/
install_comsetup.sh
executable file
·472 lines (414 loc) · 13.1 KB
/
install_comsetup.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
################################################
# Under GPL license
# https://www.gnu.org/licenses/gpl.html
# Authors: Patrick Dutoit
# Laurent Roge
# On June 10 2017
# V0.1
# v0.2 ajout de browsepy (Patrick Dutoit)
################################################
#!/bin/bash -i
######
# Recherche du répertoire ConfigTinker
######
if [[ -z "$nafabox_path" ]]
then
echo "Run first Pre_Install.sh and reload Terminal"
exit
fi
dirinstall=${nafabox_path}
server_choice=$1
figlet -k Install ComSetup
echo "================================================="
echo "================================================="
echo " Install time zone, Web Interface, X11VNC, WebDavServer, BrowsePy and NoVNC"
echo "================================================="
echo "================================================="
cd ${dirinstall}
######
# detect language
######
source ${dirinstall}/detect_language.sh
source ${dirinstall}/proctype.sh
sudo apt-get update
if [[ ${server_choice} == "server" ]]
then
echo "############################"
echo "## install in server mode ##"
echo "############################"
web=TRUE
xvnc=FALSE
dav=TRUE
browse=TRUE
novnc=FALSE
nomach=FALSE
ddserv=TRUE
mobindi=FALSE
elif [[ ${server_choice} == "default" ]]
then
echo "#############################"
echo "## install in default mode ##"
echo "#############################"
web=TRUE
xvnc=TRUE
dav=TRUE
browse=TRUE
novnc=TRUE
nomach=TRUE
ddserv=TRUE
mobindi=TRUE
else
if ${french}
then
dial[0]="Installation/Mise à jour des logiciels"
dial[1]="Choisir le(s) logiciel(s) à installer"
choice[0]="Installation Interface HTML"
choice[1]="Installation X11VNC"
choice[2]="Install WebDav"
choice[3]="Installation BrowsePy"
choice[4]="Installation NoVNC"
choice[5]="Installation Nomachine"
choice[6]="Serveur pour QDslrDashboard"
choice[7]="Installation de Mobindi"
else
dial[0]="Install/Update of software"
dial[1]="Choose software(s) to install"
choice[0]="Install HTML Interface"
choice[1]="Install X11VNC"
choice[2]="Install WebDav"
choice[3]="Install BrowsePy"
choice[4]="Install NoVNC"
choice[5]="Install Nomachine"
choice[6]="Server for QDslrDashboard"
choice[7]="Install Mobindi"
fi
st=(true true true true true true true true)
# interface de choix
if chose=`yad --width=400 \
--center \
--form \
--title="${dial[0]}" \
--text="${dial[1]}" \
--field=":LBL" \
--field="${choice[0]}:CHK" \
--field="${choice[1]}:CHK" \
--field="${choice[2]}:CHK" \
--field="${choice[3]}:CHK" \
--field="${choice[4]}:CHK" \
--field="${choice[5]}:CHK" \
--field="${choice[6]}:CHK" \
--field="${choice[7]}:CHK" \
"" "${st[0]}" "${st[1]}" "${st[2]}" \
"${st[3]}" "${st[4]}" "${st[5]}" "${st[6]}" \
"${st[7]}"`
then
web=$(echo "$chose" | cut -d "|" -f2)
xvnc=$(echo "$chose" | cut -d "|" -f3)
dav=$(echo "$chose" | cut -d "|" -f4)
browse=$(echo "$chose" | cut -d "|" -f5)
novnc=$(echo "$chose" | cut -d "|" -f6)
nomach=$(echo "$chose" | cut -d "|" -f7)
ddserv=$(echo "$chose" | cut -d "|" -f8)
mobindi=$(echo "$chose" | cut -d "|" -f9)
else
echo "cancel"
fi
fi
if [[ ${web} == "TRUE" ]]
then
figlet -k Install web server
######
# Installer nginx
######
sudo apt-get -y install nginx apache2 cockpit python3
######
# Installer php
######
sudo apt-get -y install php
######
# Creer le répertoire www
######
site=/home/${USER}/www
mkdir -p /home/${USER}/www
######
# Installer les fichiers nécessaires pour la mise à l'heure
# en remote
######
# le fichier html d'accès au site
dial[0]="Actuate Date"
dial[1]="To update remote date do connect to the box with its
IP adress which is different if it is on home network or access point"
# create folder
mkdir ~/bin/
# copy phython script
cp ${dirinstall}/cpu_load.py ~/bin/cpu_load.py
# stop nginx service
sudo systemctl stop nginx.service
sudo systemctl disable nginx.service
# copy php file
sudo cp ${dirinstall}/startup.php ${site}/startup.php
sudo cp ${dirinstall}/setdate.php ${site}/setdate.php
cat ${dirinstall}/getTemp.php | sed -e "s/TOTO/${USER}/g" > /tmp/getTemp.php
sudo cp /tmp/getTemp.php ${site}/getTemp.php
sudo cp ${dirinstall}/hotspot_control.php ${site}/hotspot_control.php
sudo cp ${dirinstall}/logo_256.png ${site}/logo_256.png
sudo cp ${dirinstall}/light.css ${site}/light.css
sudo cp ${dirinstall}/dark.css ${site}/dark.css
sudo cp ${dirinstall}/shutdown_reboot.php ${site}/shutdown_reboot.php
# change right acces for all www file
sudo chown www-data:www-data ${site}/startup.php
sudo chown www-data:www-data ${site}/setdate.php
sudo chown www-data:www-data ${site}/getTemp.php
sudo chown www-data:www-data ${site}/hotspot_control.php
sudo chown www-data:www-data ${site}/logo_256.png
sudo chown www-data:www-data ${site}/light.css
sudo chown www-data:www-data ${site}/dark.css
sudo chown www-data:www-data ${site}/shutdown_reboot.php
# add execute right on php file
sudo chmod +x ${site}/startup.php
sudo chmod +x ${site}/setdate.php
sudo chmod +x ${site}/getTemp.php
sudo chmod +x ${site}/hotspot_control.php
sudo chmod +x ${site}/shutdown_reboot.php
# add web right
sudo adduser www-data netdev
# ajout droit d'acces pour nginx
sudo gpasswd -a www-data ${USER}
# add right for nmcli command
# sudo
# move apache at port 8280
cat /etc/apache2/ports.conf | sed -e "s/Listen 80/Listen 8280/g" > /tmp/ports.conf
sudo mv /tmp/ports.conf /etc/apache2/ports.conf
cat /etc/apache2/sites-enabled/000-default.conf | sed -e "s=*:80=*:8280=g" > /tmp/000-default.conf
sudo mv /tmp/000-default.conf /etc/apache2/sites-enabled/000-default.conf
sudo service apache2 restart
# restart nginx
sudo systemctl enable nginx.service
sudo systemctl start nginx.service
cat sudoers.txt | sed -e "s/MOI/${USER}/g" > /tmp/sudoers
sudo cp /tmp/sudoers /etc/sudoers.d/perm${USER}
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo "${dial[1]}"
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
######
# Installation du serveur nginx et PHP
######
# mod 22/11/2018
sudo apt-get install -y --reinstall php-fpm
#
sudo apt-get install -y --reinstall nginx
sudo apt-get -y install php-fpm
sudo rm /etc/nginx/sites-available/default
sudo rm /etc/nginx/sites-enabled/default
cat ${dirinstall}/server.txt | sed -e "s/MOI/${USER}/g" > /tmp/site-temp
if [[ -S "/var/run/php/php7.0-fpm.sock" ]]
then
cat /tmp/site-temp | sed -e "s/VER-PHP/7.0/g" > /tmp/site-${USER}
elif [[ -S "/var/run/php/php7.1-fpm.sock" ]]
then
cat /tmp/site-temp | sed -e "s/VER-PHP/7.1/g" > /tmp/site-${USER}
elif [[ -S "/var/run/php/php7.2-fpm.sock" ]]
then
cat /tmp/site-temp | sed -e "s/VER-PHP/7.2/g" > /tmp/site-${USER}
elif [[ -S "/var/run/php/php7.3-fpm.sock" ]]
then
cat /tmp/site-temp | sed -e "s/VER-PHP/7.3/g" > /tmp/site-${USER}
elif [[ -S "/var/run/php/php7.4-fpm.sock" ]]
then
cat /tmp/site-temp | sed -e "s/VER-PHP/7.4/g" > /tmp/site-${USER}
elif [[ -S "/var/run/php/php8.0-fpm.sock" ]]
then
cat /tmp/site-temp | sed -e "s/VER-PHP/8.0/g" > /tmp/site-${USER}
elif [[ -S "/var/run/php/php8.1-fpm.sock" ]]
then
cat /tmp/site-temp | sed -e "s/VER-PHP/8.1/g" > /tmp/site-${USER}
elif [[ -S "/var/run/php/php8.2-fpm.sock" ]]
then
cat /tmp/site-temp | sed -e "s/VER-PHP/8.2/g" > /tmp/site-${USER}
elif [[ -S "/var/run/php/php8.3-fpm.sock" ]]
then
cat /tmp/site-temp | sed -e "s/VER-PHP/8.3/g" > /tmp/site-${USER}
fi
sudo cp /tmp/site-${USER} /etc/nginx/sites-available/site-${USER}
sudo chown ${USER}:${USER} /etc/nginx/sites-available/site-${USER}
sudo ln -sf /etc/nginx/sites-available/site-${USER} /etc/nginx/sites-enabled/site-${USER}
fi
if [[ ${dav} == "TRUE" ]]
then
######
# Install of webdav server
######
${dirinstall}/install_webdavserver.sh
fi
if [[ ${browse} == "TRUE" ]]
then
######
# Install of browsepy
######
${dirinstall}/install_browsepy.sh
fi
if [[ ${nomach} == "TRUE" ]]
then
######
# Install of nomachine server
######
${dirinstall}/install_nomachine.sh
fi
if [[ ${xvnc} == "TRUE" ]]
then
######
# Installation x11vnc
######
figlet -k Install X11VNC
sudo apt-get -y install x11vnc
# demarage sur la session
#mkdir -p ~/.x11vnc
#mkdir -p ~/bin/
#cp $dirinstall/startx11vnc.sh ~/bin/
#chmod +x ~/bin/startx11vnc.sh
#~/bin/startx11vnc.sh
#mkdir -p ~/.config/autostart/
#cat $dirinstall/startx11vnc.desktop | sed -e "s/nafa/${USER}/g" > /tmp/startx11vnc.desktop
#cp /tmp/startx11vnc.desktop ~/.config/autostart/
#
# demarage sur le X11
vnc_path=/home/${USER}/.vnc/passwd
rm ${vnc_path}
test_w=true
number_t=0
figlet -k VNC Password :
while ${test_w} && [[ "$number_t" < 3 ]]
do
echo "Enter Le mot de passe VNC pour votre BOX :"
x11vnc -storepasswd
if [[ -f ${vnc_path} ]]
then
test_w=false
else
number_t=$((number_t + 1))
echo "Reload, remaing test: "$((3-number_t))
fi
done
echo "Merci ! ----------------------------------"
machine=$(sudo lshw | grep "produit\|product" | grep "Raspberry")
normal_option="-auth guess -forever -loop -noncache -noxdamage -noxrecord -repeat -shared -xkb -rfbauth $vnc_path -rfbport 5900"
tinker_option="-forever -loop -noncache -noxdamage -noxrecord -repeat -shared -xkb -rfbauth $vnc_path -rfbport 5900"
#test version
if [[ ${proc} == "_amd64" ]]
then
option=${normal_option}
elif [[ ${proc} == "_armhf" ]]
then
if [[ ${machine} == *"Raspberry"* ]]
then
option=${normal_option}
else
option=${tinker_option}
fi
elif [[ ${proc} == "_x86" ]]
then
option=${normal_option}
elif [[ ${proc} == "_aarch64" ]]
then
if [[ ${machine} == *"Raspberry"* ]]
then
option=${normal_option}
else
option=${tinker_option}
fi
fi
# injection fichier system
cat ${dirinstall}/x11vnc.service | sed -e "s=OPTION=$option=g" > /tmp/x11vnc2.service
cat /tmp/x11vnc2.service | sed -e "s=MOI=${USER}=g" > /tmp/x11vnc.service
sudo mv /tmp/x11vnc.service /lib/systemd/system/x11vnc.service
# allumage au démarage
sudo systemctl stop x11vnc.service
sudo systemctl disable x11vnc.service
sudo systemctl daemon-reload
sudo systemctl enable x11vnc.service
sudo systemctl start x11vnc.service
echo "Need reboot for active VNC"
######
# Installation TightVNC Server
######
figlet -k Install TightVNC Server
sudo apt-get -y install tightvncserver
# injection fichier system
cat ${dirinstall}/tightvnc.service | sed -e "s=MOI=${USER}=g" > /tmp/tightvnc.service
sudo mv /tmp/tightvnc.service /lib/systemd/system/tightvnc.service
# allumage au démarage
sudo systemctl stop tightvnc.service
sudo systemctl disable tightvnc.service
sudo systemctl daemon-reload
sudo systemctl enable tightvnc.service
sudo systemctl start tightvnc.service
echo "Need reboot for active VNC"
# attention adaper la session au GUI rajouter edition dynamique avec $DESKTOP_SESSION
cp ${dirinstall}/xstartup ${HOME}/.vnc/xstartup
fi
if [[ ${novnc} == "TRUE" ]]
then
######
# Installation accès vnc via navigateur
######
figlet -k Install novnc
sudo apt-get -y install novnc
sudo apt-get -y install git
cd /home/${USER}/bin/
#
#test si le dossier noVNC existe, si oui suppression
#
if [[ -d "/home/${USER}/bin/noVNC" ]]
then
echo "suppression de l'ancien dossier noVNC"
rm -Rf /home/${USER}/bin/noVNC
fi
#version=`curl -s "https://api.github.com/repos/novnc/noVNC/releases/latest" | awk -F '"' '/tag_name/{print $4}'`
version="v1.4.0"
wget https://github.com/novnc/noVNC/archive/${version}.zip
unzip ${version}.zip
rm ${version}.zip
mv noVNC-${version:1} noVNC
#git clone git://github.com/kanaka/noVNC
if [[ -f /etc/systemd/system/novnc.service ]]
then
sudo systemctl stop novnc.service
sudo systemctl disable novnc.service
sudo rm /etc/systemd/system/novnc.service
fi
cat ${dirinstall}/novnc.service | sed -e "s=MOI=${USER}=g" > /tmp/novnc.service
sudo cp /tmp/novnc.service /lib/systemd/system/novnc.service
# sudo chmod a+rwx /lib/systemd/system/novnc.service
sudo systemctl daemon-reload
sudo systemctl enable novnc.service
sudo systemctl start novnc.service
fi
if [[ ${ddserv} == "TRUE" ]]
then
######
# Installation du ddserver pour qdslrdashboard
######
figlet -k Install ddserver
cd ~/bin
if [[ -d "/home/${USER}/bin/DslrDashboardServer" ]]
then
echo "suppression de l'ancien dossier ddserver"
rm -Rf /home/${USER}/bin/DslrDashboardServer
fi
git clone https://github.com/hubaiz/DslrDashboardServer.git
sudo apt-get -y install build-essential pkg-config libusb-1.0-0-dev
cd ~/bin/DslrDashboardServer
g++ -Wall src/main.cpp src/communicator.cpp `pkg-config --libs --cflags libusb-1.0` -lpthread -lrt -lstdc++ -o ddserver
sudo ln -sf ~/bin/DslrDashboardServer/ddserver /usr/bin/ddserver
cat ${dirinstall}/ddserver.service | sed -e "s/MOI/${USER}/g" > /tmp/ddserver.service
sudo cp /tmp/ddserver.service /lib/systemd/system/ddserver.service
sudo systemctl stop ddserver.service
sudo systemctl disable ddserver.service
sudo systemctl daemon-reload
sudo systemctl enable ddserver.service
sudo systemctl start ddserver.service
fi
if [[ ${mobindi} == "TRUE" ]]
then
${dirinstall}/install_mobindi.sh
fi