mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
Merge branch 'main' of https://github.com/jokob-sk/NetAlertX
This commit is contained in:
7
install/install.debian.sh → install/debian12/install.debian12.sh
Executable file → Normal file
7
install/install.debian.sh → install/debian12/install.debian12.sh
Executable file → Normal file
@@ -1,10 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# 🛑 Important: This is only used for the bare-metal install 🛑
|
||||
# Update /install/start.debian.sh in most cases is preferred
|
||||
# Update /install/start.debian12.sh in most cases is preferred
|
||||
|
||||
echo "---------------------------------------------------------"
|
||||
echo "[INSTALL] Run install.debian.sh"
|
||||
echo "[INSTALL] Run install.debian12.sh"
|
||||
echo "---------------------------------------------------------"
|
||||
|
||||
# Set environment variables
|
||||
@@ -35,4 +35,5 @@ if [ ! -f $INSTALL_DIR/front/buildtimestamp.txt ]; then
|
||||
fi
|
||||
|
||||
# Start NetAlertX
|
||||
"$INSTALL_DIR/install/start.debian.sh"
|
||||
chmod +x "$INSTALL_DIR/install/debian12/start.debian12.sh"
|
||||
"$INSTALL_DIR/install/debian12/start.debian12.sh"
|
||||
5
install/install_dependencies.debian.sh → install/debian12/install_dependencies.debian12.sh
Executable file → Normal file
5
install/install_dependencies.debian.sh → install/debian12/install_dependencies.debian12.sh
Executable file → Normal file
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
echo "---------------------------------------------------------"
|
||||
echo "[INSTALL] Run install_dependencies.debian.sh"
|
||||
echo "[INSTALL] Run install_dependencies.debian12.sh"
|
||||
echo "---------------------------------------------------------"
|
||||
|
||||
# ❗ IMPORTANT - if you modify this file modify the root Dockerfile as well ❗
|
||||
@@ -23,7 +23,7 @@ sudo apt-get install nginx nginx-core mtr php-fpm php8.2-fpm php-cli php8.2 php8
|
||||
sudo phpenmod -v 8.2 sqlite3
|
||||
|
||||
# setup virtual python environment so we can use pip3 to install packages
|
||||
apt-get install python3.11-venv -y
|
||||
apt-get install python3-venv -y
|
||||
python3 -m venv myenv
|
||||
source myenv/bin/activate
|
||||
|
||||
@@ -31,4 +31,3 @@ update-alternatives --install /usr/bin/python python /usr/bin/python3 10
|
||||
|
||||
# install packages thru pip3
|
||||
pip3 install openwrt-luci-rpc asusrouter asyncio aiohttp graphene flask flask-cors unifi-sm-api tplink-omada-client wakeonlan pycryptodome requests paho-mqtt scapy cron-converter pytz json2table dhcp-leases pyunifi speedtest-cli chardet python-nmap dnspython librouteros yattag git+https://github.com/foreign-sub/aiofreepybox.git
|
||||
|
||||
6
install/netalertx.debian.conf → install/debian12/netalertx.conf
Executable file → Normal file
6
install/netalertx.debian.conf → install/debian12/netalertx.conf
Executable file → Normal file
@@ -14,7 +14,7 @@ server {
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
|
||||
fastcgi_connect_timeout 75;
|
||||
fastcgi_send_timeout 600;
|
||||
fastcgi_read_timeout 600;
|
||||
}
|
||||
fastcgi_send_timeout 600;
|
||||
fastcgi_read_timeout 600;
|
||||
}
|
||||
}
|
||||
44
install/start.debian.sh → install/debian12/start.debian12.sh
Executable file → Normal file
44
install/start.debian.sh → install/debian12/start.debian12.sh
Executable file → Normal file
@@ -1,16 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
echo "---------------------------------------------------------"
|
||||
echo "[INSTALL] Run start.debian.sh"
|
||||
echo "[INSTALL] Run start.debian12.sh"
|
||||
echo "---------------------------------------------------------"
|
||||
|
||||
echo
|
||||
echo "This script will set up and start NetAlertX on your Debian12 system."
|
||||
|
||||
INSTALL_DIR=/app # Specify the installation directory here
|
||||
|
||||
# DO NOT CHANGE ANYTHING BELOW THIS LINE!
|
||||
INSTALLER_DIR=$INSTALL_DIR/install/debian12
|
||||
CONF_FILE=app.conf
|
||||
DB_FILE=app.db
|
||||
NGINX_CONF_FILE=netalertx.debian.conf
|
||||
NGINX_CONF_FILE=netalertx.conf
|
||||
WEB_UI_DIR=/var/www/html/netalertx
|
||||
NGINX_CONFIG_FILE=/etc/nginx/conf.d/$NGINX_CONF_FILE
|
||||
OUI_FILE="/usr/share/arp-scan/ieee-oui.txt" # Define the path to ieee-oui.txt and ieee-iab.txt
|
||||
@@ -34,12 +36,26 @@ if [[ $EUID -ne 0 ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Run setup scripts
|
||||
echo "[INSTALL] Run setup scripts"
|
||||
|
||||
"${INSTALL_PATH}/install/install_dependencies.debian.sh" # if modifying this file transfer the changes into the root Dockerfile.debian as well!
|
||||
|
||||
echo "[INSTALL] Setup NGINX"
|
||||
echo "---------------------------------------------------------"
|
||||
echo "[INSTALL] Installing dependencies"
|
||||
echo "---------------------------------------------------------"
|
||||
echo
|
||||
|
||||
|
||||
"${INSTALLER_DIR}/install_dependencies.debian12.sh" # if modifying this file transfer the changes into the root Dockerfile.debian as well!
|
||||
|
||||
|
||||
echo "---------------------------------------------------------"
|
||||
echo "[INSTALL] Installing NGINX and setting up the web server"
|
||||
echo "---------------------------------------------------------"
|
||||
echo
|
||||
echo "[INSTALL] Stopping any NGINX web server"
|
||||
|
||||
service nginx stop 2>/dev/null
|
||||
pkill -f "python ${INSTALL_DIR}/server" 2>/dev/null
|
||||
echo "[INSTALL] Updating the existing installation..."
|
||||
|
||||
# Remove default NGINX site if it is symlinked, or backup it otherwise
|
||||
if [ -L /etc/nginx/sites-enabled/default ] ; then
|
||||
@@ -52,19 +68,17 @@ fi
|
||||
|
||||
# Clear existing directories and files
|
||||
if [ -d $WEB_UI_DIR ]; then
|
||||
echo "Removing existing NetAlertX web-UI"
|
||||
sudo rm -R $WEB_UI_DIR
|
||||
echo "[INSTALL] Removing existing NetAlertX web-UI"
|
||||
rm -R $WEB_UI_DIR
|
||||
fi
|
||||
|
||||
if [ -f $NGINX_CONFIG_FILE ]; then
|
||||
echo "Removing existing NetAlertX NGINX config"
|
||||
sudo rm $NGINX_CONFIG_FILE
|
||||
fi
|
||||
echo "[INSTALL] Removing existing NetAlertX NGINX config"
|
||||
rm "$NGINX_CONFIG_FILE" 2>/dev/null || true
|
||||
|
||||
# create symbolic link to the install directory
|
||||
ln -s $INSTALL_PATH/front $WEB_UI_DIR
|
||||
# create symbolic link to NGINX configuration coming with NetAlertX
|
||||
sudo ln -s "${INSTALL_PATH}/install/netalertx.debian.conf" /etc/nginx/conf.d/$NGINX_CONF_FILE
|
||||
sudo ln -s "${INSTALL_PATH}/install/debian12/netalertx.conf" /etc/nginx/conf.d/$NGINX_CONF_FILE
|
||||
|
||||
# Use user-supplied port if set
|
||||
if [ -n "${PORT}" ]; then
|
||||
@@ -108,7 +122,6 @@ echo "[INSTALL] Fixing file permissions"
|
||||
chown root:www-data "${INSTALL_DIR}"/api/user_notifications.json
|
||||
|
||||
echo "[INSTALL] Fixing WEB_UI_DIR: ${WEB_UI_DIR}"
|
||||
|
||||
chmod -R a+rwx $WEB_UI_DIR
|
||||
|
||||
echo "[INSTALL] Fixing INSTALL_DIR: ${INSTALL_DIR}"
|
||||
@@ -151,6 +164,7 @@ fi
|
||||
|
||||
# start PHP
|
||||
/etc/init.d/php8.2-fpm start
|
||||
nginx -t || { echo "[INSTALL] nginx config test failed"; exit 1; }
|
||||
/etc/init.d/nginx start
|
||||
|
||||
# Start Nginx and your application to start at boot (if needed)
|
||||
@@ -14,6 +14,7 @@ echo "---------------------------------------------------------"
|
||||
|
||||
# Set environment variables
|
||||
INSTALL_DIR=/app # Specify the installation directory here
|
||||
INSTALLER_DIR=$INSTALL_DIR/install/ubuntu24
|
||||
|
||||
# Check if script is run as root
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
@@ -36,10 +37,12 @@ apt-get install -y git
|
||||
if [ -d "$INSTALL_DIR" ]; then
|
||||
echo "The installation directory exists. Removing it to ensure a clean install."
|
||||
echo "Are you sure you want to continue? This will delete all existing files in $INSTALL_DIR."
|
||||
echo "This will include ALL YOUR SETTINGS AND DATABASE! (if there are any)"
|
||||
echo
|
||||
echo "Type:"
|
||||
echo " - 'install' to continue"
|
||||
echo " - 'update' to just update from GIT"
|
||||
echo " - 'start' to do nothing, leave install as-is"
|
||||
echo " - 'install' to continue and DELETE ALL!"
|
||||
echo " - 'update' to just update from GIT (keeps your db and settings)"
|
||||
echo " - 'start' to do nothing, leave install as-is (just run the start script)"
|
||||
if [ "$1" == "install" ] || [ "$1" == "update" ] || [ "$1" == "start" ]; then
|
||||
confirmation=$1
|
||||
else
|
||||
@@ -52,9 +55,9 @@ if [ -d "$INSTALL_DIR" ]; then
|
||||
|
||||
# Stop nginx if running
|
||||
if command -v systemctl >/dev/null 2>&1 && systemctl list-units --type=service | grep -q nginx; then
|
||||
systemctl stop nginx 2>/dev/null
|
||||
systemctl stop nginx 2>/dev/null
|
||||
elif command -v service >/dev/null 2>&1; then
|
||||
service nginx stop 2>/dev/null
|
||||
service nginx stop 2>/dev/null
|
||||
fi
|
||||
|
||||
# Kill running NetAlertX server processes in this INSTALL_DIR
|
||||
@@ -73,14 +76,10 @@ if [ -d "$INSTALL_DIR" ]; then
|
||||
echo "INSTALL_DIR is not set, is root, or is invalid. Aborting for safety."
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "INSTALL_DIR is not set or is root. Aborting for safety."
|
||||
exit 1
|
||||
fi
|
||||
elif [ "$confirmation" == "update" ]; then
|
||||
echo "Updating the existing installation..."
|
||||
service nginx stop 2>/dev/null
|
||||
pkill -f "python ${INSTALL_DIR}/server" 2>/dev/null
|
||||
pkill -f "python ${INSTALL_DIR}/server" 2>/dev/null
|
||||
cd "$INSTALL_DIR" || { echo "Failed to change directory to $INSTALL_DIR"; exit 1; }
|
||||
git pull
|
||||
elif [ "$confirmation" == "start" ]; then
|
||||
@@ -101,5 +100,6 @@ fi
|
||||
# Start NetAlertX
|
||||
|
||||
# This is where we setup the virtual environment and install dependencies
|
||||
cd "$INSTALL_DIR/install/ubuntu" || { echo "Failed to change directory to $INSTALL_DIR/install/ubuntu"; exit 1; }
|
||||
"$INSTALL_DIR/install/ubuntu/start.ubuntu.sh"
|
||||
cd "$INSTALLER_DIR" || { echo "Failed to change directory to $INSTALLER_DIR"; exit 1; }
|
||||
chmod +x "$INSTALLER_DIR/start.ubuntu24.sh"
|
||||
"$INSTALLER_DIR/start.ubuntu24.sh"
|
||||
@@ -4,15 +4,16 @@ echo "---------------------------------------------------------"
|
||||
echo "[INSTALL]"
|
||||
echo "---------------------------------------------------------"
|
||||
echo
|
||||
echo "This script will set up and start NetAlertX on your Ubuntu system."
|
||||
echo "This script will set up and start NetAlertX on your Ubuntu24 system."
|
||||
|
||||
# Specify the installation directory here
|
||||
INSTALL_DIR=/app
|
||||
|
||||
# DO NOT CHANGE ANYTHING BELOW THIS LINE!
|
||||
INSTALLER_DIR=$INSTALL_DIR/install/ubuntu24
|
||||
CONF_FILE=app.conf
|
||||
DB_FILE=app.db
|
||||
NGINX_CONF_FILE=netalertx.ubuntu.conf
|
||||
NGINX_CONF_FILE=netalertx.conf
|
||||
WEB_UI_DIR=/var/www/html/netalertx
|
||||
NGINX_CONFIG_FILE=/etc/nginx/conf.d/$NGINX_CONF_FILE
|
||||
OUI_FILE="/usr/share/arp-scan/ieee-oui.txt" # Define the path to ieee-oui.txt and ieee-iab.txt
|
||||
@@ -58,7 +59,7 @@ phpenmod -v ${PHPVERSION} sqlite3
|
||||
|
||||
update-alternatives --install /usr/bin/python python /usr/bin/python3 10
|
||||
|
||||
cd $INSTALL_DIR/install/ubuntu || { echo "Failed to change directory to $INSTALL_DIR/install/ubuntu"; exit 1; }
|
||||
cd $INSTALLER_DIR || { echo "Failed to change directory to $INSTALLER_DIR"; exit 1; }
|
||||
|
||||
# setup virtual python environment so we can use pip3 to install packages
|
||||
apt-get install python3-venv -y
|
||||
@@ -102,7 +103,7 @@ rm "$NGINX_CONFIG_FILE" 2>/dev/null || true
|
||||
# create symbolic link to the install directory
|
||||
ln -s $INSTALL_PATH/front $WEB_UI_DIR
|
||||
# create symbolic link to NGINX configuration coming with NetAlertX
|
||||
ln -s "${INSTALL_PATH}/install/ubuntu/$NGINX_CONF_FILE" $NGINX_CONFIG_FILE
|
||||
ln -s "${INSTALLER_DIR}/$NGINX_CONF_FILE" $NGINX_CONFIG_FILE
|
||||
|
||||
# Use user-supplied port if set
|
||||
if [ -n "${PORT}" ]; then
|
||||
@@ -137,22 +138,31 @@ else
|
||||
fi
|
||||
fi
|
||||
|
||||
# create log and api mounts
|
||||
|
||||
echo "---------------------------------------------------------"
|
||||
echo "[INSTALL] Create log and api mounts"
|
||||
mkdir -p "${INSTALL_DIR}/log" "${INSTALL_DIR}/api"
|
||||
umount "${INSTALL_DIR}/log" 2>/dev/null || true
|
||||
umount "${INSTALL_DIR}/api" 2>/dev/null || true
|
||||
mount -t tmpfs -o size=32m,noexec,nosuid,nodev tmpfs "${INSTALL_DIR}/log"
|
||||
mount -t tmpfs -o size=16m,noexec,nosuid,nodev tmpfs "${INSTALL_DIR}/api"
|
||||
# Create an empty log files
|
||||
echo "---------------------------------------------------------"
|
||||
echo
|
||||
|
||||
# Create the execution_queue.log file if it doesn't exist
|
||||
echo "[INSTALL] Cleaning up old mounts if any"
|
||||
umount "${INSTALL_DIR}/log"
|
||||
umount "${INSTALL_DIR}/api"
|
||||
|
||||
echo "[INSTALL] Creating log and api folders if they don't exist"
|
||||
mkdir -p "${INSTALL_DIR}/log" "${INSTALL_DIR}/api"
|
||||
|
||||
echo "[INSTALL] Mounting log and api folders as tmpfs"
|
||||
mount -t tmpfs -o noexec,nosuid,nodev tmpfs "${INSTALL_DIR}/log"
|
||||
mount -t tmpfs -o noexec,nosuid,nodev tmpfs "${INSTALL_DIR}/api"
|
||||
|
||||
|
||||
# Create log files if they don't exist
|
||||
echo "[INSTALL] Creating log files if they don't exist"
|
||||
touch "${INSTALL_DIR}"/log/{app.log,execution_queue.log,app_front.log,app.php_errors.log,stderr.log,stdout.log,db_is_locked.log}
|
||||
touch "${INSTALL_DIR}"/api/user_notifications.json
|
||||
# Create plugins sub-directory if it doesn't exist in case a custom log folder is used
|
||||
mkdir -p "${INSTALL_DIR}"/log/plugins
|
||||
|
||||
|
||||
# Fixing file permissions
|
||||
echo "[INSTALL] Fixing file permissions"
|
||||
chown root:www-data "${INSTALL_DIR}"/api/user_notifications.json
|
||||
Reference in New Issue
Block a user