-
Notifications
You must be signed in to change notification settings - Fork 3
/
installer.sh
481 lines (418 loc) · 18.4 KB
/
installer.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
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
#!/bin/bash
# /*!
# * Termsteel Installer V0.4BETA
# * (c) 2022 Afi
# * Released under the MIT License.
# */
#EXPORT
export NEWT_COLORS='
root=white,gray
window=white,lightgray
border=black,lightgray
shadow=white,black
button=black,green
actbutton=black,red
compactbutton=black,
title=black,
roottext=black,gray
textbox=black,lightgray
acttextbox=gray,white
entry=lightgray,gray
disentry=gray,lightgray
checkbox=black,lightgray
actcheckbox=black,green
emptyscale=,black
fullscale=,red
listbox=black,lightgray
actlistbox=lightgray,gray
actsellistbox=black,green
'
# === FUNCTIONS ===
function Python_check() {
type -P python3 >/dev/null 2>&1 && Python_Installed=yes
if [[ "$Python_Installed" == 'yes' ]]; then
Wget_check
else
if whiptail --yesno "Termsteel detects that Python3 is not installed on your machine, but this is necessary in the installation of termsteel.\n\nDo you want Termsteel installer install Python 3 for you ?" 15 50; then
sudo apt-get install python3 &>/dev/null
sudo apt install python3-pip &>/dev/null
Python_check
else
exit 1
fi
fi
}
function Wget_check() {
type -P wget >/dev/null 2>&1 && Wget_Installed=yes
if [[ "$Wget_Installed" == 'yes' ]]; then
Fastjar_check
else
if whiptail --yesno "Termsteel detects that Wget is not installed on your machine, but this is necessary in the installation of termsteel.\n\nDo you want Termsteel installer install Wget for you ?" 15 50; then
apt-get install wget &>/dev/null
Wget_check
fi
fi
}
function Fastjar_check() {
type -P fastjar >/dev/null 2>&1 && Fastjar_Installed=yes
if [[ "$Fastjar_Installed" == 'yes' ]]; then
Termsteel_version
else
if whiptail --yesno "Termsteel detects that Fastjar is not installed on your machine, but this is necessary in the installation of termsteel.\n\nDo you want Termsteel installer install Fastjar for you ?" 15 50; then
apt-get install fastjar &>/dev/null
Termsteel_version
fi
fi
}
function Menu() {
CHOICE=$(whiptail --menu "Termsteel installer V0.4beta" 18 100 10 \
"1." "Install Termsteel" \
"2." "Troubleshooting" \
"3." "Exit Termsteel installer" 3>&1 1>&2 2>&3)
if [ -z "$CHOICE" ]; then
exit 1
else
if [[ "$CHOICE" == '1.' ]]; then
Python_check
elif [[ "$CHOICE" == '2.' ]]; then
Troubleshooting
elif [[ "$CHOICE" == '3.' ]]; then
exit 1
else
exit 1
fi
fi
}
function Troubleshooting() {
TRS_CHOICE=$(whiptail --menu --nocancel "Termsteel installer V0.4beta > Troubleshooting" 18 100 10 \
"1." "Uninstall Termsteel" \
"2." "Update Termsteel" \
"3." "Reinstall all Termsteel dependencies" \
"4." "Back" 3>&1 1>&2 2>&3)
if [ -z "$TRS_CHOICE" ]; then
exit 1
else
if [[ "$TRS_CHOICE" == '1.' ]]; then
Uninstall_Termsteel
elif [[ "$TRS_CHOICE" == '2.' ]]; then
whiptail --msgbox --title "Update Termsteel" "This feature is not available in this version of Termsteel installer" 15 50 && Troubleshooting
elif [[ "$TRS_CHOICE" == '3.' ]]; then
Reinstall_Termsteel_Deeps
elif [[ "$TRS_CHOICE" == '4.' ]]; then
Menu
else
exit 1
fi
fi
}
function Termsteel_version() {
VERSION_CHOICE=$(whiptail --menu --nocancel "Please choose a version of Termsteel" 18 100 10 \
"1." "TERMSTEEL BETA_V0.0.1" 3>&1 1>&2 2>&3)
if [ -z "$VERSION_CHOICE" ]; then
exit 1
else
if [[ "$VERSION_CHOICE" == '1.' ]]; then
Licensing
else
exit
fi
fi
}
function Licensing() {
LICENSING_URL="https://raw.githubusercontent.com/afi-dev/Termsteel/main/LICENSE"
wget "$LICENSING_URL" 2>&1 | \
stdbuf -o0 awk '/[.] +[0-9][0-9]?[0-9]?%/ { print substr($0,63,3) }' | \
whiptail --title "EULA" --gauge "Downloading EULA from https://raw.githubusercontent.com/afi-dev/Termsteel/main/LICENSE" 10 100 0
if(whiptail --title "Licensing" --textbox "LICENSE" --scrolltext 25 75 --ok-button "Next"); then
if(whiptail --title "Licensing" --yesno "To install termsteel you must absolutely accept this license. Wishing you to accept the agreements subscribed in the terms ?" --scrolltext 25 75 --yes-button Agree --no-button Reject); then
rm LICENSE -f
Eula
else
rm LICENSE -f
Menu
fi
else
exit 0
fi
}
function Eula() {
EULA_URL="https://raw.githubusercontent.com/afi-dev/Termsteel/main/EULA"
wget "$EULA_URL" 2>&1 | \
stdbuf -o0 awk '/[.] +[0-9][0-9]?[0-9]?%/ { print substr($0,63,3) }' | \
whiptail --title "EULA" --gauge "Downloading EULA from https://raw.githubusercontent.com/afi-dev/Termsteel/main/EULA" 10 100 0
if(whiptail --title "EULA Agreements" --textbox "EULA" --scrolltext 25 75 --ok-button "Next"); then
if(whiptail --title "EULA Agreements" --yesno "To install termsteel you must absolutely accept these EULA agreements. Wishing you to accept the agreements subscribed in the terms ?" --scrolltext 25 75 --yes-button Agree --no-button Reject); then
rm EULA -f
Install_Termsteel
else
rm EULA -f
Menu
fi
else
exit 0
fi
}
function Install_Termsteel() {
python_ver="$(python3 -c 'import sys; print(".".join(map(str, sys.version_info[0:2])))')"
termsteel --version &>/dev/null
if [ $? -eq 0 ]; then
whiptail --msgbox "Termsteel is already installed" --title "Already installed" 15 50
Menu
else
msgs=("Preparing Install..."
"Starting Update your system..."
"Preparing installing all dependencies (Python Librairies)"
"Starting Install argon2-cffi==21.3.0"
"Starting Install argon2-cffi-bindings==21.2.0"
"Starting Install bidict==0.22.0"
"Starting Install certifi==2022.5.18.1"
"Starting Install cffi==1.15.0"
"Starting Install charset-normalizer==2.0.12"
"Starting Install click==7.1.2"
"Starting Install Flask==1.0.2"
"Starting Install Flask-Argon2==0.2.0.0"
"Starting Install flask-jwt-login==0.0.5"
"Starting Install Flask-SocketIO==5.2.0"
"Starting Install idna==3.3"
"Starting Install importlib-metadata==4.11.4"
"Starting Install itsdangerous==1.1.0"
"Starting Install Jinja2==2.11.3"
"Starting Install markup==0.2"
"Starting Install MarkupSafe==2.0.1"
"Starting Install pycparser==2.21"
"Starting Install PyJWT==1.6.4"
"Starting Install python-engineio==4.2.1"
"Starting Install python-socketio==5.4.0"
"Starting Install requests==2.27.1"
"Starting Install urllib3==1.26.9"
"Starting Install waitress==2.1.2"
"Starting Install Werkzeug==1.0.1"
"Starting Install zipp==3.8.0"
"Preparing Extracting Termsteel files"
"Starting cd into /tmp"
"Starting Download termsteel_v0.0.1.tar.gz"
"Starting Unpacking termsteel_v0.0.1.tar.gz"
"Starting cd into termsteel_v0.0.1"
"Starting Install Termsteel in python3 distpackage"
"export"
"Starting Add $USER permissions to dist-packages on termsteel"
"Starting Add $USER permissions to dist-packages on termsteel"
"Starting Setup FLASK_APP on termsteel"
"Starting Setup FLASK_ENV on development"
"Starting cd into /tmp"
"Starting Removing /termsteel_v0.0.1"
"Starting Removing termsteel_v0.0.1"
...
)
commands=("sleep 0.5"
"sudo apt-get update &>/dev/null"
"sleep 0.5"
"sudo pip install argon2-cffi==21.3.0 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install argon2-cffi-bindings==21.2.0 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install bidict==0.22.0 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install certifi==2022.5.18.1 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install cffi==1.15.0 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install charset-normalizer==2.0.12 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install click==7.1.2 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install Flask==1.0.2 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install Flask-Argon2==0.2.0.0 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install flask-jwt-login==0.0.5 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install Flask-SocketIO==5.2.0 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install idna==3.3 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install importlib-metadata==4.11.4 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install itsdangerous==1.1.0 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install Jinja2==2.11.3 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install markup==0.2 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install MarkupSafe==2.0.1 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install pycparser==2.21 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install PyJWT==1.6.4 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install python-engineio==4.2.1 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install python-socketio==5.4.0 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install requests==2.27.1 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install urllib3==1.26.9 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install waitress==2.1.2 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install Werkzeug==1.0.1 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install zipp==3.8.0 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sleep 0.5"
"cd /tmp &>/dev/null"
"sudo wget https://github.com/afi-dev/Termsteel/releases/download/v0.0.1/termsteel_v0.0.1.tar.gz &>/dev/null"
"sudo tar -xvf termsteel_v0.0.1.tar.gz"
"cd termsteel_v0.0.1"
"sudo python3 setup.py install &>/dev/null"
"sudo chown -R $USER /usr/local/lib/python$python_ver/dist-packages/"
"sudo chown -R $USER /usr/local/lib/python$python_ver/dist-packages/"
"export FLASK_APP=termsteel &>/dev/null"
"export FLASK_ENV=development &>/dev/null"
"cd /tmp &>/dev/null"
"sudo rm -rf termsteel_v0.0.1"
"sudo rm -f termsteel_v0.0.1.tar.gz"
...
)
n=${#commands[@]}
i=0
while [ "$i" -lt "$n" ]; do
pct=$(( i * 100 / n ))
echo XXX
echo $i
echo "${msgs[i]}"
echo XXX
echo "$pct"
eval "${commands[i]}"
i=$((i + 1))
done | whiptail --title "Installing Termsteel..." --gauge "We are almost there be patient..." 10 60 0
Check_is_install
fi
}
function Check_is_install() {
if command -v termsteel &> /dev/null; then
termsteel --version &>/dev/null
if [ $? -eq 0 ]; then
All_done
else
whiptail --msgbox --title "Error" "Termsteel installer encountered an error during the installation and did not correctly install termsteel, tried to restart an installation, if the problem persists send an issue on github." 15 50
fi
else
whiptail --msgbox --title "Error" "Termsteel installer encountered an error during the installation and did not correctly install termsteel, tried to restart an installation, if the problem persists send an issue on github." 15 50
exit
fi
}
function All_done() {
whiptail --title "Termsteel installed" --msgbox "Termsteel V0.0.1 has been successfully installed ! \n\nIf you encounter a problem do not hesitate to let me know by creating an issue on github. \n\nHave fun with Termsteel" 15 50
exit
}
function Uninstall_Termsteel() {
termsteel --version &>/dev/null
if [ $? -eq 0 ]; then
if (whiptail --title "Uninstall Termsteel" --yesno "Do you want really uninstall Termsteel ?" 15 50); then
sudo rm /usr/local/lib/python$python_ver/dist-packages/* -rf
sudo rm /usr/local/bin/termsteel -f
whiptail --msgbox "Termsteel has just been successfully uninstalled" --title "Uninstalled" 15 50
Troubleshooting
else
Troubleshooting
fi
else
whiptail --msgbox "Termsteel is not installed on this system" --title "Termsteel not installed" 15 50
if (whiptail --title "Install Termsteel" --yesno "Do you want install Termsteel ?" 15 50); then
Install_Termsteel
else
Troubleshooting
fi
Troubleshooting
fi
Troubleshooting
}
function Reinstall_Termsteel_Deeps() {
msgs=("Preparing Install..."
"Starting Install argon2-cffi==21.3.0"
"Starting Install argon2-cffi-bindings==21.2.0"
"Starting Install bidict==0.22.0"
"Starting Install certifi==2022.5.18.1"
"Starting Install cffi==1.15.0"
"Starting Install charset-normalizer==2.0.12"
"Starting Install click==7.1.2"
"Starting Install Flask==1.0.2"
"Starting Install Flask-Argon2==0.2.0.0"
"Starting Install flask-jwt-login==0.0.5"
"Starting Install Flask-SocketIO==5.2.0"
"Starting Install idna==3.3"
"Starting Install importlib-metadata==4.11.4"
"Starting Install itsdangerous==1.1.0"
"Starting Install Jinja2==2.11.3"
"Starting Install markup==0.2"
"Starting Install MarkupSafe==2.0.1"
"Starting Install pycparser==2.21"
"Starting Install PyJWT==1.6.4"
"Starting Install python-engineio==4.2.1"
"Starting Install python-socketio==5.4.0"
"Starting Install requests==2.27.1"
"Starting Install urllib3==1.26.9"
"Starting Install waitress==2.1.2"
"Starting Install Werkzeug==1.0.1"
"Starting Install zipp==3.8.0"
...
)
commands=("sleep 0.5"
"sudo pip install argon2-cffi==21.3.0 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install argon2-cffi-bindings==21.2.0 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install bidict==0.22.0 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install certifi==2022.5.18.1 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install cffi==1.15.0 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install charset-normalizer==2.0.12 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install click==7.1.2 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install Flask==1.0.2 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install Flask-Argon2==0.2.0.0 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install flask-jwt-login==0.0.5 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install Flask-SocketIO==5.2.0 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install idna==3.3 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install importlib-metadata==4.11.4 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install itsdangerous==1.1.0 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install Jinja2==2.11.3 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install markup==0.2 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install MarkupSafe==2.0.1 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install pycparser==2.21 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install PyJWT==1.6.4 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install python-engineio==4.2.1 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install python-socketio==5.4.0 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install requests==2.27.1 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install urllib3==1.26.9 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install waitress==2.1.2 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install Werkzeug==1.0.1 --no-dependencies --upgrade --force-reinstall &>/dev/null"
"sudo pip install zipp==3.8.0 --no-dependencies --upgrade --force-reinstall &>/dev/null"
...
)
n=${#commands[@]}
i=0
while [ "$i" -lt "$n" ]; do
pct=$(( i * 100 / n ))
echo XXX
echo $i
echo "${msgs[i]}"
echo XXX
echo "$pct"
eval "${commands[i]}"
i=$((i + 1))
done | whiptail --title "Reinstallation of dependencies..." --gauge "We are almost there be patient..." 10 60 0
whiptail --msgbox --title "Successfully re-installed" "Dependencies successfully re-installed" 15 50
Troubleshooting
}
# === SCRIPT ===
# Force User to use sudo
if [[ $(/usr/bin/id -u) -ne 0 ]]; then
whiptail --msgbox --title "Termsteel installer need sudo permission" "Please run Termsteel installer with sudo." 15 50
exit 1
fi
# Force User to use bash => 3.
if [ -z ${BASH} ]; then
whiptail --msgbox --title "Please run the script using the bash interpreter." "Termsteel installer need bash" 15 50
exit 1
else
bash_major_version=${BASH_VERSION:0:1}
if [ ${bash_major_version} -lt 3 ]; then
echo "Please run the script using bash version 3 or greater"
exit 1
fi
fi
echo """
.::::::.
.::^^::::::^^:..
.:^^:::::....:::::^::.
.::^^::::....::::....::::^^::.
:^^:::....::::::::::::....:::^^:
^^::...::::::..::::::::::::...::^^
:^::.:::::::..^:.::::::::::::::.::^:
:^::.::::...^YY:.::::::::::::::.::^:
:^::.:::.:~5&&!^:.:::::::::::::.::^:
:^::.:::.^J5@@#J:..........::::.::^:
:^::.::::..J#J^..:~!!!!!!!^.:::.::^:
:^::.::::.^7:..:.:PGGGGGGG7.:::.::^:
:^::.::::::..::::..........::::.::^:
^^::...::::::::::.........:...::^^
:^^:::....::::::::::::....:::^^:
.::^^::::....::::....::::^^::.
.:^^^::::....::::^^^:.
.::^^^::::^^^:..
.::::::.
"""
sleep 1
Menu