-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall
More file actions
executable file
·155 lines (133 loc) · 3.76 KB
/
install
File metadata and controls
executable file
·155 lines (133 loc) · 3.76 KB
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
#!/bin/bash
# Copyright Brad Hermanson 2026
#
# This file is part of Aletheia.
#
# Aletheia is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# Aletheia is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with Aletheia. If not, see <https://www.gnu.org/licenses/agpl-3.0.en.html>.
NAME="aletheia-mobile"
FILES=
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 "${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 "${RED}Error: Not a directory$NOCOLOR\n"
exit 1
fi
fi
QUIT=false
USER="$(whoami)"
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"
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 mpv
check_dep node
check_dep jq
check_dep socat
check_dep gtts-cli true
if [ "$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" "$DESTDIR/share/$NAME/" "$DESTDIR/share/doc/$NAME/"
chmod 755 "$DESTDIR/bin" "$DESTDIR/share/$NAME/" "$DESTDIR/share/doc/$NAME/"
if ! install -m 755 aletheia-mobile "$DESTDIR/bin/"; then
FAIL=true
fi
if ! install -m 644 index.html "$DESTDIR/share/$NAME/"; then
FAIL=true
fi
if ! install -m 644 aletheia-webserver.js "$DESTDIR/share/$NAME/"; then
FAIL=true
fi
if ! install -m 644 LICENSE "$DESTDIR/share/doc/$NAME/"; then
FAIL=true
fi
if ! install -m 644 theme*.css "$DESTDIR/share/$NAME/"; then
FAIL=true
fi
if ! install -m 644 language.* "$DESTDIR/share/$NAME/"; then
FAIL=true
fi
if ! install -m 644 aletheia-mobile.svg "$DESTDIR/share/$NAME/"; then
FAIL=true
fi
sed -i "/^ALETHEIA_DATA_DIR/s#.*#ALETHEIA_DATA_DIR=\"${DESTDIR}/share/aletheia-mobile/\"#g" "$DESTDIR/bin/aletheia-mobile"
FILES+=("${DESTDIR}/bin/aletheia-mobile")
FILES+=("${DESTDIR}/share/aletheia-mobile/index.html")
FILES+=("${DESTDIR}/share/aletheia-mobile/aletheia-webserver.js")
FILES+=("${DESTDIR}/share/doc/aletheia-mobile/LICENSE")
FILES+=("${DESTDIR}/share/aletheia-mobile/theme"*".css")
FILES+=("${DESTDIR}/share/aletheia-mobile/language."*)
FILES+=("${DESTDIR}/share/aletheia-mobile/aletheia-mobile.svg")
for i in $(seq 0 $((${#FILES[@]}-1))); do
if [ -n "${FILES[i]}" ]; then
chown "$USER:$USER" "${FILES[i]}"
fi
done
if ! $FAIL; then
echo -ne "${GREEN}done$NOCOLOR\n\n"
for i in $(seq 1 $((${#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 -ne "\n${NOCOLOR}Use ${GREEN}./uninstall --destdir $DESTDIR$NOCOLOR to remove.\n"
else
echo -ne "\n${NOCOLOR}Use ${GREEN}./uninstall$NOCOLOR to remove.\n"
fi
exit 0
else
echo -ne "${RED}failed$NOCOLOR\n"
exit 1
fi