mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
MQTT rework v0.4, install scripts rework, Traefik docs 📦
This commit is contained in:
@@ -1,33 +1,115 @@
|
||||
#!/bin/sh
|
||||
/home/pi/pialert/dockerfiles/user-mapping.sh
|
||||
#!/bin/bash
|
||||
|
||||
echo "---------------------------------------------------------"
|
||||
echo "[INSTALL] Run start.sh"
|
||||
echo "---------------------------------------------------------"
|
||||
|
||||
|
||||
INSTALL_DIR=/home/pi # Specify the installation directory here
|
||||
|
||||
# # if custom variables not set we do not need to do anything
|
||||
# if [ -n "${TZ}" ]; then
|
||||
# FILECONF=/home/pi/pialert/config/pialert.conf
|
||||
# FILECONF=$INSTALL_DIR/pialert/config/pialert.conf
|
||||
# if [ -f "$FILECONF" ]; then
|
||||
# sed -ie "s|Europe/Berlin|${TZ}|g" /home/pi/pialert/config/pialert.conf
|
||||
# sed -ie "s|Europe/Berlin|${TZ}|g" $INSTALL_DIR/pialert/config/pialert.conf
|
||||
# else
|
||||
# sed -ie "s|Europe/Berlin|${TZ}|g" /home/pi/pialert/back/pialert.conf_bak
|
||||
# sed -ie "s|Europe/Berlin|${TZ}|g" $INSTALL_DIR/pialert/back/pialert.conf_bak
|
||||
# fi
|
||||
# fi
|
||||
|
||||
# Check if script is run as root
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
echo "This script must be run as root. Please use 'sudo'."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Run setup scripts
|
||||
echo "[INSTALL] Run setup scripts"
|
||||
|
||||
"$INSTALL_DIR/pialert/dockerfiles/user-mapping.sh"
|
||||
"$INSTALL_DIR/pialert/install/install_dependencies.sh"
|
||||
"$INSTALL_DIR/pialert/install/install_python.sh"
|
||||
|
||||
# Chaneg port number if set
|
||||
if [ -n "${PORT}" ]; then
|
||||
sed -ie 's/listen 20211/listen '${PORT}'/g' /etc/nginx/sites-available/default
|
||||
fi
|
||||
|
||||
# I hope this will fix DB permission issues going forward
|
||||
FILEDB=/home/pi/pialert/db/pialert.db
|
||||
if [ -f "$FILEDB" ]; then
|
||||
chown -R www-data:www-data /home/pi/pialert/db/pialert.db
|
||||
echo "[INSTALL] Setup NGINX"
|
||||
|
||||
# Remove /html folder if exists
|
||||
sudo rm -R /var/www/html
|
||||
|
||||
# create symbolic link to the pialert install directory
|
||||
ln -s $INSTALL_DIR/pialert/front /var/www/html
|
||||
# remove dfault NGINX site
|
||||
sudo rm /etc/nginx/sites-available/default
|
||||
# create symbolic link to NGINX configuaration coming with PiAlert
|
||||
sudo ln -s "$INSTALL_DIR/pialert/install/default" /etc/nginx/sites-available/default
|
||||
# use user-supplied port
|
||||
sudo sed -i 's/listen 80/listen '"$PORT"'/g' /etc/nginx/sites-available/default
|
||||
|
||||
|
||||
# Run the hardware vendors update at least once
|
||||
echo "[INSTALL] Run the hardware vendors update"
|
||||
|
||||
# Define the path to ieee-oui.txt and ieee-iab.txt
|
||||
oui_file="/usr/share/arp-scan/ieee-oui.txt"
|
||||
|
||||
# Check if ieee-oui.txt or ieee-iab.txt exist
|
||||
if [ -f "$oui_file" ]; then
|
||||
echo "The file ieee-oui.txt exists. Skipping update_vendors.sh..."
|
||||
else
|
||||
echo "The file ieee-oui.txt does not exist. Running update_vendors..."
|
||||
|
||||
# Run the update_vendors.sh script
|
||||
if [ -f "$INSTALL_DIR/pialert/back/update_vendors.sh" ]; then
|
||||
"$INSTALL_DIR/pialert/back/update_vendors.sh"
|
||||
else
|
||||
echo "update_vendors.sh script not found in $INSTALL_DIR."
|
||||
fi
|
||||
fi
|
||||
|
||||
chmod -R a+rw /home/pi/pialert/front/log
|
||||
chmod -R a+rw /home/pi/pialert/config
|
||||
# Fixing file permissions
|
||||
echo "[INSTALL] Fixing file permissions"
|
||||
|
||||
/etc/init.d/php7.4-fpm start
|
||||
chmod -R a+rwx $INSTALL_DIR
|
||||
chmod -R a+rwx /var/www/html
|
||||
chmod -R a+rw $INSTALL_DIR/pialert/front/log
|
||||
chmod -R a+rw $INSTALL_DIR/pialert/config
|
||||
|
||||
FILEDB=$INSTALL_DIR/pialert/db/pialert.db
|
||||
|
||||
if [ -f "$FILEDB" ]; then
|
||||
chown -R www-data:www-data $INSTALL_DIR/pialert/db/pialert.db
|
||||
fi
|
||||
|
||||
|
||||
echo "[INSTALL] Create pialert.db and pialert.conf backups"
|
||||
|
||||
# Create a backup of pialert.conf
|
||||
cp "$INSTALL_DIR/pialert/config/pialert.conf" "$INSTALL_DIR/pialert/back/pialert.conf_bak"
|
||||
|
||||
# Create a backup of pialert.db
|
||||
cp "$INSTALL_DIR/pialert/db/pialert.db" "$INSTALL_DIR/pialert/back/pialert.db_bak"
|
||||
|
||||
# Create buildtimestamp.txt
|
||||
date +%s > "$INSTALL_DIR/pialert/front/buildtimestamp.txt"
|
||||
|
||||
|
||||
# start PHP
|
||||
/etc/init.d/php8.2-fpm start
|
||||
/etc/init.d/nginx start
|
||||
|
||||
# cron -f
|
||||
#python /home/pi/pialert/back/pialert.py
|
||||
# echo "[DEBUG] DATA MONKEY VERSION ..."
|
||||
python /home/pi/pialert/pialert/
|
||||
# Start Nginx and your application to start at boot (if needed)
|
||||
systemctl start nginx
|
||||
systemctl enable nginx
|
||||
|
||||
# systemctl enable pi-alert
|
||||
sudo systemctl restart nginx
|
||||
|
||||
# Activate the virtual python environment
|
||||
source myenv/bin/activate
|
||||
|
||||
# Start the PiAlert python script
|
||||
python $INSTALL_DIR/pialert/pialert/
|
||||
|
||||
Reference in New Issue
Block a user