-
-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MQTT rework v0.4, install scripts rework, Traefik docs 📦
- Loading branch information
Showing
22 changed files
with
50,460 additions
and
203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
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 | ||
|
||
# Fixing file permissions | ||
echo "[INSTALL] Fixing file permissions" | ||
|
||
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 /home/pi/pialert/db/pialert.db | ||
chown -R www-data:www-data $INSTALL_DIR/pialert/db/pialert.db | ||
fi | ||
|
||
chmod -R a+rw /home/pi/pialert/front/log | ||
chmod -R a+rw /home/pi/pialert/config | ||
|
||
/etc/init.d/php7.4-fpm start | ||
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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Oops, something went wrong.