-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall
executable file
·181 lines (157 loc) · 4.09 KB
/
install
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#!/bin/bash
GREEN="\033[1;32m"
NOCOLOR="\033[0m"
RED="\033[1;31m"
YELLOW="\033[1;33m"
DESTDIR=${DESTDIR:-/usr/local}
if [ "$1" == "--destdir" ]; then
if [ -d "$2" ]; then
DESTDIR=$2
else
echo -ne "\n${RED}Error: Not a directory$NOCOLOR\n"
exit 1
fi
fi
if [ "${1:0:10}" == "--destdir=" ]; then
dir=${1:10}
if [ -d "$dir" ]; then
DESTDIR=$dir
else
echo -ne "\n${RED}Error: Not a directory$NOCOLOR\n"
exit 1
fi
fi
QUIT=false
WARN=false
USER="$(whoami)"
echo -e "\n${GREEN}Aletheia $(grep "VERSION=" < aletheia | cut -d'"' -f2)\n"
check_dep() {
local dependency_name="$1"
local only_warn="$2"
echo -ne "${NOCOLOR}Checking for $dependency_name... "
if [ ! -x "$(command -v "$dependency_name")" ]; then
if [ "$only_warn" != true ]; then
echo -e "${RED}no"
QUIT=true
else
echo -e "${YELLOW}no"
WARN=true
fi
else
echo -e "${GREEN}yes"
fi
}
check_dep bash
check_dep bc
check_dep calc
check_dep espeak-ng
check_dep exiftool
check_dep ffmpeg
check_dep ffprobe
#check_dep iconv
check_dep mplayer
check_dep pactl
check_dep sox
check_dep sqlite3
check_dep vim
echo -e "\nOptional Dependencies\n"
check_dep eyeD3 true
check_dep flac true
check_dep gtts-cli true
check_dep parallel true
check_dep play true
if [ "$WARN" == true ]; then
echo -ne "\n${YELLOW}Warning: ${NOCOLOR}Optional dependencies missing.\n\n"
echo -ne "${YELLOW}Continue anyway [${GREEN}y${YELLOW}/${RED}n${YELLOW}]? "
read -rsn1 key
if [ "$key" != "y" ] && [ "$key" != "Y" ]; then
if [ "$key" == $'\e' ]; then
read -rsn3 -t 0.001
fi
echo
exit 1
else
echo
fi
elif [ "$QUIT" == true ]; then
echo -ne "\n${RED}Error: ${NOCOLOR}Missing dependencies.\n\n"
exit 1
fi
if [ ! -w "$DESTDIR" ]; then
echo -e "\n${RED}Error:$NOCOLOR Need root permission to install in $DESTDIR"
exit 1
fi
echo -ne "\n${NOCOLOR}Installing... $NOCOLOR"
DESTDIR=${DESTDIR%/}
FAIL=false
mkdir -p "$DESTDIR/bin/"
mkdir -p "$DESTDIR/share/man/man1/"
mkdir -p "$DESTDIR/share/applications/"
mkdir -p "$DESTDIR/share/aletheia/themes/"
mkdir -p "$DESTDIR/share/aletheia/vimrc/"
mkdir -p "$DESTDIR/share/aletheia/languages/"
mkdir -p "$DESTDIR/share/icons/"
if ! install -m 755 aletheia "$DESTDIR/bin/"; then
FAIL=true
fi
if ! install -m 755 aletheia_desktop_launcher "$DESTDIR/bin/"; then
FAIL=true
fi
if ! install -m 644 aletheia.1 "$DESTDIR/share/man/man1/"; then
FAIL=true
fi
if ! install -m 644 aletheia.desktop "$DESTDIR/share/applications/"; then
FAIL=true
fi
if ! install -m 644 aletheia.png "$DESTDIR/share/icons/"; then
FAIL=true
fi
if ! install -m 644 ./themes/* "$DESTDIR/share/aletheia/themes/"; then
FAIL=true
fi
if ! install -m 644 ./vimrc/* "$DESTDIR/share/aletheia/vimrc/"; then
FAIL=true
fi
if ! install -m 644 ./languages/* "$DESTDIR/share/aletheia/languages/"; then
FAIL=true
fi
if ! install -m 644 example.* "$DESTDIR/share/aletheia/"; then
FAIL=true
fi
sed -i "/^ALETHEIA_DATA_DIR/s#.*#ALETHEIA_DATA_DIR=\"${DESTDIR}/share/aletheia/\"#g" "$DESTDIR/bin/aletheia"
FILES[0]="${DESTDIR}/bin/aletheia"
FILES[1]="${DESTDIR}/bin/aletheia_desktop_launcher"
FILES[2]="${DESTDIR}/share/man/man1/aletheia.1"
FILES[3]="${DESTDIR}/share/applications/aletheia.desktop"
FILES[4]="${DESTDIR}/share/icons/aletheia.png"
FILES+=("${DESTDIR}/share/aletheia/example."*)
FILES+=("${DESTDIR}/share/aletheia/vimrc/"*)
FILES+=("${DESTDIR}/share/aletheia/themes/"*)
FILES+=("${DESTDIR}/share/aletheia/languages/"*)
for i in $(seq 0 $((${#FILES[@]}-1))); do
chown "$USER:$USER" "${FILES[i]}"
done
if ! $FAIL; then
echo -ne "${GREEN}done$NOCOLOR"
echo -ne "\n${NOCOLOR}Updating man pages... $NOCOLOR"
if ! mandb >/dev/null 2>/dev/null; then
echo -ne "${RED}failed$NOCOLOR"
else
echo -ne "${GREEN}done$NOCOLOR"
fi
echo -e "\n"
for i in $(seq 0 $((${#FILES[@]}-1))); do
path="${FILES[i]%/*}"
file="${FILES[i]##*/}"
echo -e "$NOCOLOR$path/$GREEN$file"
done
if [ "$DESTDIR" != "/usr/local" ] && [ "$DESTDIR" != "/usr/local/" ]; then
echo -e "\n${NOCOLOR}Use ${GREEN}./uninstall --destdir $DESTDIR$NOCOLOR to remove.\n"
else
echo -e "\n${NOCOLOR}Use ${GREEN}./uninstall$NOCOLOR to remove.\n"
fi
exit 0
else
echo -e "${RED}failed$NOCOLOR\n"
exit 1
fi