forked from synaptiko/.files
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.sh
executable file
·87 lines (72 loc) · 2.1 KB
/
init.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
function checkDependency {
repository=`echo $1 | cut -d'/' -f1`
dependencyName=`echo $1 | cut -d'/' -f2`
dependency=$dependencyName
if [ $repository == "aur" ]; then
repository=" (aur)";
elif [ $repository == "synaptiko" ]; then
repository=" (synaptiko)";
dependency="synaptiko-$dependency";
else
repository="";
fi
if pacman -Qs $dependency &> /dev/null; then
echo -e " \e[32m✓\e[0m $dependencyName$repository"
return 0
else
echo -e " \e[31m✖\e[0m $dependencyName$repository"
return 1
fi
}
mkdir -p $DIR/.logs
for moduleDir in `find $DIR/*/ -maxdepth 1 -type d | sort`; do
module=`basename $moduleDir`
failedDependenciesCount=0
if [ ! -f ${moduleDir}install.sh ]; then
continue
fi
echo -e "\e[1m$module\e[0m module:"
if [ -f $module/dependencies ] && [ `wc -l $module/dependencies | cut -d' ' -f1` != "0" ]; then
echo "- checking dependencies:"
moduleDependencies=$(<$moduleDir/dependencies)
for dependency in $moduleDependencies; do
if ! checkDependency $dependency; then
((failedDependenciesCount+=1))
fi
done
fi
if [ $failedDependenciesCount -gt 0 ]; then
(>&2 echo " Missing dependencies ($failedDependenciesCount) => skipping installation")
else
# for some modules sudo access is required; authorize now
sudo true
echo -n "- installing: "
if ${moduleDir}install.sh >& $DIR/.logs/$module; then
echo -e "\e[32m✓\e[0m"
else
echo -e "\e[31m✖"
sed -E 's/^/ /' $DIR/.logs/$module
echo -en "\e[0m"
fi
if [ -f ${moduleDir}install-under-root ]; then
echo -n "- installing for root user: "
if sudo ${moduleDir}install.sh >& $DIR/.logs/$module-root; then
echo -e "\e[32m✓\e[0m"
else
echo -e "\e[31m✖"
sed -E 's/^/ /' $DIR/.logs/$module-root
echo -en "\e[0m"
fi
fi
fi
echo
done
for moduleDir in `find $DIR/*/ -maxdepth 1 -type d`; do
# execute post-install scripts if any
if [ -f ${moduleDir}post-install.sh ]; then
echo -e "\e[1m$module\e[0m module post-install script found, executing…"
${moduleDir}post-install.sh
fi
done