1
- #! /bin/bash
1
+ #! /usr/ bin/env bash
2
2
3
3
echo " ---------------------------------------------------------"
4
4
echo " [INSTALL] Run start.sh"
@@ -7,6 +7,12 @@ echo "---------------------------------------------------------"
7
7
8
8
INSTALL_DIR=/home/pi # Specify the installation directory here
9
9
10
+ # DO NOT CHANGE ANYTHING BELOW THIS LINE!
11
+ WEB_UI_DIR=/var/www/html/pialert
12
+ NGINX_CONFIG_FILE=/etc/nginx/conf.d/pialert.conf
13
+ OUI_FILE=" /usr/share/arp-scan/ieee-oui.txt" # Define the path to ieee-oui.txt and ieee-iab.txt
14
+ # DO NOT CHANGE ANYTHING ABOVE THIS LINE!
15
+
10
16
# if custom variables not set we do not need to do anything
11
17
if [ -n " ${TZ} " ]; then
12
18
FILECONF=$INSTALL_DIR /pialert/config/pialert.conf
@@ -29,38 +35,50 @@ echo "[INSTALL] Run setup scripts"
29
35
" $INSTALL_DIR /pialert/dockerfiles/user-mapping.sh"
30
36
" $INSTALL_DIR /pialert/install/install_dependencies.sh" # if modifying this file transfer the chanegs into the root Dockerfile as well!
31
37
32
- # Change port number if set
33
- if [ -n " ${PORT} " ]; then
34
- sed -ie ' s/listen 20211/listen ' ${PORT} ' /g' /etc/nginx/sites-available/default
35
- fi
36
-
37
38
echo " [INSTALL] Setup NGINX"
38
39
39
- # Remove /html folder if exists
40
- sudo rm -R /var/www/html
40
+ # Remove default NGINX site if it is symlinked, or backup it otherwise
41
+ if [ -L /etc/nginx/sites-enabled/default ] ; then
42
+ echo " Disabling default NGINX site, removing sym-link in /etc/nginx/sites-enabled"
43
+ sudo rm /etc/nginx/sites-enabled/default
44
+ elif [ -f /etc/nginx/sites-enabled/default ]; then
45
+ echo " Disabling default NGINX site, moving config to /etc/nginx/sites-available"
46
+ sudo mv /etc/nginx/sites-enabled/default /etc/nginx/sites-available/default.bkp_pialert
47
+ fi
48
+
49
+ # Clear existing directories and files
50
+ if [ -d $WEB_UI_DIR ]; then
51
+ echo " Removing existing PiAlert web-UI"
52
+ sudo rm -R $WEB_UI_DIR
53
+ fi
54
+
55
+ if [ -f $NGINX_CONFIG_FILE ]; then
56
+ echo " Removing existing PiAlert NGINX config"
57
+ sudo rm $NGINX_CONFIG_FILE
58
+ fi
41
59
42
60
# create symbolic link to the pialert install directory
43
- ln -s $INSTALL_DIR /pialert/front /var/www/html
44
- # remove dfault NGINX site
45
- sudo rm /etc/nginx/sites-available/default
61
+ ln -s $INSTALL_DIR /pialert/front $WEB_UI_DIR
46
62
# create symbolic link to NGINX configuaration coming with PiAlert
47
- sudo ln -s " $INSTALL_DIR /pialert/install/default" /etc/nginx/sites-available/default
48
- # use user-supplied port
49
- sudo sed -i ' s/listen 80/listen ' " $PORT " ' /g' /etc/nginx/sites-available/default
63
+ sudo ln -s " $INSTALL_DIR /pialert/install/pialert.conf" /etc/nginx/conf.d/pialert.conf
64
+
65
+ # Use user-supplied port if set
66
+ if [ -n " ${PORT} " ]; then
67
+ echo " Setting webserver to user-supplied port ($PORT )"
68
+ sudo sed -i ' s/listen 20211/listen ' " $PORT " ' /g' /etc/nginx/conf.d/pialert.conf
69
+ fi
50
70
51
71
# Change web interface address if set
52
- if [ -n " ${LISTEN_ADDR} " ]; then
53
- sed -ie ' s/listen /listen ' ${LISTEN_ADDR} :' /g' /etc/nginx/sites-available/default
72
+ if [ -n " ${LISTEN_ADDR} " ]; then
73
+ echo " Setting webserver to user-supplied address ($LISTEN_ADDR )"
74
+ sed -ie ' s/listen /listen ' " ${LISTEN_ADDR} " :' /g' /etc/nginx/conf.d/pialert.conf
54
75
fi
55
76
56
77
# Run the hardware vendors update at least once
57
78
echo " [INSTALL] Run the hardware vendors update"
58
79
59
- # Define the path to ieee-oui.txt and ieee-iab.txt
60
- oui_file=" /usr/share/arp-scan/ieee-oui.txt"
61
-
62
80
# Check if ieee-oui.txt or ieee-iab.txt exist
63
- if [ -f " $oui_file " ]; then
81
+ if [ -f " $OUI_FILE " ]; then
64
82
echo " The file ieee-oui.txt exists. Skipping update_vendors.sh..."
65
83
else
66
84
echo " The file ieee-oui.txt does not exist. Running update_vendors..."
77
95
echo " [INSTALL] Fixing file permissions"
78
96
79
97
80
- chmod -R a+rwx /var/www/html
98
+ chmod -R a+rwx $WEB_UI_DIR
81
99
chmod -R a+rw $INSTALL_DIR /pialert/front/log
82
100
chmod -R a+rwx $INSTALL_DIR
83
101
0 commit comments