-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·88 lines (75 loc) · 1.73 KB
/
install.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
88
#!/bin/sh
REPOSITORY="$(dirname "$(realpath "${0}")")"
install_suckless() {
if [ "$(id -u)" -ne 0 ]; then
echo "Super user is required to install suckless software."
if command -v "sudo" > /dev/null 2>&1; then
sudo "${0}" suckless
exit 0
fi
fi
echo "Installing suckless software..."
cd "${REPOSITORY}/suckless"
for suckless_item in *; do
[ -e "${suckless_item}" ] || break
cd "${suckless_item}"
printf "Building %s..." "${suckless_item}"
if make > /dev/null 2>&1; then
echo "OK"
else
echo "FAILED"
false
fi
printf "Installing %s..." "${suckless_item}"
if make install > /dev/null 2>&1; then
echo "OK"
else
echo "FAILED"
false
fi
make clean > /dev/null 2>&1
cd "${REPOSITORY}/suckless"
done
cd "${REPOSITORY}"
}
install_home() {
echo "Installing config files..."
[ -z "${HOME}" ] && (echo "\$HOME isn't defined" && false)
cd "${REPOSITORY}/home"
config_files="$(find . -follow | sed -n '1!p' | cut -c3-)"
for file in $config_files; do
printf "%s..." "${file}"
if [ -d "${file}" ]; then
if [ ! -d "${HOME}/${file}" ]; then
mkdir --parents "${HOME}/${file}"
fi
elif [ -f "${file}" ]; then
if [ -f "${HOME}/${file}" ]; then
cd "${HOME}"
cp --parents "${file}" "${REPOSITORY}/backup-home"
rm -r "${HOME:?}/${file:?}"
cd "${REPOSITORY}/home"
fi
ln -sf "${REPOSITORY}/home/${file}" "${HOME}/${file}"
else
echo "${file} is something else..."
fi
echo "DONE"
done
cd "${REPOSITORY}"
}
usage() {
echo "$0 home|suckless"
exit 0
}
set -e
case $1 in
"home")
install_home
;;
"suckless")
install_suckless
;;
*)
usage
esac