diff --git a/.dockerignore b/.dockerignore index b9ddb743..1d55a42b 100755 --- a/.dockerignore +++ b/.dockerignore @@ -16,5 +16,4 @@ CONTRIBUTING FUNDING.yml config/.gitignore db/.gitignore -pialert/README.md -pialert/README_ES.md + diff --git a/.github/ISSUE_TEMPLATE/i-have-an-issue.yml b/.github/ISSUE_TEMPLATE/i-have-an-issue.yml index f5aedbf0..b50ae9b3 100755 --- a/.github/ISSUE_TEMPLATE/i-have-an-issue.yml +++ b/.github/ISSUE_TEMPLATE/i-have-an-issue.yml @@ -34,9 +34,9 @@ body: required: false - type: textarea attributes: - label: pialert.conf + label: app.conf description: | - Paste your `pialert.conf` (remove personal info) + Paste your `app.conf` (remove personal info) render: python validations: required: false @@ -58,13 +58,13 @@ body: required: true - type: textarea attributes: - label: pialert.log + label: app.log description: | Logs with debug enabled (https://github.com/jokob-sk/NetAlertX/blob/main/docs/DEBUG_TIPS.md) ⚠ ***Generally speaking, all bug reports should have logs provided.*** Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in. Additionally, any additional info? Screenshots? References? Anything that will give us more context about the issue you are encountering! - You can use `tail -100 /home/pi/pialert/front/log/pialert.log` in teh container if you have troubles getting to the log files. + You can use `tail -100 /app/front/log/app.log` in the container if you have troubles getting to the log files. validations: required: false - type: checkboxes diff --git a/.github/workflows/docker_cache-cleaner.yml b/.github/workflows/docker_cache-cleaner.yml index 8d7f61e7..43573815 100755 --- a/.github/workflows/docker_cache-cleaner.yml +++ b/.github/workflows/docker_cache-cleaner.yml @@ -4,8 +4,8 @@ on: workflow_dispatch: # manual option - schedule: - - cron: '15 22 * * 1' # every Monday 10.15pm UTC (~11.15am Tuesday NZT) + # schedule: + # - cron: '15 22 * * 1' # every Monday 10.15pm UTC (~11.15am Tuesday NZT) jobs: diff --git a/.gitignore b/.gitignore index 4fe462ba..ff1ef480 100755 --- a/.gitignore +++ b/.gitignore @@ -2,8 +2,10 @@ .DS_Store config/* config/pialert.conf +config/app.conf db/* db/pialert.db +db/app.db front/log/* front/api/* **/plugins/**/*.log diff --git a/Dockerfile b/Dockerfile index 765c52f2..ab09a935 100755 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,7 @@ FROM alpine:3.19 as builder -ARG INSTALL_DIR=/home/pi +ARG INSTALL_DIR=/app + ENV PYTHONUNBUFFERED 1 RUN apk add --no-cache bash python3 \ @@ -9,7 +10,7 @@ RUN apk add --no-cache bash python3 \ # Enable venv ENV PATH="/opt/venv/bin:$PATH" -COPY . ${INSTALL_DIR}/pialert/ +COPY . ${INSTALL_DIR}/ RUN pip install requests paho-mqtt scapy cron-converter pytz json2table dhcp-leases pyunifi speedtest-cli chardet \ && bash -c "find ${INSTALL_DIR} -type d -exec chmod 750 {} \;" \ @@ -19,7 +20,7 @@ RUN pip install requests paho-mqtt scapy cron-converter pytz json2table dhcp-lea # second stage FROM alpine:3.19 as runner -ARG INSTALL_DIR=/home/pi +ARG INSTALL_DIR=/app COPY --from=builder /opt/venv /opt/venv @@ -40,12 +41,12 @@ RUN apk update --no-cache \ && apk add --no-cache sqlite php82 php82-fpm php82-cgi php82-curl php82-sqlite3 php82-session \ && apk add --no-cache python3 nginx \ && ln -s /usr/bin/awake /usr/bin/wakeonlan \ - && bash -c "install -d -m 750 -o nginx -g www-data ${INSTALL_DIR} ${INSTALL_DIR}/pialert" \ + && bash -c "install -d -m 750 -o nginx -g www-data ${INSTALL_DIR} ${INSTALL_DIR}" \ && rm -f /etc/nginx/http.d/default.conf -COPY --from=builder --chown=nginx:www-data ${INSTALL_DIR}/pialert/ ${INSTALL_DIR}/pialert/ +COPY --from=builder --chown=nginx:www-data ${INSTALL_DIR}/ ${INSTALL_DIR}/ -RUN ${INSTALL_DIR}/pialert/dockerfiles/pre-setup.sh +RUN ${INSTALL_DIR}/dockerfiles/pre-setup.sh HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=2 \ CMD curl -sf -o /dev/null ${LISTEN_ADDR}:${PORT}/api/app_state.json diff --git a/Dockerfile.debian b/Dockerfile.debian index 6b55d6fd..c2301beb 100755 --- a/Dockerfile.debian +++ b/Dockerfile.debian @@ -10,6 +10,7 @@ ENV USER=pi USER_ID=1000 USER_GID=1000 PORT=20211 RUN apt-get update RUN apt-get install sudo -y +ARG INSTALL_DIR=/app # create pi user and group # add root and www-data to pi group so they can r/w files and db @@ -23,7 +24,7 @@ RUN groupadd --gid "${USER_GID}" "${USER}" && \ usermod -a -G ${USER_GID} root && \ usermod -a -G ${USER_GID} www-data -COPY --chmod=775 --chown=${USER_ID}:${USER_GID} . /home/pi/pialert/ +COPY --chmod=775 --chown=${USER_ID}:${USER_GID} . ${INSTALL_DIR}/ # ❗ IMPORTANT - if you modify this file modify the /install/install_dependecies.debian.sh file as well ❗ @@ -43,8 +44,8 @@ RUN python3 -m venv myenv RUN /bin/bash -c "source myenv/bin/activate && update-alternatives --install /usr/bin/python python /usr/bin/python3 10 && pip3 install requests paho-mqtt scapy cron-converter pytz json2table dhcp-leases pyunifi speedtest-cli chardet" # Create a buildtimestamp.txt to later check if a new version was released -RUN date +%s > /home/pi/pialert/front/buildtimestamp.txt +RUN date +%s > ${INSTALL_DIR}/front/buildtimestamp.txt -CMD ["/home/pi/pialert/install/start.debian.sh"] +CMD ["${INSTALL_DIR}/install/start.debian.sh"] diff --git a/README.md b/README.md index 20b8ec83..ae3fca74 100755 --- a/README.md +++ b/README.md @@ -74,7 +74,9 @@ Get visibility of what's going on on your WIFI/LAN network. Schedule scans for d [![GitHub Sponsors](https://img.shields.io/github/sponsors/jokob-sk?style=social)](https://github.com/sponsors/jokob-sk) -Thank you to all the wonderful people who are sponsoring this project (=preventing my burnout🔥🤯): +Thank you to all the wonderful people who are sponsoring this project. + +> preventing my burnout😅 are: | All Sponsors | diff --git a/back/pialert.conf b/back/app.conf similarity index 100% rename from back/pialert.conf rename to back/app.conf diff --git a/back/pialert.db b/back/app.db similarity index 100% rename from back/pialert.db rename to back/app.db diff --git a/back/pialert-cli b/back/pialert-cli index d7d2b720..8a800688 100755 --- a/back/pialert-cli +++ b/back/pialert-cli @@ -1,7 +1,7 @@ #!/bin/bash SCRIPT=$(readlink -f $0) SCRIPTPATH=`dirname $SCRIPT` -CONFFILENAME="pialert.conf" +CONFFILENAME="app.conf" PIA_CONF_FILE=${SCRIPTPATH}'/../config/${CONFFILENAME}' case $1 in diff --git a/back/report_sample.html b/back/report_sample.html index a00981a8..44d8c159 100755 --- a/back/report_sample.html +++ b/back/report_sample.html @@ -13,7 +13,7 @@ diff --git a/back/report_template.html b/back/report_template.html index 8a78b5f9..0b29cdd6 100755 --- a/back/report_template.html +++ b/back/report_template.html @@ -22,7 +22,7 @@
- NetAlertX Report + Net Alertx
@@ -55,7 +55,7 @@ NetAlertX ()
©2020 Puche (2022+ - jokob-sk) | Built on: | Version: | + jokob-sk) | Built on: | Version: | Docs diff --git a/back/report_template_new_version.html b/back/report_template_new_version.html index 8576c3b9..40a4d3ab 100755 --- a/back/report_template_new_version.html +++ b/back/report_template_new_version.html @@ -22,7 +22,7 @@
- NetAlertX Report + Net Alertx
@@ -59,7 +59,7 @@ NetAlertX ()
©2020 Puche (2022+ - jokob-sk) | Built on: | Version: | + jokob-sk) | Built on: | Version: | Docs diff --git a/docker-compose.yml b/docker-compose.yml index 243c219c..9bbfde2c 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,12 +11,14 @@ services: network_mode: host # restart: unless-stopped volumes: - # - ${APP_DATA_LOCATION}/netalertx_dev/config:/home/pi/pialert/config + # - ${APP_DATA_LOCATION}/netalertx_dev/config:/app/config + # - ${APP_DATA_LOCATION}/netalertx/config:/app/config - ${APP_DATA_LOCATION}/netalertx/config:/home/pi/pialert/config - # - ${APP_DATA_LOCATION}/netalertx_dev/db:/home/pi/pialert/db - - ${APP_DATA_LOCATION}/netalertx/db:/home/pi/pialert/db + # - ${APP_DATA_LOCATION}/netalertx_dev/db:/app/db + # - ${APP_DATA_LOCATION}/netalertx/db:/app/db + - ${APP_DATA_LOCATION}/netalertx/db:/home/pi/pialert/db # (optional) useful for debugging if you have issues setting up the container - # - ${LOGS_LOCATION}:/home/pi/pialert/front/log + # - ${LOGS_LOCATION}:/app/front/log # --------------------------------------------------------------------------- # DELETE START anyone trying to use this file: comment out / delete BELOW lines, they are only for development purposes - ${APP_DATA_LOCATION}/netalertx/dhcp_samples/dhcp1.leases:/mnt/dhcp1.leases @@ -24,39 +26,40 @@ services: - ${APP_DATA_LOCATION}/netalertx/dhcp_samples/pihole_dhcp_full.leases:/etc/pihole/dhcp.leases - ${APP_DATA_LOCATION}/netalertx/dhcp_samples/pihole_dhcp_2.leases:/etc/pihole/dhcp2.leases - ${APP_DATA_LOCATION}/pihole/etc-pihole/pihole-FTL.db:/etc/pihole/pihole-FTL.db - - ${DEV_LOCATION}/netalertx:/home/pi/pialert/netalertx - - ${DEV_LOCATION}/dockerfiles:/home/pi/pialert/dockerfiles + - ${DEV_LOCATION}/server:/app/server + - ${DEV_LOCATION}/dockerfiles:/app/dockerfiles - ${APP_DATA_LOCATION}/netalertx/php.ini:/etc/php/8.2/fpm/php.ini - - ${DEV_LOCATION}/install:/home/pi/pialert/install - - ${DEV_LOCATION}/front/css:/home/pi/pialert/front/css - - ${DEV_LOCATION}/back/update_vendors.sh:/home/pi/pialert/back/update_vendors.sh - - ${DEV_LOCATION}/front/lib/AdminLTE:/home/pi/pialert/front/lib/AdminLTE - - ${DEV_LOCATION}/front/js:/home/pi/pialert/front/js - - ${DEV_LOCATION}/install/start.debian.sh:/home/pi/pialert/install/start.debian.sh - - ${DEV_LOCATION}/install/user-mapping.debian.sh:/home/pi/pialert/install/user-mapping.debian.sh - - ${DEV_LOCATION}/install/install.debian.sh:/home/pi/pialert/install/install.debian.sh - - ${DEV_LOCATION}/install/install_dependencies.debian.sh:/home/pi/pialert/install/install_dependencies.debian.sh - - ${DEV_LOCATION}/front/api:/home/pi/pialert/front/api - - ${DEV_LOCATION}/front/php:/home/pi/pialert/front/php - - ${DEV_LOCATION}/front/deviceDetails.php:/home/pi/pialert/front/deviceDetails.php - - ${DEV_LOCATION}/front/deviceDetailsTools.php:/home/pi/pialert/front/deviceDetailsTools.php - - ${DEV_LOCATION}/front/devices.php:/home/pi/pialert/front/devices.php - - ${DEV_LOCATION}/front/events.php:/home/pi/pialert/front/events.php - - ${DEV_LOCATION}/front/plugins.php:/home/pi/pialert/front/plugins.php - - ${DEV_LOCATION}/front/pluginsCore.php:/home/pi/pialert/front/pluginsCore.php - - ${DEV_LOCATION}/front/help_faq.php:/home/pi/pialert/front/help_faq.php - - ${DEV_LOCATION}/front/index.php:/home/pi/pialert/front/index.php - - ${DEV_LOCATION}/front/maintenance.php:/home/pi/pialert/front/maintenance.php - - ${DEV_LOCATION}/front/network.php:/home/pi/pialert/front/network.php - - ${DEV_LOCATION}/front/presence.php:/home/pi/pialert/front/presence.php - - ${DEV_LOCATION}/front/settings.php:/home/pi/pialert/front/settings.php - - ${DEV_LOCATION}/front/systeminfo.php:/home/pi/pialert/front/systeminfo.php - - ${DEV_LOCATION}/front/report.php:/home/pi/pialert/front/report.php - - ${DEV_LOCATION}/front/workflows.php:/home/pi/pialert/front/workflows.php - - ${DEV_LOCATION}/front/appEventsCore.php:/home/pi/pialert/front/appEventsCore.php - - ${DEV_LOCATION}/front/multiEditCore.php:/home/pi/pialert/front/multiEditCore.php - - ${DEV_LOCATION}/front/donations.php:/home/pi/pialert/front/donations.php - - ${DEV_LOCATION}/front/plugins:/home/pi/pialert/front/plugins + - ${DEV_LOCATION}/install:/app/install + - ${DEV_LOCATION}/front/css:/app/front/css + - ${DEV_LOCATION}/front/img:/app/front/img + - ${DEV_LOCATION}/back/update_vendors.sh:/app/back/update_vendors.sh + - ${DEV_LOCATION}/front/lib/AdminLTE:/app/front/lib/AdminLTE + - ${DEV_LOCATION}/front/js:/app/front/js + - ${DEV_LOCATION}/install/start.debian.sh:/app/install/start.debian.sh + - ${DEV_LOCATION}/install/user-mapping.debian.sh:/app/install/user-mapping.debian.sh + - ${DEV_LOCATION}/install/install.debian.sh:/app/install/install.debian.sh + - ${DEV_LOCATION}/install/install_dependencies.debian.sh:/app/install/install_dependencies.debian.sh + - ${DEV_LOCATION}/front/api:/app/front/api + - ${DEV_LOCATION}/front/php:/app/front/php + - ${DEV_LOCATION}/front/deviceDetails.php:/app/front/deviceDetails.php + - ${DEV_LOCATION}/front/deviceDetailsTools.php:/app/front/deviceDetailsTools.php + - ${DEV_LOCATION}/front/devices.php:/app/front/devices.php + - ${DEV_LOCATION}/front/events.php:/app/front/events.php + - ${DEV_LOCATION}/front/plugins.php:/app/front/plugins.php + - ${DEV_LOCATION}/front/pluginsCore.php:/app/front/pluginsCore.php + - ${DEV_LOCATION}/front/help_faq.php:/app/front/help_faq.php + - ${DEV_LOCATION}/front/index.php:/app/front/index.php + - ${DEV_LOCATION}/front/maintenance.php:/app/front/maintenance.php + - ${DEV_LOCATION}/front/network.php:/app/front/network.php + - ${DEV_LOCATION}/front/presence.php:/app/front/presence.php + - ${DEV_LOCATION}/front/settings.php:/app/front/settings.php + - ${DEV_LOCATION}/front/systeminfo.php:/app/front/systeminfo.php + - ${DEV_LOCATION}/front/report.php:/app/front/report.php + - ${DEV_LOCATION}/front/workflows.php:/app/front/workflows.php + - ${DEV_LOCATION}/front/appEventsCore.php:/app/front/appEventsCore.php + - ${DEV_LOCATION}/front/multiEditCore.php:/app/front/multiEditCore.php + - ${DEV_LOCATION}/front/donations.php:/app/front/donations.php + - ${DEV_LOCATION}/front/plugins:/app/front/plugins # DELETE END anyone trying to use this file: comment out / delete ABOVE lines, they are only for development purposes # --------------------------------------------------------------------------- environment: diff --git a/dockerfiles/README.md b/dockerfiles/README.md index aa2b5a95..7dc080b9 100755 --- a/dockerfiles/README.md +++ b/dockerfiles/README.md @@ -25,8 +25,8 @@ ```yaml docker run -d --rm --network=host \ - -v local/path/pialert/config:/home/pi/pialert/config \ - -v local/path/pialert/db:/home/pi/pialert/db \ + -v local/path/config:/app/config \ + -v local/path/db:/app/db \ -e TZ=Europe/Berlin \ -e PORT=20211 \ jokobsk/netalertx:latest @@ -49,22 +49,22 @@ docker run -d --rm --network=host \ | Required | Path | Description | | :------------- | :------------- | :-------------| -| ✅ | `:/home/pi/pialert/config` | Folder which will contain the `pialert.conf` & `devices.csv` ([read about devices.csv](https://github.com/jokob-sk/NetAlertX/blob/main/docs/DEVICES_BULK_EDITING.md)) files (see below for details). | -| ✅ | `:/home/pi/pialert/db` | Folder which will contain the `pialert.db` file | -| | `:/home/pi/pialert/front/log` | Logs folder useful for debugging if you have issues setting up the container | +| ✅ | `:/app/config` | Folder which will contain the `app.conf` & `devices.csv` ([read about devices.csv](https://github.com/jokob-sk/NetAlertX/blob/main/docs/DEVICES_BULK_EDITING.md)) files (see below for details). | +| ✅ | `:/app/db` | Folder which will contain the `app.db` file | +| | `:/app/front/log` | Logs folder useful for debugging if you have issues setting up the container | | | `:/etc/pihole/pihole-FTL.db` | PiHole's `pihole-FTL.db` database file. Required if you want to use PiHole DB mapping. | | | `:/etc/pihole/dhcp.leases` | PiHole's `dhcp.leases` file. Required if you want to use PiHole `dhcp.leases` file. This has to be matched with a corresponding `DHCPLSS_paths_to_check` setting entry (the path in the container must contain `pihole`)| -| | `:/home/pi/pialert/front/api` | A simple [API endpoint](https://github.com/jokob-sk/NetAlertX/blob/main/docs/API.md) containing static (but regularly updated) json and other files. | -| | `:/home/pi/pialert/front/plugins//ignore_plugin` | Map a file `ignore_plugin` to ignore a plugin. Plugins can be soft-disabled via settings. More in the [Plugin docs](https://github.com/jokob-sk/NetAlertX/blob/main/front/plugins/README.md). | +| | `:/app/front/api` | A simple [API endpoint](https://github.com/jokob-sk/NetAlertX/blob/main/docs/API.md) containing static (but regularly updated) json and other files. | +| | `:/app/front/plugins//ignore_plugin` | Map a file `ignore_plugin` to ignore a plugin. Plugins can be soft-disabled via settings. More in the [Plugin docs](https://github.com/jokob-sk/NetAlertX/blob/main/front/plugins/README.md). | | | `:/etc/resolv.conf` | Use a custom `resolv.conf` file for [better name resolution](https://github.com/jokob-sk/NetAlertX/blob/main/docs/REVERSE_DNS.md). | > Use separate `db` and `config` directories, don't nest them. -### (If UI is not available) Modify the config (`pialert.conf`) +### (If UI is not available) Modify the config (`app.conf`) - The preferred way is to manage the configuration via the Settings section in the UI. -- You can modify [pialert.conf](https://github.com/jokob-sk/NetAlertX/tree/main/config) directly, if needed. -- If unavailable, the app generates a default `pialert.conf` and `pialert.db` file on the first run. +- You can modify [app.conf](https://github.com/jokob-sk/NetAlertX/tree/main/config) directly, if needed. +- If unavailable, the app generates a default `app.conf` and `app.db` file on the first run. #### Important settings @@ -130,10 +130,10 @@ services: network_mode: "host" restart: unless-stopped volumes: - - local/path/pialert/config:/home/pi/pialert/config - - local/path/pialert/db:/home/pi/pialert/db + - local/path/config:/app/config + - local/path/db:/app/db # (optional) useful for debugging if you have issues setting up the container - - local/path/logs:/home/pi/pialert/front/log + - local/path/logs:/app/front/log environment: - TZ=Europe/Berlin - PORT=20211 @@ -157,8 +157,8 @@ Example by [SeimuS](https://github.com/SeimusS). - TZ=Europe/Bratislava restart: always volumes: - - ./pialert/pialert_db:/home/pi/pialert/db - - ./pialert/pialert_config:/home/pi/pialert/config + - ./netalertx/db:/app/db + - ./netalertx/config:/app/config network_mode: host ``` @@ -179,10 +179,10 @@ services: network_mode: "host" restart: unless-stopped volumes: - - ${APP_DATA_LOCATION}/netalertx/config:/home/pi/pialert/config - - ${APP_DATA_LOCATION}/netalertx/db/pialert.db:/home/pi/pialert/db/pialert.db + - ${APP_DATA_LOCATION}/netalertx/config:/app/config + - ${APP_DATA_LOCATION}/netalertx/db/:/app/db/ # (optional) useful for debugging if you have issues setting up the container - - ${LOGS_LOCATION}:/home/pi/pialert/front/log + - ${LOGS_LOCATION}:/app/front/log environment: - TZ=${TZ} - PORT=${PORT} @@ -211,7 +211,7 @@ To run the container execute: `sudo docker-compose --env-file /path/to/.env up` ### Example 4 -Courtesy of [pbek](https://github.com/pbek). The volume `pialert_db` is used by the db directory. The two config files are mounted directly from a local folder to their places in the config folder. You can backup the `docker-compose.yaml` folder and the docker volumes folder. +Courtesy of [pbek](https://github.com/pbek). The volume `netalertx_db` is used by the db directory. The two config files are mounted directly from a local folder to their places in the config folder. You can backup the `docker-compose.yaml` folder and the docker volumes folder. ```yaml netalertx: @@ -227,15 +227,15 @@ Courtesy of [pbek](https://github.com/pbek). The volume `pialert_db` is used by ipv4_address: 192.168.1.2 restart: unless-stopped volumes: - - pialert_db:/home/pi/pialert/db - - ./pialert/pialert.conf:/home/pi/pialert/config/pialert.conf + - netalertx_db:/app/db + - ./netalertx/:/app/config/ ``` ## 🏅 Recognitions -Big thanks to @Macleykun & for help and tips&tricks for Dockerfile(s) and @vladaurosh for Alpine re-base help. +Big thanks to @Macleykun & for help and tips & tricks for Dockerfile(s) and @vladaurosh for Alpine re-base help. -## ❤ Support me to prevent my burnout 🔥🤯 +## ❤ Support me | [![GitHub](https://i.imgur.com/emsRCPh.png)](https://github.com/sponsors/jokob-sk) | [![Buy Me A Coffee](https://i.imgur.com/pIM6YXL.png)](https://www.buymeacoffee.com/jokobsk) | [![Patreon](https://i.imgur.com/MuYsrq1.png)](https://www.patreon.com/user?u=84385063) | | --- | --- | --- | diff --git a/dockerfiles/pre-setup.sh b/dockerfiles/pre-setup.sh index 0f815dd8..1ab830c0 100755 --- a/dockerfiles/pre-setup.sh +++ b/dockerfiles/pre-setup.sh @@ -1,6 +1,7 @@ #!/bin/bash -export INSTALL_DIR=/home/pi +export INSTALL_DIR=/app +export APP_NAME=netalertx # php-fpm setup install -d -o nginx -g www-data /run/php/ @@ -13,12 +14,12 @@ sed -i "/^group/c\group = www-data" /etc/php82/php-fpm.d/www.conf # s6 overlay setup mkdir -p /etc/s6-overlay/s6-rc.d/{SetupOneshot,php-fpm/dependencies.d,nginx/dependencies.d} -mkdir -p /etc/s6-overlay/s6-rc.d/{SetupOneshot,php-fpm/dependencies.d,nginx/dependencies.d,pialert/dependencies.d} +mkdir -p /etc/s6-overlay/s6-rc.d/{SetupOneshot,php-fpm/dependencies.d,nginx/dependencies.d,$APP_NAME/dependencies.d} echo "oneshot" > /etc/s6-overlay/s6-rc.d/SetupOneshot/type echo "longrun" > /etc/s6-overlay/s6-rc.d/php-fpm/type echo "longrun" > /etc/s6-overlay/s6-rc.d/nginx/type -echo "longrun" > /etc/s6-overlay/s6-rc.d/pialert/type -echo -e "${INSTALL_DIR}/pialert/dockerfiles/setup.sh" > /etc/s6-overlay/s6-rc.d/SetupOneshot/up +echo "longrun" > /etc/s6-overlay/s6-rc.d/$APP_NAME/type +echo -e "${INSTALL_DIR}/dockerfiles/setup.sh" > /etc/s6-overlay/s6-rc.d/SetupOneshot/up echo -e "#!/bin/execlineb -P\n/usr/sbin/php-fpm82 -F" > /etc/s6-overlay/s6-rc.d/php-fpm/run echo -e '#!/bin/execlineb -P\nnginx -g "daemon off;"' > /etc/s6-overlay/s6-rc.d/nginx/run echo -e '#!/bin/execlineb -P @@ -30,11 +31,11 @@ echo -e '#!/bin/execlineb -P " [INSTALL] 🚀 Starting app (:${PORT}) - " }' > /etc/s6-overlay/s6-rc.d/pialert/run -echo -e "python ${INSTALL_DIR}/pialert/netalertx" >> /etc/s6-overlay/s6-rc.d/pialert/run + " }' > /etc/s6-overlay/s6-rc.d/$APP_NAME/run +echo -e "python ${INSTALL_DIR}/server" >> /etc/s6-overlay/s6-rc.d/server/run touch /etc/s6-overlay/s6-rc.d/user/contents.d/{SetupOneshot,php-fpm,nginx} /etc/s6-overlay/s6-rc.d/{php-fpm,nginx}/dependencies.d/SetupOneshot -touch /etc/s6-overlay/s6-rc.d/user/contents.d/{SetupOneshot,php-fpm,nginx,pialert} /etc/s6-overlay/s6-rc.d/{php-fpm,nginx,pialert}/dependencies.d/SetupOneshot +touch /etc/s6-overlay/s6-rc.d/user/contents.d/{SetupOneshot,php-fpm,nginx,$APP_NAME} /etc/s6-overlay/s6-rc.d/{php-fpm,nginx,$APP_NAME}/dependencies.d/SetupOneshot touch /etc/s6-overlay/s6-rc.d/nginx/dependencies.d/php-fpm -touch /etc/s6-overlay/s6-rc.d/pialert/dependencies.d/nginx +touch /etc/s6-overlay/s6-rc.d/$APP_NAME/dependencies.d/nginx rm -f $0 diff --git a/dockerfiles/setup.sh b/dockerfiles/setup.sh index c92ed48d..5e142ce8 100755 --- a/dockerfiles/setup.sh +++ b/dockerfiles/setup.sh @@ -4,14 +4,20 @@ echo "---------------------------------------------------------" echo "[INSTALL] Run setup.sh" echo "---------------------------------------------------------" -export INSTALL_DIR=/home/pi # Specify the installation directory here +export INSTALL_DIR=/app # Specify the installation directory here # DO NOT CHANGE ANYTHING BELOW THIS LINE! -CONFFILENAME="pialert.conf" -NGINX_CONFIG_FILE="/etc/nginx/http.d/${CONFFILENAME}" -DBFILENAME="pialert.db" + +CONF_FILE="app.conf" +NGINX_CONF_FILE=netalertx.conf +DB_FILE="app.db" + +NGINX_CONFIG_FILE="/etc/nginx/http.d/${NGINX_CONF_FILE}" + OUI_FILE="/usr/share/arp-scan/ieee-oui.txt" # Define the path to ieee-oui.txt and ieee-iab.txt -FILEDB="${INSTALL_DIR}/pialert/db/${DBFILENAME}" + + +FULL_FILEDB_PATH="${INSTALL_DIR}/db/${DB_FILE}" # DO NOT CHANGE ANYTHING ABOVE THIS LINE! @@ -21,25 +27,41 @@ if [[ $EUID -ne 0 ]]; then exit 1 fi -echo "[INSTALL] Copy starter ${DBFILENAME} and ${CONFFILENAME} if they don't exist" +echo "[INSTALL] Copy starter ${DB_FILE} and ${CONF_FILE} if they don't exist" # DANGER ZONE: ALWAYS_FRESH_INSTALL if [ "$ALWAYS_FRESH_INSTALL" = true ]; then echo "[INSTALL] ❗ ALERT /db and /config folders are cleared because the ALWAYS_FRESH_INSTALL is set to: $ALWAYS_FRESH_INSTALL❗" - # Delete content of "$INSTALL_DIR/pialert/config/" - rm -rf "$INSTALL_DIR/pialert/config/"* + # Delete content of "$INSTALL_DIR/config/" + rm -rf "$INSTALL_DIR/config/"* - # Delete content of "$INSTALL_DIR/pialert/db/" - rm -rf "$INSTALL_DIR/pialert/db/"* + # Delete content of "$INSTALL_DIR/db/" + rm -rf "$INSTALL_DIR/db/"* fi +# 🔻 FOR BACKWARD COMPATIBILITY - REMOVE AFTER 12/12/2024 +# Check if pialert.db exists, then copy to app.db +INSTALL_DIR_OLD=/home/pi/pialert +OLD_APP_NAME=pialert + +# Check if pialert.db exists, then create a symbolic link to app.db +if [ -f "${INSTALL_DIR_OLD}/db/${OLD_APP_NAME}.db" ]; then + ln -s "${INSTALL_DIR_OLD}/db/${OLD_APP_NAME}.db" "${FULL_FILEDB_PATH}" +fi + +# Check if ${OLD_APP_NAME}.conf exists, then create a symbolic link to app.conf +if [ -f "${INSTALL_DIR_OLD}/config/${OLD_APP_NAME}.conf" ]; then + ln -s "${INSTALL_DIR_OLD}/config/${OLD_APP_NAME}.conf" "${INSTALL_DIR}/config/${CONF_FILE}" +fi +# 🔺 FOR BACKWARD COMPATIBILITY - REMOVE AFTER 12/12/2024 + # Copy starter .db and .conf if they don't exist -cp -na "${INSTALL_DIR}/pialert/back/${CONFFILENAME}" "${INSTALL_DIR}/pialert/config/${CONFFILENAME}" -cp -na "${INSTALL_DIR}/pialert/back/${DBFILENAME}" "${FILEDB}" +cp -na "${INSTALL_DIR}/back/${CONF_FILE}" "${INSTALL_DIR}/config/${CONF_FILE}" +cp -na "${INSTALL_DIR}/back/${DB_FILE}" "${FULL_FILEDB_PATH}" # if custom variables not set we do not need to do anything if [ -n "${TZ}" ]; then - FILECONF="${INSTALL_DIR}/pialert/config/${CONFFILENAME}" + FILECONF="${INSTALL_DIR}/config/${CONF_FILE}" echo "[INSTALL] Setup timezone" sed -i "\#^TIMEZONE=#c\TIMEZONE='${TZ}'" "${FILECONF}" @@ -50,7 +72,7 @@ fi echo "[INSTALL] Setup NGINX" echo "Setting webserver to address ($LISTEN_ADDR) and port ($PORT)" -envsubst '$INSTALL_DIR $LISTEN_ADDR $PORT' < "${INSTALL_DIR}/pialert/install/netalertx.template.conf" > "${NGINX_CONFIG_FILE}" +envsubst '$INSTALL_DIR $LISTEN_ADDR $PORT' < "${INSTALL_DIR}/install/netalertx.template.conf" > "${NGINX_CONFIG_FILE}" # Run the hardware vendors update at least once echo "[INSTALL] Run the hardware vendors update" @@ -62,27 +84,27 @@ 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" + if [ -f "${INSTALL_DIR}/back/update_vendors.sh" ]; then + "${INSTALL_DIR}/back/update_vendors.sh" else echo "update_vendors.sh script not found in ${INSTALL_DIR}." fi fi # Create an empty log files -# Create the execution_queue.log and pialert_front.log files if they don't exist -touch "${INSTALL_DIR}"/pialert/front/log/{execution_queue.log,pialert_front.log,pialert.php_errors.log,stderr.log,stdout.log} +# Create the execution_queue.log and app_front.log files if they don't exist +touch "${INSTALL_DIR}"/front/log/{execution_queue.log,app_front.log,app.php_errors.log,stderr.log,stdout.log} echo "[INSTALL] Fixing permissions after copied starter config & DB" -chown -R nginx:www-data "${INSTALL_DIR}"/pialert/{config,front/log,db} -chmod 750 "${INSTALL_DIR}"/pialert/{config,front/log,db} -find "${INSTALL_DIR}"/pialert/{config,front/log,db} -type f -exec chmod 640 {} \; +chown -R nginx:www-data "${INSTALL_DIR}"/{config,front/log,db} +chmod 750 "${INSTALL_DIR}"/{config,front/log,db} +find "${INSTALL_DIR}"/{config,front/log,db} -type f -exec chmod 640 {} \; # Check if buildtimestamp.txt doesn't exist -if [ ! -f "${INSTALL_DIR}/pialert/front/buildtimestamp.txt" ]; then +if [ ! -f "${INSTALL_DIR}/front/buildtimestamp.txt" ]; then # Create buildtimestamp.txt - date +%s > "${INSTALL_DIR}/pialert/front/buildtimestamp.txt" - chown nginx:www-data "${INSTALL_DIR}/pialert/front/buildtimestamp.txt" + date +%s > "${INSTALL_DIR}/front/buildtimestamp.txt" + chown nginx:www-data "${INSTALL_DIR}/front/buildtimestamp.txt" fi echo -e " diff --git a/docs/API.md b/docs/API.md index 7a3718b9..8f734d5f 100755 --- a/docs/API.md +++ b/docs/API.md @@ -9,7 +9,7 @@ The endpoints are updated when objects in the API endpoints are changed. ### Location of the endpoints -In the container, these files are located under the `/home/pi/pialert/front/api/` folder and thus on the `/api/` url. +In the container, these files are located under the `/app/front/api/` folder and thus on the `/api/` url. ### Available endpoints diff --git a/docs/BACKUPS.md b/docs/BACKUPS.md index 4dc8a163..45301117 100755 --- a/docs/BACKUPS.md +++ b/docs/BACKUPS.md @@ -7,8 +7,8 @@ There are 3 artifacts that can be used to backup the application: | File | Description | Limitations | |-----------------------|-------------------------------|-------------------------------| -| `/db/pialert.db` | Database file(s) | The database file might be in an uncommitted state or corrupted | -| `/config/pialert.conf` | Configuration file | Doesn't contain settings from the Maintenance section | +| `/db/app.db` | Database file(s) | The database file might be in an uncommitted state or corrupted | +| `/config/app.conf` | Configuration file | Doesn't contain settings from the Maintenance section | | `/config/devices.csv` | CSV file containing device information | Doesn't contain historical data | ## Data and cackup storage @@ -17,7 +17,7 @@ To decide on a backup strategy, check where the data is stored: ### Core Configuration -The core application configuration is in the `pialert.conf` file (See [Settings System](https://github.com/jokob-sk/NetAlertX/blob/main/docs/SETTINGS_SYSTEM.md) for details), such as: +The core application configuration is in the `app.conf` file (See [Settings System](https://github.com/jokob-sk/NetAlertX/blob/main/docs/SETTINGS_SYSTEM.md) for details), such as: - Notification settings - Scanner settings @@ -35,7 +35,7 @@ The core device data is backed up to the `devices_.csv` file via the ### Historical data -Historical data is stored in the `pialert.db` database (See [Database overview](https://github.com/jokob-sk/NetAlertX/blob/main/docs/DATABASE.md) for details). This data includes: +Historical data is stored in the `app.db` database (See [Database overview](https://github.com/jokob-sk/NetAlertX/blob/main/docs/DATABASE.md) for details). This data includes: - Plugin objects - Plugin historical entries @@ -46,7 +46,7 @@ Historical data is stored in the `pialert.db` database (See [Database overview]( The safest approach to backups is to backup all of the above, by taking regular file system backups (I use [Kopia](https://github.com/kopia/kopia)). -Arguably, the most time is spent setting up the device list, so if only one file is kept I'd recommend to have a latest backup of the `devices_.csv` file, followed by the `pialert.conf` file. +Arguably, the most time is spent setting up the device list, so if only one file is kept I'd recommend to have a latest backup of the `devices_.csv` file, followed by the `app.conf` file. ### Scenario 1: Full backup @@ -54,8 +54,8 @@ End-result: Full restore #### Source artifacts: -- `/db/pialert.db` (uncorrupted) -- `/config/pialert.conf` +- `/db/app.db` (uncorrupted) +- `/config/app.conf` #### Recovery: @@ -68,14 +68,14 @@ End-result: Partial restore (historical data & configurations from the Maintenan #### Source artifacts: -- `/config/pialert.conf` +- `/config/app.conf` - `/config/devices_.csv` or `/config/devices.csv` #### Recovery: Even with a corrupted database you can recover what I would argue is 99% of the configuration (except of a couple of settings under Maintenance). -- map the `/config/pialert.conf` file as described in the [Setup documentation](https://github.com/jokob-sk/NetAlertX/blob/main/dockerfiles/README.md#docker-paths). +- map the `/config/app.conf` file as described in the [Setup documentation](https://github.com/jokob-sk/NetAlertX/blob/main/dockerfiles/README.md#docker-paths). - rename the `devices_.csv` to `devices.csv` and place it in the `/config` folder - Restore the `devices.csv` backup via the [Maintenance section](https://github.com/jokob-sk/NetAlertX/blob/main/docs/DEVICES_BULK_EDITING.md) diff --git a/docs/DATABASE.md b/docs/DATABASE.md index bb2ae1d9..fedef963 100755 --- a/docs/DATABASE.md +++ b/docs/DATABASE.md @@ -1,5 +1,5 @@ - # A high-level description of the datbase structure + # A high-level description of the database structure ⚠ Disclaimer: As I'm not the original author, some of the information might be inaccurate. Feel free to submit a PR to correct anything within this page or documentation in general. @@ -20,7 +20,7 @@ | Plugins_Language_Strings | Language strings colelcted from the plugin `config.json` files used for string resolution in the frontend. | ![Screen12][screen12] | | Plugins_Objects | Unique objects detected by individual plugins. | ![Screen13][screen13] | | Sessions | Used to display sessions in the charts | ![Screen15][screen15] | - | Settings | Database representation of the sum of all settings from `pialert.conf` and plugins coming from `config.json` files. | ![Screen16][screen16] | + | Settings | Database representation of the sum of all settings from `app.conf` and plugins coming from `config.json` files. | ![Screen16][screen16] | diff --git a/docs/DEBUG_PLUGINS.md b/docs/DEBUG_PLUGINS.md index 512a10f9..27ca3865 100755 --- a/docs/DEBUG_PLUGINS.md +++ b/docs/DEBUG_PLUGINS.md @@ -19,7 +19,7 @@ For a more in-depth overview on how plugins work check the [Plugins development #### Incorrect input data -Input data from the plugin might cause mapping issues in specific edge cases. Look for a corresponding section in the `pialert.log` file, for example notice the first line of the execution run of the `PIHOLE` plugin below: +Input data from the plugin might cause mapping issues in specific edge cases. Look for a corresponding section in the `app.log` file, for example notice the first line of the execution run of the `PIHOLE` plugin below: ``` 17:31:05 [Scheduler] - Scheduler run for PIHOLE: YES diff --git a/docs/DEBUG_TIPS.md b/docs/DEBUG_TIPS.md index f2712862..7c180037 100755 --- a/docs/DEBUG_TIPS.md +++ b/docs/DEBUG_TIPS.md @@ -15,8 +15,8 @@ Start the container via the **terminal** with a command similar to this one: ```bash docker run --rm --network=host \ - -v local/path/pialert/config:/home/pi/pialert/config \ - -v local/path/pialert/db:/home/pi/pialert/db \ + -v local/path/netalertx/config:/app/config \ + -v local/path/netalertx/db:/app/db \ -e TZ=Europe/Berlin \ -e PORT=20211 \ jokobsk/netalertx:latest @@ -53,9 +53,9 @@ services: ### Permissions -* If facing issues (AJAX errors, can't write to DB, empty screen, etc,) make sure permissions are set correctly, and check the logs under `/home/pi/pialert/front/log`. -* To solve permission issues you can try setting the owner and group of the `pialert.db` by executing the following on the host system: `docker exec netalertx chown -R www-data:www-data /home/pi/pialert/db/pialert.db`. -* If still facing issues, try to map the pialert.db file (⚠ not folder) to `:/home/pi/pialert/db/pialert.db` (see [docker-compose Examples](https://github.com/jokob-sk/NetAlertX/blob/main/dockerfiles/README.md#-docker-composeyml-examples) for details) +* If facing issues (AJAX errors, can't write to DB, empty screen, etc,) make sure permissions are set correctly, and check the logs under `/app/front/log`. +* To solve permission issues you can try setting the owner and group of the `app.db` by executing the following on the host system: `docker exec netalertx chown -R www-data:www-data /app/db/app.db`. +* If still facing issues, try to map the app.db file (⚠ not folder) to `:/app/db/app.db` (see [docker-compose Examples](https://github.com/jokob-sk/NetAlertX/blob/main/dockerfiles/README.md#-docker-composeyml-examples) for details) ### Container restarts / crashes diff --git a/docs/HOME_ASSISTANT.md b/docs/HOME_ASSISTANT.md index 44c83182..8321a0f9 100755 --- a/docs/HOME_ASSISTANT.md +++ b/docs/HOME_ASSISTANT.md @@ -36,9 +36,9 @@ NetAlertX comes with MQTT support, allowing you to show all detected devices as | ![Screen 3][list] | ![Screen 4][overview] | - [configuration]: /docs/img/HOME_ASISSTANT/PiAlert-HomeAssistant-Configuration.png "configuration" - [sensors]: /docs/img/HOME_ASISSTANT/PiAlert-HomeAssistant-Device-as-Sensors.png "sensors" - [history]: /docs/img/HOME_ASISSTANT/PiAlert-HomeAssistant-Device-Presence-History.png "history" - [list]: /docs/img/HOME_ASISSTANT/PiAlert-HomeAssistant-Devices-List.png "list" - [overview]: /docs/img/HOME_ASISSTANT/PiAlert-HomeAssistant-Overview-Card.png "overview" + [configuration]: /docs/img/HOME_ASISSTANT/HomeAssistant-Configuration.png "configuration" + [sensors]: /docs/img/HOME_ASISSTANT/HomeAssistant-Device-as-Sensors.png "sensors" + [history]: /docs/img/HOME_ASISSTANT/HomeAssistant-Device-Presence-History.png "history" + [list]: /docs/img/HOME_ASISSTANT/HomeAssistant-Devices-List.png "list" + [overview]: /docs/img/HOME_ASISSTANT/HomeAssistant-Overview-Card.png "overview" diff --git a/docs/HW_INSTALL.md b/docs/HW_INSTALL.md index b973981c..94e37368 100755 --- a/docs/HW_INSTALL.md +++ b/docs/HW_INSTALL.md @@ -14,20 +14,20 @@ be dangerous, as you cannot see the code that's about to be executed on your sys Alternatively you can download the installation script `install/install.debian.sh` from the repository and check the code yourself (beware other scripts are downloaded too - only from this repo). -NetAlertX will be installed in `home/pi/pialert/` and run on port number `20211`. +NetAlertX will be installed in `/app` and run on port number `20211`. Some facts about what and where something will be changed/installed by the HW install setup (may not contain everything!): -- `/home/pi/pialert` directory will be deleted and newly created -- `/home/pi/pialert` will contain the whole repository (downloaded by `install/install.debian.sh`) +- `/app` directory will be deleted and newly created +- `/app` will contain the whole repository (downloaded by `install/install.debian.sh`) - The default NGINX site `/etc/nginx/sites-enabled/default` will be disabled (sym-link deleted or backed up to `sites-available`) -- `/var/www/html/pialert` directory will be deleted and newly created -- `/etc/nginx/conf.d/pialert.conf` will be sym-linked to `/home/pi/pialert/install/netalertx.debian.conf` +- `/var/www/html/netalertx` directory will be deleted and newly created +- `/etc/nginx/conf.d/netalertx.conf` will be sym-linked to `/app/install/netalertx.debian.conf` - Some files (IEEE device vendors info, ...) will be created in the directory where the installation script is executed ## Limitations -- No system service is provided. NetAlertX must be started using `/home/pi/pialert/install/start.debian.sh`. +- No system service is provided. NetAlertX must be started using `/app/install/start.debian.sh`. - No checks for other running software is done. - Only tested to work on Debian Bookworm (Debian 12). - **EXPERIMENTAL** and not recommended way to install NetAlertX. diff --git a/docs/ICONS.md b/docs/ICONS.md index d0546ab4..989ecd2d 100755 --- a/docs/ICONS.md +++ b/docs/ICONS.md @@ -45,7 +45,7 @@ Copying the HTML code from [Font Awesome](https://fontawesome.com/search?o=r&m=f If you own the premium package of Font Awesome icons you can mount it in your Docker container the following way: ```yaml -/font-awesome:/home/pi/pialert/front/lib/AdminLTE/bower_components/font-awesome:ro +/font-awesome:/app/front/lib/AdminLTE/bower_components/font-awesome:ro ``` You can use the full range of Font Awesome icons afterwards. diff --git a/docs/MIGRATION.md b/docs/MIGRATION.md new file mode 100755 index 00000000..08ebcdc2 --- /dev/null +++ b/docs/MIGRATION.md @@ -0,0 +1,119 @@ +# Migration form PiAlert to NetAlertX + +The migration should be pretty straightforward. The application installation folder in the docker container has changed from `/home/pi/pialert` to `/app`. That means the new mount points are: + + | Old mount point | New mount point | + |----------------------|---------------| + | `/home/pi/pialert/config` | `/app/config` | + | `/home/pi/pialert/db` | `/app/db` | + + + If you were mounting files directly, please note the file names have changed: + + | Old file name | New file name | + |----------------------|---------------| + | `pialert.conf` | `app.conf` | + | `pialert.db` | `app.db` | + + +> [!NOTE] +> The application uses symlinks linking the old locations to the new ones, so data loss should not occur. [Backup strategies](https://github.com/jokob-sk/NetAlertX/blob/main/docs/BACKUPS.md) are still recommended to backup your setup. + +In summary, docker file mount locations in your `docker-compose.yml` or docker run command have changed. Examples follow. + + +## Example 1: Mapping folders + +### Old docker-compose.yml + +```yaml +version: "3" +services: + pialert: + container_name: pialert + # use the below line if you want to test the latest dev image + # image: "jokobsk/netalertx-dev:latest" + image: "jokobsk/pialert:latest" + network_mode: "host" + restart: unless-stopped + volumes: + - local/path/config:/home/pi/pialert/config + - local/path/db:/home/pi/pialert/db + # (optional) useful for debugging if you have issues setting up the container + - local/path/logs:/home/pi/pialert/front/log + environment: + - TZ=Europe/Berlin + - PORT=20211 +``` + +### New docker-compose.yml + +```yaml +version: "3" +services: + netalertx: # ⚠🟡 This has changed (optional) 🟡⚠ + container_name: netalertx # ⚠🟡 This has changed (optional) 🟡⚠ + # use the below line if you want to test the latest dev image + # image: "jokobsk/netalertx-dev:latest" + image: "jokobsk/netalertx:latest" # ⚠🔺🟡 This has changed (optional/required in future) 🟡🔺⚠ + network_mode: "host" + restart: unless-stopped + volumes: + - local/path/config:/app/config # ⚠🔺 This has changed (required) 🔺⚠ + - local/path/db:/app/db # ⚠🔺 This has changed (required) 🔺⚠ + # (optional) useful for debugging if you have issues setting up the container + - local/path/logs:/app/front/log # ⚠🟡 This has changed (optional) 🟡⚠ + environment: + - TZ=Europe/Berlin + - PORT=20211 +``` + + +## Example 2: Mapping files + +> [!NOTE] +> The recommendation is to map folders as in Example 1, map files directly only when needed. + +### Old docker-compose.yml + +```yaml +version: "3" +services: + pialert: + container_name: pialert + # use the below line if you want to test the latest dev image + # image: "jokobsk/netalertx-dev:latest" + image: "jokobsk/pialert:latest" + network_mode: "host" + restart: unless-stopped + volumes: + - local/path/config/pialert.conf:/home/pi/pialert/config/pialert.conf + - local/path/db/pialert.db:/home/pi/pialert/db/pialert.db + # (optional) useful for debugging if you have issues setting up the container + - local/path/logs:/home/pi/pialert/front/log + environment: + - TZ=Europe/Berlin + - PORT=20211 +``` + +### New docker-compose.yml + +```yaml +version: "3" +services: + netalertx: # ⚠🟡 This has changed (optional) 🟡⚠ + container_name: netalertx # ⚠🟡 This has changed (optional) 🟡⚠ + # use the below line if you want to test the latest dev image + # image: "jokobsk/netalertx-dev:latest" + image: "jokobsk/netalertx:latest" # ⚠🔺🟡 This has changed (optional/required in future) 🟡🔺⚠ + network_mode: "host" + restart: unless-stopped + volumes: + - local/path/config/app.conf:/app/config/app.conf # ⚠🔺 This has changed (required) 🔺⚠ + - local/path/db/app.db:/app/db/app.db # ⚠🔺 This has changed (required) 🔺⚠ + # (optional) useful for debugging if you have issues setting up the container + - local/path/logs:/app/front/log # ⚠🟡 This has changed (optional) 🟡⚠ + environment: + - TZ=Europe/Berlin + - PORT=20211 +``` diff --git a/docs/README.md b/docs/README.md index 2e7b058f..a909a2ed 100755 --- a/docs/README.md +++ b/docs/README.md @@ -63,7 +63,7 @@ There is also an in-app Help / FAQ section that should be answering frequently a #### 👩‍💻For Developers👨‍💻 -- [APP code structure](/netalertx/README.md) +- [Server APP code structure](/server/README.md) - [Database structure](/docs/DATABASE.md) - [API endpoints details](/docs/API.md) - [Plugin system details and how to develop your own](/front/plugins/README.md) @@ -122,7 +122,7 @@ Suggested test cases: Some additional context: -* Permanent settings/config is stored in the `pialert.conf` file +* Permanent settings/config is stored in the `app.conf` file * Currently temporary (session?) settings are stored in the `Parameters` DB table as key-value pairs. This table is wiped during a container rebuild/restart and its values are re-initialized from cookies/session data from the browser. ## 🐛 Submitting an issue or bug diff --git a/docs/REVERSE_DNS.md b/docs/REVERSE_DNS.md index d7bc1aad..07bab836 100755 --- a/docs/REVERSE_DNS.md +++ b/docs/REVERSE_DNS.md @@ -41,9 +41,9 @@ services: image: "jokobsk/netalertx:latest" restart: unless-stopped volumes: - - ./config/pialert.conf:/home/pi/pialert/config/pialert.conf - - ./pialert_db:/home/pi/pialert/db - - ./log:/home/pi/pialert/front/log + - ./config/app.conf:/app/config/app.conf + - ./db:/app/db + - ./log:/app/front/log - ./config/resolv.conf:/etc/resolv.conf # Mapping the /resolv.conf file for better name resolution environment: - TZ=Europe/Berlin diff --git a/docs/REVERSE_PROXY.md b/docs/REVERSE_PROXY.md index 1233cbe6..1e218703 100755 --- a/docs/REVERSE_PROXY.md +++ b/docs/REVERSE_PROXY.md @@ -472,9 +472,9 @@ Mapping the updated file (on the local filesystem at `/appl/docker/netalertx/def ```bash docker run -d --rm --network=host \ --name=netalertx \ - -v /appl/docker/pialert/config:/home/pi/pialert/config \ - -v /appl/docker/pialert/db:/home/pi/pialert/db \ - -v /appl/docker/pialert/default:/etc/nginx/sites-available/default \ + -v /appl/docker/netalertx/config:/app/config \ + -v /appl/docker/netalertx/db:/app/db \ + -v /appl/docker/netalertx/default:/etc/nginx/sites-available/default \ -e TZ=Europe/Amsterdam \ -e PORT=20211 \ jokobsk/netalertx:latest diff --git a/docs/SETTINGS_SYSTEM.md b/docs/SETTINGS_SYSTEM.md index 1207a6c1..128642b8 100755 --- a/docs/SETTINGS_SYSTEM.md +++ b/docs/SETTINGS_SYSTEM.md @@ -6,11 +6,11 @@ If you are a user of the app, settings have a detailed description in the _Setti ### 🛢 Data storage -The source of truth for user-defined values is the `pialert.conf` file. Editing the file makes the App overwrite values in the `Settings` database table and in the `table_settings.json` file. +The source of truth for user-defined values is the `app.conf` file. Editing the file makes the App overwrite values in the `Settings` database table and in the `table_settings.json` file. #### Settings database table -The `Settings` database table contains settings for App run purposes. The table is recreated every time the App restarts. The settings are loaded from the source-of-truth, that is the `pialert.conf` file. A high-level overview on the database structure can be found in the [database documentation](/docs/DATABASE.md). +The `Settings` database table contains settings for App run purposes. The table is recreated every time the App restarts. The settings are loaded from the source-of-truth, that is the `app.conf` file. A high-level overview on the database structure can be found in the [database documentation](/docs/DATABASE.md). #### table_settings.json @@ -20,27 +20,27 @@ This is the [API endpoint](/docs/API.md) that reflects the state of the `Setting The json file is also cached on the client-side local storage of the browser. -#### pialert.conf +#### app.conf > [!NOTE] > This is the source of truth for settings. User-defined values in this files always override default values specified in the Plugin definition. -The App generates two `pialert.conf` entries for every setting (Since version 23.8+). One entry is the setting value, the second is the `__metadata` associated with the setting. This `__metadata` entry contains the full setting definition in JSON format. Currently unused, but intended to be used in future to extend the Settings system. +The App generates two `app.conf` entries for every setting (Since version 23.8+). One entry is the setting value, the second is the `__metadata` associated with the setting. This `__metadata` entry contains the full setting definition in JSON format. Currently unused, but intended to be used in future to extend the Settings system. #### Plugin settings > [!NOTE] > This is the preferred way adding settings going forward. I'll be likely migrating all app settings into plugin-based settings. -Plugin settings are loaded dynamically from the `config.json` of individual plugins. If a setting isn't defined in the `pialert.conf` file, it is initialized via the `default_value` property of a setting from the `config.json` file. Check the [Plugins documentation](https://github.com/jokob-sk/NetAlertX/blob/main/front/plugins/README.md#-setting-object-structure), section `⚙ Setting object structure` for details on the structure of the setting. +Plugin settings are loaded dynamically from the `config.json` of individual plugins. If a setting isn't defined in the `app.conf` file, it is initialized via the `default_value` property of a setting from the `config.json` file. Check the [Plugins documentation](https://github.com/jokob-sk/NetAlertX/blob/main/front/plugins/README.md#-setting-object-structure), section `⚙ Setting object structure` for details on the structure of the setting. ![Screen 1][screen1] ### Settings Process flow -The process flow is mostly managed by the [initialise.py](/pialert/initialise.py) file. +The process flow is mostly managed by the [initialise.py](/server/initialise.py) file. -The script is responsible for reading user-defined values from a configuration file (`pialert.conf`), initializing settings, and importing them into a database. It also handles plugins and their configurations. +The script is responsible for reading user-defined values from a configuration file (`app.conf`), initializing settings, and importing them into a database. It also handles plugins and their configurations. Here's a high-level description of the code: @@ -49,7 +49,7 @@ Here's a high-level description of the code: - `importConfigs`: This function is the main entry point of the script. It imports user settings from a configuration file, processes them, and saves them to the database. - - `read_config_file`: This function reads the configuration file (`pialert.conf`) and returns a dictionary containing the key-value pairs from the file. + - `read_config_file`: This function reads the configuration file (`app.conf`) and returns a dictionary containing the key-value pairs from the file. 2. Importing Configuration and Initializing Settings: - The `importConfigs` function starts by checking the modification time of the configuration file to determine if it needs to be re-imported. If the file has not been modified since the last import, the function skips the import process. diff --git a/docs/SUBNETS.md b/docs/SUBNETS.md index ae2fb63a..24c7db0d 100755 --- a/docs/SUBNETS.md +++ b/docs/SUBNETS.md @@ -8,7 +8,7 @@ You need to specify the network interface and the network mask. You can also con ## Examples > [!NOTE] -> Please use the UI to configure settings as that ensures that the config file is in the correct format. Edit `pialert.conf` directly only when really necessary. +> Please use the UI to configure settings as that ensures that the config file is in the correct format. Edit `app.conf` directly only when really necessary. > ![settings](/front/plugins/arp_scan/arp-scan-settings.png) * Examples for one and two subnets (❗ Note the `['...', '...']` format): diff --git a/docs/VERSIONS.md b/docs/VERSIONS.md index 40614a01..12185523 100755 --- a/docs/VERSIONS.md +++ b/docs/VERSIONS.md @@ -22,4 +22,4 @@ For a comparison, this is how the UI looks like if you are on the latest stable ## Implementation details -During build a [/home/pi/pialert/front/buildtimestamp.txt](https://github.com/jokob-sk/NetAlertX/blob/092797e75ccfa8359444ad149e727358ac4da05f/Dockerfile#L44) file is created. The app then periodically checks if a new release is available with a newer timestamp in GitHub's rest-based JSON endpoint (check the `def isNewVersion():` method in `pialert.py` for details). \ No newline at end of file +During build a [/app/front/buildtimestamp.txt](https://github.com/jokob-sk/NetAlertX/blob/092797e75ccfa8359444ad149e727358ac4da05f/Dockerfile#L44) file is created. The app then periodically checks if a new release is available with a newer timestamp in GitHub's rest-based JSON endpoint (check the `def isNewVersion():` method for details). \ No newline at end of file diff --git a/docs/img/HOME_ASISSTANT/PiAlert-HomeAssistant-Configuration.png b/docs/img/HOME_ASISSTANT/HomeAssistant-Configuration.png similarity index 100% rename from docs/img/HOME_ASISSTANT/PiAlert-HomeAssistant-Configuration.png rename to docs/img/HOME_ASISSTANT/HomeAssistant-Configuration.png diff --git a/docs/img/HOME_ASISSTANT/PiAlert-HomeAssistant-Device-Presence-History.png b/docs/img/HOME_ASISSTANT/HomeAssistant-Device-Presence-History.png similarity index 100% rename from docs/img/HOME_ASISSTANT/PiAlert-HomeAssistant-Device-Presence-History.png rename to docs/img/HOME_ASISSTANT/HomeAssistant-Device-Presence-History.png diff --git a/docs/img/HOME_ASISSTANT/PiAlert-HomeAssistant-Device-as-Sensors.png b/docs/img/HOME_ASISSTANT/HomeAssistant-Device-as-Sensors.png similarity index 100% rename from docs/img/HOME_ASISSTANT/PiAlert-HomeAssistant-Device-as-Sensors.png rename to docs/img/HOME_ASISSTANT/HomeAssistant-Device-as-Sensors.png diff --git a/docs/img/HOME_ASISSTANT/PiAlert-HomeAssistant-Devices-List.png b/docs/img/HOME_ASISSTANT/HomeAssistant-Devices-List.png similarity index 100% rename from docs/img/HOME_ASISSTANT/PiAlert-HomeAssistant-Devices-List.png rename to docs/img/HOME_ASISSTANT/HomeAssistant-Devices-List.png diff --git a/docs/img/HOME_ASISSTANT/PiAlert-HomeAssistant-Overview-Card.png b/docs/img/HOME_ASISSTANT/HomeAssistant-Overview-Card.png similarity index 100% rename from docs/img/HOME_ASISSTANT/PiAlert-HomeAssistant-Overview-Card.png rename to docs/img/HOME_ASISSTANT/HomeAssistant-Overview-Card.png diff --git a/front/css/pialert.css b/front/css/app.css similarity index 93% rename from front/css/pialert.css rename to front/css/app.css index d31ebe29..0669546f 100755 --- a/front/css/pialert.css +++ b/front/css/app.css @@ -2,7 +2,7 @@ # NetAlertX # Open Source Network Guard / WIFI & LAN intrusion detector # -# pialert.css - Front module. CSS styles +# app.css - Front module. CSS styles #------------------------------------------------------------------------------- # Puche 2021 / 2022+ jokob jokob@duck.com GNU GPLv3 ----------------------------------------------------------------------------- */ @@ -151,10 +151,26 @@ /* ----------------------------------------------------------------------------- Customized Main Menu ----------------------------------------------------------------------------- */ + +.NetAlertX-logo +{ + border-color:transparent !important; + height: 50px !important; + width: 50px !important; + margin-top:15px !important; + border-radius: 1px !important; +} + .main-header .logo { width: 150px; } + +.navbar-nav > .user-menu .user-image +{ + margin-top: 3px; +} + .main-header>.navbar { margin-left: 150px; } @@ -487,6 +503,73 @@ display: none; } +/* ticker setup */ +.ticker-li +{ + width: 40%; +} + +#ticker_announcement_plc +{ + + /* height: 50px; */ + overflow: hidden; + width: 65%; + position: absolute; + left: 40px; + top: 15px; +} + +@media (max-width: 1500px) and (min-width: 1101px) { + #ticker_announcement_plc { + width: 45%; /* Width for screen sizes between 1100px and 730px */ + } +} + +@media (max-width: 1100px) and (min-width: 801px) { + #ticker_announcement_plc { + width: 30%; /* Width for screen sizes between 1100px and 730px */ + } +} + +@media (max-width: 800px) { + #ticker_announcement_plc { + width: 25%; /* Width for screen sizes less than 730px */ + } +} + +#ticker-message a +{ + color:#3200bb; + text-decoration: underline; +} + +#ticker-message +{ + color:#FFFFFF; +} + +#ticker_announcement_plc:hover .ticker_announcement { + animation-play-state: paused; + } + +@keyframes marquee { + 0% { + transform: translateX(100%); + } + 100% { + transform: translateX(-150%); + } + } + +.ticker_announcement { + text-align: center; + white-space: nowrap; + animation: marquee 20s linear infinite; + cursor: default; +} + +/* maintenance buttons */ .dbtools-button { display: inline-block; diff --git a/front/devices.php b/front/devices.php index acacf7e5..7ef18f8b 100755 --- a/front/devices.php +++ b/front/devices.php @@ -19,8 +19,8 @@ // check permissions - $dbPath = "../db/pialert.db"; - $confPath = "../config/pialert.conf"; + $dbPath = "../db/app.db"; + $confPath = "../config/app.conf"; checkPermissions([$dbPath, $confPath]); ?> diff --git a/front/img/NetAlertX_black.png b/front/img/NetAlertX_black.png new file mode 100755 index 00000000..8999fb37 Binary files /dev/null and b/front/img/NetAlertX_black.png differ diff --git a/front/img/NetAlertX_white.png b/front/img/NetAlertX_white.png new file mode 100755 index 00000000..2d8c3133 Binary files /dev/null and b/front/img/NetAlertX_white.png differ diff --git a/front/img/NetAlertX_white_1.png b/front/img/NetAlertX_white_1.png new file mode 100755 index 00000000..a6c717ba Binary files /dev/null and b/front/img/NetAlertX_white_1.png differ diff --git a/front/img/NetAlertX_white_2.png b/front/img/NetAlertX_white_2.png new file mode 100755 index 00000000..f1676ce7 Binary files /dev/null and b/front/img/NetAlertX_white_2.png differ diff --git a/front/img/manifest.json b/front/img/manifest.json index 0e0dfe2c..24ff2693 100755 --- a/front/img/manifest.json +++ b/front/img/manifest.json @@ -1,6 +1,6 @@ { - "name": "Pi-Alert Console", - "short_name": "Pi-Alert", + "name": "NetAlertX Console", + "short_name": "NetAlertX", "display": "standalone", "icons": [ { diff --git a/front/img/pialertLogoBlack.png b/front/img/pialertLogoBlack.png deleted file mode 100755 index fe20f244..00000000 Binary files a/front/img/pialertLogoBlack.png and /dev/null differ diff --git a/front/img/pialertLogoGray50.png b/front/img/pialertLogoGray50.png deleted file mode 100755 index ab4563e0..00000000 Binary files a/front/img/pialertLogoGray50.png and /dev/null differ diff --git a/front/img/pialertLogoGray80.png b/front/img/pialertLogoGray80.png deleted file mode 100755 index 3c347c27..00000000 Binary files a/front/img/pialertLogoGray80.png and /dev/null differ diff --git a/front/img/pialertLogoOrange.png b/front/img/pialertLogoOrange.png deleted file mode 100755 index 00bf5dad..00000000 Binary files a/front/img/pialertLogoOrange.png and /dev/null differ diff --git a/front/img/pialertLogoWhite.png b/front/img/pialertLogoWhite.png deleted file mode 100755 index ae372da9..00000000 Binary files a/front/img/pialertLogoWhite.png and /dev/null differ diff --git a/front/index.php b/front/index.php index 8785e0c4..79e67463 100755 --- a/front/index.php +++ b/front/index.php @@ -1,5 +1,5 @@ - + - @@ -148,7 +147,7 @@ if ($ENABLED_DARKMODE === True) {

-


/home/pi/pialert/back/pialert-cli set_password

+


/app/back/pialert-cli set_password

diff --git a/front/js/common.js b/front/js/common.js index 3706d3ef..beb7d818 100755 --- a/front/js/common.js +++ b/front/js/common.js @@ -409,6 +409,26 @@ function showMessage (textMessage="") { } } +// ----------------------------------------------------------------------------- +function showTickerAnnouncement(textMessage = "") { + if (textMessage.toLowerCase().includes("error")) { + // show error + alert(textMessage); + } else { + // show permanent notification + $("#ticker-message").html(textMessage); + $("#tickerAnnouncement").removeClass("myhidden"); + // Move the tickerAnnouncement element to ticker_announcement_plc + $("#tickerAnnouncement").appendTo("#ticker_announcement_plc"); + + // var $ticker = $('#tickerAnnouncement'); + // var $tickerMessage = $('#ticker-message'); + + // Clone the ticker message to create continuous scrolling effect + // $tickerMessage.clone().appendTo($ticker); + } +} + // ----------------------------------------------------------------------------- // String utilities @@ -1154,7 +1174,7 @@ function arraysContainSameValues(arr1, arr2) { // ----------------------------------------------------------------------------- // Define a unique key for storing the flag in sessionStorage -var sessionStorageKey = "myScriptExecuted_pialert_common"; +var sessionStorageKey = "myScriptExecuted_common_js"; // ----------------------------------------------------------------------------- // Clearing all the caches @@ -1202,7 +1222,7 @@ $.get('api/app_state.json?nocache=' + Date.now(), function(appState) { // Display spinner and reload page if not yet initialized function handleFirstLoad(callback) { - if(!pialert_common_init) + if(!app_common_init) { setTimeout(function() { @@ -1214,7 +1234,7 @@ function handleFirstLoad(callback) // ----------------------------------------------------------------------------- // Check if the code has been executed before by checking sessionStorage -var pialert_common_init = sessionStorage.getItem(sessionStorageKey) === "true"; +var app_common_init = sessionStorage.getItem(sessionStorageKey) === "true"; var completedCalls = [] var completedCalls_final = ['cacheSettings', 'cacheStrings', 'cacheDevices']; diff --git a/front/maintenance.php b/front/maintenance.php index b72d65c3..a57eb46a 100755 --- a/front/maintenance.php +++ b/front/maintenance.php @@ -57,7 +57,7 @@ $pia_installed_skins = array('skin-black-light', // Size and last mod of DB ------------------------------------------------------ -$pia_db = str_replace('front', 'db', getcwd()).'/pialert.db'; +$pia_db = str_replace('front', 'db', getcwd()).'/app.db'; $pia_db_size = number_format((filesize($pia_db) / 1000000),2,",",".") . ' MB'; $pia_db_mod = date ("F d Y H:i:s", filemtime($pia_db)); @@ -67,7 +67,7 @@ $pia_db_mod = date ("F d Y H:i:s", filemtime($pia_db)); $Pia_Archive_Path = str_replace('front', 'db', getcwd()).'/'; $Pia_Archive_count = 0; $Pia_Archive_diskusage = 0; -$files = glob($Pia_Archive_Path."pialertdb_*.zip"); +$files = glob($Pia_Archive_Path."appdb_*.zip"); if ($files){ $Pia_Archive_count = count($files); } @@ -78,7 +78,7 @@ $Pia_Archive_diskusage = number_format(($Pia_Archive_diskusage / 1000000),2,",", // Find latest Backup for restore ----------------------------------------------- -$latestfiles = glob($Pia_Archive_Path."pialertdb_*.zip"); +$latestfiles = glob($Pia_Archive_Path."appdb_*.zip"); natsort($latestfiles); $latestfiles = array_reverse($latestfiles,False); @@ -403,14 +403,14 @@ $db->close();
-
-
pialert_front.log
- +
app_front.log
+
- +
-
-
pialert.php_errors.log
- +
app.php_errors.log
+
- +
@@ -792,7 +792,7 @@ function scrollDown() // Check if the parent
  • is active if (elementToCheck.parent().hasClass("active")) { { - var areaIDs = ['pialert_log', 'pialert_front_log', 'IP_changes_log', 'stdout_log', 'stderr_log', 'pialert_pholus_log', 'pialert_pholus_lastrun_log', 'pialert_php_log']; + var areaIDs = ['app_log', 'app_front_log', 'IP_changes_log', 'stdout_log', 'stderr_log', 'app_pholus_log', 'app_pholus_lastrun_log', 'app_php_log']; for (let i = 0; i < areaIDs.length; i++) { diff --git a/front/php/server/db.php b/front/php/server/db.php index 67d9f249..40e7b21f 100755 --- a/front/php/server/db.php +++ b/front/php/server/db.php @@ -10,7 +10,7 @@ //------------------------------------------------------------------------------ // DB File Path -$DBFILE = dirname(__FILE__).'/../../../db/pialert.db'; +$DBFILE = dirname(__FILE__).'/../../../db/app.db'; //------------------------------------------------------------------------------ // Connect DB diff --git a/front/php/server/devices.php b/front/php/server/devices.php index a0056f35..15439930 100755 --- a/front/php/server/devices.php +++ b/front/php/server/devices.php @@ -331,7 +331,7 @@ function deleteActHistory() { //------------------------------------------------------------------------------ function PiaBackupDBtoArchive() { // prepare fast Backup - $dbfilename = 'pialert.db'; + $dbfilename = 'app.db'; $file = '../../../db/'.$dbfilename; $newfile = '../../../db/'.$dbfilename.'.latestbackup'; @@ -340,7 +340,7 @@ function PiaBackupDBtoArchive() { echo lang('BackDevices_Backup_CopError'); } else { // Create archive with actual date - $Pia_Archive_Name = 'pialertdb_'.date("Ymd_His").'.zip'; + $Pia_Archive_Name = 'appdb_'.date("Ymd_His").'.zip'; $Pia_Archive_Path = '../../../db/'; exec('zip -j '.$Pia_Archive_Path.$Pia_Archive_Name.' ../../../db/'.$dbfilename, $output); // chheck if archive exists @@ -389,7 +389,7 @@ function PiaPurgeDBBackups() { $Pia_Archive_Path = '../../../db'; $Pia_Backupfiles = array(); - $files = array_diff(scandir($Pia_Archive_Path, SCANDIR_SORT_DESCENDING), array('.', '..', $dbfilename, 'pialertdb-reset.zip')); + $files = array_diff(scandir($Pia_Archive_Path, SCANDIR_SORT_DESCENDING), array('.', '..', $dbfilename, 'netalertxdb-reset.zip')); foreach ($files as &$item) { diff --git a/front/php/server/util.php b/front/php/server/util.php index 83af9b6a..656745f4 100755 --- a/front/php/server/util.php +++ b/front/php/server/util.php @@ -250,7 +250,7 @@ function cleanLog($logFile) $path = ""; - $allowedFiles = ['pialert.log', 'pialert_front.log', 'IP_changes.log', 'stdout.log', 'stderr.log', "pialert_pholus_lastrun.log", 'pialert.php_errors.log']; + $allowedFiles = ['app.log', 'app_front.log', 'IP_changes.log', 'stdout.log', 'stderr.log', "pholus_lastrun.log", 'app.php_errors.log']; if(in_array($logFile, $allowedFiles)) { @@ -387,7 +387,7 @@ function saveSettings() // Replace the original file with the temporary file rename($tempConfPath, $fullConfPath); - displayMessage("
    Settings saved to the pialert.conf file.

    A time-stamped backup of the previous file created.

    Reloading...
    ", + displayMessage("
    Settings saved to the app.conf file.

    A time-stamped backup of the previous file created.

    Reloading...
    ", FALSE, TRUE, TRUE, TRUE); } diff --git a/front/php/templates/build.php b/front/php/templates/build.php index 0ab9f1e2..ed352c38 100755 --- a/front/php/templates/build.php +++ b/front/php/templates/build.php @@ -11,7 +11,7 @@ # cvc90 2023 https://github.com/cvc90 GNU GPLv3 # #---------------------------------------------------------------------------------# - $file = "/home/pi/pialert/front/buildtimestamp.txt"; + $file = "/app/front/buildtimestamp.txt"; if (file_exists($file)) { echo date("Y-m-d", ((int)file_get_contents($file))); } diff --git a/front/php/templates/footer.php b/front/php/templates/footer.php index 16e663be..46a0e76c 100755 --- a/front/php/templates/footer.php +++ b/front/php/templates/footer.php @@ -58,5 +58,9 @@ + + diff --git a/front/php/templates/header.php b/front/php/templates/header.php index 10d6aa0b..b6249fce 100755 --- a/front/php/templates/header.php +++ b/front/php/templates/header.php @@ -54,7 +54,7 @@ require dirname(__FILE__).'/security.php'; - + @@ -66,7 +66,7 @@ require dirname(__FILE__).'/security.php'; - + @@ -111,19 +111,23 @@ if ($ENABLED_DARKMODE === True) { + onLoad="show_pia_servertime();" >
    +
    + + + + +
    + + +
    + +
    + + +
    +
    Announcement message
    +
    + diff --git a/front/php/templates/security.php b/front/php/templates/security.php index d0cb62eb..4a529178 100755 --- a/front/php/templates/security.php +++ b/front/php/templates/security.php @@ -24,7 +24,7 @@ if(array_search('action', $_REQUEST) != FALSE) // ################################################## // ## Login Processing start // ################################################## -$config_file = "../config/pialert.conf"; +$config_file = "../config/app.conf"; $config_file_lines = file($config_file); $CookieSaveLoginName = "NetAlertX_SaveLogin"; diff --git a/front/php/templates/skinUI.php b/front/php/templates/skinUI.php index d72ccc5a..291fe7a2 100755 --- a/front/php/templates/skinUI.php +++ b/front/php/templates/skinUI.php @@ -12,7 +12,7 @@ if( isset($_COOKIE['Front_Dark_Mode_Enabled'])) $ENABLED_DARKMODE = False; } -foreach (glob("/home/pi/pialert/db/setting_skin*") as $filename) { +foreach (glob("/app/db/setting_skin*") as $filename) { $pia_skin_selected = str_replace('setting_','',basename($filename)); } if (isset($pia_skin_selected) == FALSE or (strlen($pia_skin_selected) == 0)) {$pia_skin_selected = 'skin-blue';} diff --git a/front/php/templates/timezone.php b/front/php/templates/timezone.php index 5f754cd2..26416572 100755 --- a/front/php/templates/timezone.php +++ b/front/php/templates/timezone.php @@ -5,9 +5,9 @@ // ################################### $configFolderPath = dirname(__FILE__)."/../../../config/"; -$config_file = "pialert.conf"; +$config_file = "app.conf"; $logFolderPath = dirname(__FILE__)."/../../log/"; -$log_file = "pialert_front.log"; +$log_file = "app_front.log"; $fullConfPath = $configFolderPath.$config_file; diff --git a/front/php/templates/version.php b/front/php/templates/version.php index 5afe352f..f383264e 100755 --- a/front/php/templates/version.php +++ b/front/php/templates/version.php @@ -11,7 +11,7 @@ # cvc90 2023 https://github.com/cvc90 GNU GPLv3 # #---------------------------------------------------------------------------------# - $filename = "/home/pi/pialert/.VERSION"; + $filename = "/app/.VERSION"; if(file_exists($filename)) { echo file_get_contents($filename); } diff --git a/front/plugins/README.md b/front/plugins/README.md index b06f90d7..bfed8ea8 100755 --- a/front/plugins/README.md +++ b/front/plugins/README.md @@ -74,7 +74,7 @@ Example use cases for plugins could be: * Creating a script to create FAKE devices based on user input via custom settings * ...at this point the limitation is mostly the creativity rather than the capability (there might be edge cases and a need to support more form controls for user input off custom settings, but you probably get the idea) -If you wish to develop a plugin, please check the existing plugin structure. Once the settings are saved by the user they need to be removed from the `pialert.conf` file manually if you want to re-initialize them from the `config.json` of the plugin. +If you wish to develop a plugin, please check the existing plugin structure. Once the settings are saved by the user they need to be removed from the `app.conf` file manually if you want to re-initialize them from the `config.json` of the plugin. Again, please read the below carefully if you'd like to contribute with a plugin yourself. This documentation file might be outdated, so double-check the sample plugins as well. @@ -141,16 +141,16 @@ Currently, these data sources are supported (valid `data_source` value). | Name | `data_source` value | Needs to return a "table"* | Overview (more details on this page below) | |----------------------|----------------------|----------------------|----------------------| | Script | `script` | no | Executes any linux command in the `CMD` setting. | -| NetAlertX DB query | `pialert-db-query` | yes | Executes a SQL query on the NetAlertX database in the `CMD` setting. | +| NetAlertX DB query | `app-db-query` | yes | Executes a SQL query on the NetAlertX database in the `CMD` setting. | | Template | `template` | no | Used to generate internal settings, such as default values. | | External SQLite DB query | `sqlite-db-query` | yes | Executes a SQL query from the `CMD` setting on an external SQLite database mapped in the `DB_PATH` setting. | | Plugin type | `plugin_type` | no | Specifies the type of the plugin and in which section the Plugin settings are displayed ( one of `general/system/scanner/other/publisher` ). | -> * "Needs to return a "table" means that the application expects a `last_result.log` file with some results. It's not a blocker, however warnings in the `pialert.log` might be logged. +> * "Needs to return a "table" means that the application expects a `last_result.log` file with some results. It's not a blocker, however warnings in the `app.log` might be logged. > 🔎Example >```json ->"data_source": "pialert-db-query" +>"data_source": "app-db-query" >``` If you want to display plugin objects or import devices into the app, data sources have to return a "table" of the exact structure as outlined above. @@ -202,11 +202,11 @@ https://www.google.com|null|2023-01-02 15:56:30|200|0.7898| ``` -### "data_source": "pialert-db-query" +### "data_source": "app-db-query" -If the `data_source` is set to `pialert-db-query`, the `CMD` setting needs to contain a SQL query rendering the columns as defined in the "Column order and values" section above. The order of columns is important. +If the `data_source` is set to `app-db-query`, the `CMD` setting needs to contain a SQL query rendering the columns as defined in the "Column order and values" section above. The order of columns is important. -This SQL query is executed on the `pialert.db` SQLite database file. +This SQL query is executed on the `app.db` SQLite database file. > 🔎Example > @@ -281,7 +281,7 @@ For example for `PIHOLE` (`"unique_prefix": "PIHOLE"`) it is `EXTERNAL_PIHOLE.`. > ... >``` -The actual SQL query you want to execute is then stored as a `CMD` setting, similar to a Plugin of the `pialert-db-query` plugin type. The format has to adhere to the format outlined in the "Column order and values" section above. +The actual SQL query you want to execute is then stored as a `CMD` setting, similar to a Plugin of the `app-db-query` plugin type. The format has to adhere to the format outlined in the "Column order and values" section above. > 🔎Example > @@ -448,7 +448,7 @@ The `params` array in the `config.json` is used to enable the user to change the > Passing user-defined settings to a command. Let's say, you want to have a script, that is called with a user-defined parameter called `urls`: > > ```bash -> root@server# python3 /home/pi/pialert/front/plugins/website_monitor/script.py urls=https://google.com,https://duck.com +> root@server# python3 /app/front/plugins/website_monitor/script.py urls=https://google.com,https://duck.com > ``` * You can allow the user to add URLs to a setting with the `function` property set to a custom name, such as `urls_to_check` (this is not a reserved name from the section "Supported settings `function` values" below). @@ -469,7 +469,7 @@ The `params` array in the `config.json` is used to enable the user to change the { "function": "CMD", "type": "text", - "default_value":"python3 /home/pi/pialert/front/plugins/website_monitor/script.py urls={urls}", + "default_value":"python3 /app/front/plugins/website_monitor/script.py urls={urls}", "options": [], "localized": ["name", "description"], "name" : [{ @@ -483,7 +483,7 @@ The `params` array in the `config.json` is used to enable the user to change the } ``` -During script execution, the app will take the command `"python3 /home/pi/pialert/front/plugins/website_monitor/script.py urls={urls}"`, take the `{urls}` wildcard and replace it with the value from the `WEBMON_urls_to_check` setting. This is because: +During script execution, the app will take the command `"python3 /app/front/plugins/website_monitor/script.py urls={urls}"`, take the `{urls}` wildcard and replace it with the value from the `WEBMON_urls_to_check` setting. This is because: 1. The app checks the `params` entries 2. It finds `"name" : "urls"` @@ -495,9 +495,9 @@ During script execution, the app will take the command `"python3 /home/pi/pialer - let's say the setting with the code name `WEBMON_urls_to_check` contains 2 values entered by the user: - `WEBMON_urls_to_check=['https://google.com','https://duck.com']` 6. The app takes the value from `WEBMON_urls_to_check` and replaces the `{urls}` wildcard in the setting where `"function":"CMD"`, so you go from: - - `python3 /home/pi/pialert/front/plugins/website_monitor/script.py urls={urls}` + - `python3 /app/front/plugins/website_monitor/script.py urls={urls}` - to - - `python3 /home/pi/pialert/front/plugins/website_monitor/script.py urls=https://google.com,https://duck.com` + - `python3 /app/front/plugins/website_monitor/script.py urls=https://google.com,https://duck.com` Below are some general additional notes, when defining `params`: @@ -586,7 +586,7 @@ You can have any `"function": "my_custom_name"` custom name, however, the ones l | | - "always_after_scan" - run always after a scan is finished | | | - "before_name_updates" - run before device names are updated (for name discovery plugins) | | | - "on_new_device" - run when a new device is detected | -| | - "before_config_save" - run before the config is marked as saved. Useful if your plugin needs to modify the `pialert.conf` file. | +| | - "before_config_save" - run before the config is marked as saved. Useful if your plugin needs to modify the `app.conf` file. | | `RUN_SCHD` | (required if you include "schedule" in the above `RUN` function) Cron-like scheduling is used if the `RUN` setting is set to `schedule`. | | `CMD` | (required) Specifies the command that should be executed. | | `API_SQL` | (not implemented) Generates a `table_` + `code_name` + `.json` file as per [API docs](https://github.com/jokob-sk/NetAlertX/blob/main/docs/API.md). | diff --git a/front/plugins/_publisher_apprise/apprise.py b/front/plugins/_publisher_apprise/apprise.py index f8ff0842..8542c6df 100755 --- a/front/plugins/_publisher_apprise/apprise.py +++ b/front/plugins/_publisher_apprise/apprise.py @@ -9,7 +9,8 @@ import sys from datetime import datetime # Register NetAlertX directories -sys.path.extend(["/home/pi/pialert/front/plugins", "/home/pi/pialert/netalertx"]) +INSTALL_PATH="/app" +sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"]) import conf from const import confFileName diff --git a/front/plugins/_publisher_apprise/config.json b/front/plugins/_publisher_apprise/config.json index cdfb39ea..95c336f7 100755 --- a/front/plugins/_publisher_apprise/config.json +++ b/front/plugins/_publisher_apprise/config.json @@ -287,7 +287,7 @@ { "function": "CMD", "type": "readonly", - "default_value":"python3 /home/pi/pialert/front/plugins/_publisher_apprise/apprise.py", + "default_value":"python3 /app/front/plugins/_publisher_apprise/apprise.py", "options": [], "localized": ["name", "description"], "name" : [{ diff --git a/front/plugins/_publisher_email/config.json b/front/plugins/_publisher_email/config.json index 5d1e66be..f37d193f 100755 --- a/front/plugins/_publisher_email/config.json +++ b/front/plugins/_publisher_email/config.json @@ -354,7 +354,7 @@ { "function": "CMD", "type": "readonly", - "default_value": "python3 /home/pi/pialert/front/plugins/_publisher_email/email_smtp.py", + "default_value": "python3 /app/front/plugins/_publisher_email/email_smtp.py", "options": [], "localized": [ "name", diff --git a/front/plugins/_publisher_email/email_smtp.py b/front/plugins/_publisher_email/email_smtp.py index cf7131a8..a098b59c 100755 --- a/front/plugins/_publisher_email/email_smtp.py +++ b/front/plugins/_publisher_email/email_smtp.py @@ -15,7 +15,9 @@ import smtplib import socket import ssl -sys.path.extend(["/home/pi/pialert/front/plugins", "/home/pi/pialert/netalertx"]) +# Register NetAlertX directories +INSTALL_PATH="/app" +sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"]) # NetAlertX modules import conf @@ -93,7 +95,7 @@ def send(pHTML, pText): mylog('debug', [f'[{pluginName}] SMTP_REPORT_TO: {hide_email(str(get_setting_value("SMTP_REPORT_TO")))} SMTP_USER: {hide_email(str(get_setting_value("SMTP_USER")))}']) - subject, from_email, to_email, message_html, message_text = sanitize_email_content('NetAlertX Report', get_setting_value("SMTP_REPORT_FROM"), get_setting_value("SMTP_REPORT_TO"), pHTML, pText) + subject, from_email, to_email, message_html, message_text = sanitize_email_content('Net AlertX Report', get_setting_value("SMTP_REPORT_FROM"), get_setting_value("SMTP_REPORT_TO"), pHTML, pText) # Compose email msg = MIMEMultipart('alternative') diff --git a/front/plugins/_publisher_mqtt/config.json b/front/plugins/_publisher_mqtt/config.json index 3c216274..00f76a99 100755 --- a/front/plugins/_publisher_mqtt/config.json +++ b/front/plugins/_publisher_mqtt/config.json @@ -278,7 +278,7 @@ { "function": "CMD", "type": "readonly", - "default_value":"python3 /home/pi/pialert/front/plugins/_publisher_mqtt/mqtt.py devices={devices}", + "default_value":"python3 /app/front/plugins/_publisher_mqtt/mqtt.py devices={devices}", "options": [], "localized": ["name", "description"], "name" : [{ diff --git a/front/plugins/_publisher_mqtt/mqtt.py b/front/plugins/_publisher_mqtt/mqtt.py index fc205e83..ac69113f 100755 --- a/front/plugins/_publisher_mqtt/mqtt.py +++ b/front/plugins/_publisher_mqtt/mqtt.py @@ -16,7 +16,8 @@ import hashlib # Register NetAlertX directories -sys.path.extend(["/home/pi/pialert/front/plugins", "/home/pi/pialert/netalertx"]) +INSTALL_PATH="/app" +sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"]) # NetAlertX modules import conf @@ -172,8 +173,8 @@ def publish_mqtt(mqtt_client, topic, message): #------------------------------------------------------------------------------- def create_generic_device(mqtt_client): - deviceName = 'PiAlert' - deviceId = 'pialert' + deviceName = 'NetAlertX' + deviceId = 'netalertx' create_sensor(mqtt_client, deviceId, deviceName, 'sensor', 'online', 'wifi-check') create_sensor(mqtt_client, deviceId, deviceName, 'sensor', 'down', 'wifi-cancel') @@ -214,7 +215,7 @@ def publish_sensor(mqtt_client, sensorConfig): "device": { "identifiers" : [sensorConfig.deviceId+"_sensor"], - "manufacturer" : "PiAlert", + "manufacturer" : "NetAlertX", "name" : sensorConfig.deviceName }, "icon": icon @@ -288,7 +289,7 @@ def mqtt_start(db): row = get_device_stats(db) # Publish (wrap into {} and remove last ',' from above) - publish_mqtt(mqtt_client, "system-sensors/sensor/pialert/state", + publish_mqtt(mqtt_client, "system-sensors/sensor/netalertx/state", { "online": row[0], "down": row[1], diff --git a/front/plugins/_publisher_ntfy/config.json b/front/plugins/_publisher_ntfy/config.json index acd8465f..78407535 100755 --- a/front/plugins/_publisher_ntfy/config.json +++ b/front/plugins/_publisher_ntfy/config.json @@ -247,7 +247,7 @@ { "function": "CMD", "type": "readonly", - "default_value":"python3 /home/pi/pialert/front/plugins/_publisher_ntfy/ntfy.py", + "default_value":"python3 /app/front/plugins/_publisher_ntfy/ntfy.py", "options": [], "localized": ["name", "description"], "name" : [{ diff --git a/front/plugins/_publisher_ntfy/ntfy.py b/front/plugins/_publisher_ntfy/ntfy.py index 74c2742d..263b4a0e 100755 --- a/front/plugins/_publisher_ntfy/ntfy.py +++ b/front/plugins/_publisher_ntfy/ntfy.py @@ -12,7 +12,8 @@ from datetime import datetime from base64 import b64encode # Register NetAlertX directories -sys.path.extend(["/home/pi/pialert/front/plugins", "/home/pi/pialert/netalertx"]) +INSTALL_PATH="/app" +sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"]) import conf from const import confFileName diff --git a/front/plugins/_publisher_pushover/config.json b/front/plugins/_publisher_pushover/config.json index 090bfd09..eafa3b38 100755 --- a/front/plugins/_publisher_pushover/config.json +++ b/front/plugins/_publisher_pushover/config.json @@ -304,7 +304,7 @@ { "function": "CMD", "type": "readonly", - "default_value": "python3 /home/pi/pialert/front/plugins/_publisher_pushover/pushover.py", + "default_value": "python3 /app/front/plugins/_publisher_pushover/pushover.py", "options": [], "localized": [ "name", diff --git a/front/plugins/_publisher_pushover/pushover.py b/front/plugins/_publisher_pushover/pushover.py index a5482dc6..c03dd883 100755 --- a/front/plugins/_publisher_pushover/pushover.py +++ b/front/plugins/_publisher_pushover/pushover.py @@ -6,7 +6,8 @@ import json import requests # Register NetAlertX directories -sys.path.extend(["/home/pi/pialert/front/plugins", "/home/pi/pialert/netalertx"]) +INSTALL_PATH="/app" +sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"]) from plugin_helper import Plugin_Objects, handleEmpty # noqa: E402 from logger import mylog # noqa: E402 diff --git a/front/plugins/_publisher_pushsafer/config.json b/front/plugins/_publisher_pushsafer/config.json index 030762d9..0beda2e9 100755 --- a/front/plugins/_publisher_pushsafer/config.json +++ b/front/plugins/_publisher_pushsafer/config.json @@ -247,7 +247,7 @@ { "function": "CMD", "type": "readonly", - "default_value":"python3 /home/pi/pialert/front/plugins/_publisher_pushsafer/pushsafer.py", + "default_value":"python3 /app/front/plugins/_publisher_pushsafer/pushsafer.py", "options": [], "localized": ["name", "description"], "name" : [{ diff --git a/front/plugins/_publisher_pushsafer/pushsafer.py b/front/plugins/_publisher_pushsafer/pushsafer.py index 177de6e6..f99312f6 100755 --- a/front/plugins/_publisher_pushsafer/pushsafer.py +++ b/front/plugins/_publisher_pushsafer/pushsafer.py @@ -12,7 +12,8 @@ from datetime import datetime from base64 import b64encode # Register NetAlertX directories -sys.path.extend(["/home/pi/pialert/front/plugins", "/home/pi/pialert/netalertx"]) +INSTALL_PATH="/app" +sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"]) import conf from const import confFileName diff --git a/front/plugins/_publisher_webhook/config.json b/front/plugins/_publisher_webhook/config.json index 1f109d96..17a319fc 100755 --- a/front/plugins/_publisher_webhook/config.json +++ b/front/plugins/_publisher_webhook/config.json @@ -247,7 +247,7 @@ { "function": "CMD", "type": "readonly", - "default_value":"python3 /home/pi/pialert/front/plugins/_publisher_webhook/webhook.py", + "default_value":"python3 /app/front/plugins/_publisher_webhook/webhook.py", "options": [], "localized": ["name", "description"], "name" : [{ diff --git a/front/plugins/_publisher_webhook/webhook.py b/front/plugins/_publisher_webhook/webhook.py index 5ccf519b..8b995ae7 100755 --- a/front/plugins/_publisher_webhook/webhook.py +++ b/front/plugins/_publisher_webhook/webhook.py @@ -14,7 +14,8 @@ import hashlib import hmac # Register NetAlertX directories -sys.path.extend(["/home/pi/pialert/front/plugins", "/home/pi/pialert/netalertx"]) +INSTALL_PATH="/app" +sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"]) import conf diff --git a/front/plugins/arp_scan/config.json b/front/plugins/arp_scan/config.json index 5829b9f0..8ec69c07 100755 --- a/front/plugins/arp_scan/config.json +++ b/front/plugins/arp_scan/config.json @@ -121,7 +121,7 @@ { "function": "CMD", "type": "readonly", - "default_value": "python3 /home/pi/pialert/front/plugins/arp_scan/script.py userSubnets={subnets}", + "default_value": "python3 /app/front/plugins/arp_scan/script.py userSubnets={subnets}", "options": [], "localized": [ "name", diff --git a/front/plugins/arp_scan/script.py b/front/plugins/arp_scan/script.py index 2562e0d2..139df1e8 100755 --- a/front/plugins/arp_scan/script.py +++ b/front/plugins/arp_scan/script.py @@ -9,10 +9,10 @@ import base64 import subprocess from time import strftime -sys.path.append("/home/pi/pialert/front/plugins") -sys.path.append('/home/pi/pialert/netalertx') +# Register NetAlertX directories +INSTALL_PATH="/app" +sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"]) -# Register NetAlertX modules NetAlertX directories from database import DB from plugin_helper import Plugin_Object, Plugin_Objects, handleEmpty from logger import mylog, append_line_to_file diff --git a/front/plugins/csv_backup/config.json b/front/plugins/csv_backup/config.json index 14aa391d..29af29da 100755 --- a/front/plugins/csv_backup/config.json +++ b/front/plugins/csv_backup/config.json @@ -89,7 +89,7 @@ { "function": "CMD", "type": "readonly", - "default_value": "python3 /home/pi/pialert/front/plugins/csv_backup/script.py overwrite={overwrite} location={location}", + "default_value": "python3 /app/front/plugins/csv_backup/script.py overwrite={overwrite} location={location}", "options": [], "localized": ["name", "description"], "name": [ @@ -221,7 +221,7 @@ { "function": "location", "type": "text", - "default_value":"/home/pi/pialert/config", + "default_value":"/app/config", "options": [], "localized": ["name", "description"], "name" : [{ @@ -238,15 +238,15 @@ }], "description": [{ "language_code":"en_us", - "string" : "Where the devices.csv file should be saved. For example /home/pi/pialert/config." + "string" : "Where the devices.csv file should be saved. For example /app/config." }, { "language_code":"es_es", - "string" : "Donde se debe guardar el archivo devices.csv. Por ejemplo /home/pi/pialert/config." + "string" : "Donde se debe guardar el archivo devices.csv. Por ejemplo /app/config." }, { "language_code":"de_de", - "string" : "Wo die Datei devices.csv gespeichert werden soll. Zum Beispiel /home/pi/pialert/config." + "string" : "Wo die Datei devices.csv gespeichert werden soll. Zum Beispiel /app/config." }] } ], diff --git a/front/plugins/csv_backup/script.py b/front/plugins/csv_backup/script.py index 30a05a55..a4b8be21 100755 --- a/front/plugins/csv_backup/script.py +++ b/front/plugins/csv_backup/script.py @@ -10,8 +10,9 @@ import sqlite3 from io import StringIO from datetime import datetime -sys.path.append("/home/pi/pialert/front/plugins") -sys.path.append('/home/pi/pialert/netalertx') +# Register NetAlertX directories +INSTALL_PATH="/app" +sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"]) from plugin_helper import Plugin_Object, Plugin_Objects, decodeBase64 from logger import mylog, append_line_to_file diff --git a/front/plugins/db_cleanup/config.json b/front/plugins/db_cleanup/config.json index f022ac17..06848a57 100755 --- a/front/plugins/db_cleanup/config.json +++ b/front/plugins/db_cleanup/config.json @@ -75,7 +75,7 @@ { "function": "CMD", "type": "readonly", - "default_value": "python3 /home/pi/pialert/front/plugins/db_cleanup/script.py pluginskeephistory={pluginskeephistory} hourstokeepnewdevice={hourstokeepnewdevice} daystokeepevents={daystokeepevents} pholuskeepdays={pholuskeepdays}", + "default_value": "python3 /app/front/plugins/db_cleanup/script.py pluginskeephistory={pluginskeephistory} hourstokeepnewdevice={hourstokeepnewdevice} daystokeepevents={daystokeepevents} pholuskeepdays={pholuskeepdays}", "options": [], "localized": ["name", "description"], "name": [ diff --git a/front/plugins/db_cleanup/script.py b/front/plugins/db_cleanup/script.py index f1593491..2e32c630 100755 --- a/front/plugins/db_cleanup/script.py +++ b/front/plugins/db_cleanup/script.py @@ -10,8 +10,9 @@ import sqlite3 from io import StringIO from datetime import datetime -sys.path.append("/home/pi/pialert/front/plugins") -sys.path.append('/home/pi/pialert/netalertx') +# Register NetAlertX directories +INSTALL_PATH="/app" +sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"]) from plugin_helper import Plugin_Object, Plugin_Objects, decodeBase64 from logger import mylog, append_line_to_file diff --git a/front/plugins/ddns_update/config.json b/front/plugins/ddns_update/config.json index 8c25ab63..1a25dbf5 100755 --- a/front/plugins/ddns_update/config.json +++ b/front/plugins/ddns_update/config.json @@ -122,7 +122,7 @@ { "function": "CMD", "type": "readonly", - "default_value": "python3 /home/pi/pialert/front/plugins/ddns_update/script.py prev_ip={prev_ip} DDNS_UPDATE_URL={DDNS_UPDATE_URL} DDNS_USER={DDNS_USER} DDNS_PASSWORD={DDNS_PASSWORD} DDNS_DOMAIN={DDNS_DOMAIN} ", + "default_value": "python3 /app/front/plugins/ddns_update/script.py prev_ip={prev_ip} DDNS_UPDATE_URL={DDNS_UPDATE_URL} DDNS_USER={DDNS_USER} DDNS_PASSWORD={DDNS_PASSWORD} DDNS_DOMAIN={DDNS_DOMAIN} ", "options": [], "localized": [ "name", diff --git a/front/plugins/ddns_update/script.py b/front/plugins/ddns_update/script.py index afb55ffa..f216a6bb 100755 --- a/front/plugins/ddns_update/script.py +++ b/front/plugins/ddns_update/script.py @@ -13,8 +13,9 @@ import sqlite3 from io import StringIO from datetime import datetime -sys.path.append("/home/pi/pialert/front/plugins") -sys.path.append('/home/pi/pialert/netalertx') +# Register NetAlertX directories +INSTALL_PATH="/app" +sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"]) from plugin_helper import Plugin_Object, Plugin_Objects, decodeBase64 from logger import mylog, append_line_to_file diff --git a/front/plugins/dhcp_leases/config.json b/front/plugins/dhcp_leases/config.json index d67d451b..2efdb069 100755 --- a/front/plugins/dhcp_leases/config.json +++ b/front/plugins/dhcp_leases/config.json @@ -493,7 +493,7 @@ { "function": "CMD", "type": "text", - "default_value": "python3 /home/pi/pialert/front/plugins/dhcp_leases/script.py paths={paths}", + "default_value": "python3 /app/front/plugins/dhcp_leases/script.py paths={paths}", "options": [], "localized": [ "name", diff --git a/front/plugins/dhcp_leases/script.py b/front/plugins/dhcp_leases/script.py index 219de4af..26e6b1e5 100755 --- a/front/plugins/dhcp_leases/script.py +++ b/front/plugins/dhcp_leases/script.py @@ -8,8 +8,9 @@ import os import sys import chardet -sys.path.append("/home/pi/pialert/front/plugins") -sys.path.append('/home/pi/pialert/netalertx') +# Register NetAlertX directories +INSTALL_PATH="/app" +sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"]) from plugin_helper import Plugin_Object, Plugin_Objects, handleEmpty, is_mac from logger import mylog diff --git a/front/plugins/dhcp_servers/config.json b/front/plugins/dhcp_servers/config.json index 759f256b..8af21458 100755 --- a/front/plugins/dhcp_servers/config.json +++ b/front/plugins/dhcp_servers/config.json @@ -300,7 +300,7 @@ { "function": "CMD", "type": "text", - "default_value":"python3 /home/pi/pialert/front/plugins/dhcp_servers/script.py", + "default_value":"python3 /app/front/plugins/dhcp_servers/script.py", "options": [], "localized": ["name", "description"], "name" : [{ diff --git a/front/plugins/dhcp_servers/script.py b/front/plugins/dhcp_servers/script.py index c80dc964..e2bb29b1 100755 --- a/front/plugins/dhcp_servers/script.py +++ b/front/plugins/dhcp_servers/script.py @@ -6,8 +6,9 @@ from datetime import datetime import sys -sys.path.append("/home/pi/pialert/front/plugins") -sys.path.append('/home/pi/pialert/netalertx') +# Register NetAlertX directories +INSTALL_PATH="/app" +sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"]) from plugin_helper import Plugin_Objects, Plugin_Object from logger import mylog diff --git a/front/plugins/internet_ip/config.json b/front/plugins/internet_ip/config.json index 754d50ba..496d8b46 100755 --- a/front/plugins/internet_ip/config.json +++ b/front/plugins/internet_ip/config.json @@ -109,7 +109,7 @@ { "function": "CMD", "type": "readonly", - "default_value": "python3 /home/pi/pialert/front/plugins/internet_ip/script.py prev_ip={prev_ip} INTRNT_DIG_GET_IP_ARG={INTRNT_DIG_GET_IP_ARG}", + "default_value": "python3 /app/front/plugins/internet_ip/script.py prev_ip={prev_ip} INTRNT_DIG_GET_IP_ARG={INTRNT_DIG_GET_IP_ARG}", "options": [], "localized": [ "name", diff --git a/front/plugins/internet_ip/script.py b/front/plugins/internet_ip/script.py index a9411fe6..d02e5763 100755 --- a/front/plugins/internet_ip/script.py +++ b/front/plugins/internet_ip/script.py @@ -13,8 +13,9 @@ import sqlite3 from io import StringIO from datetime import datetime -sys.path.append("/home/pi/pialert/front/plugins") -sys.path.append('/home/pi/pialert/netalertx') +# Register NetAlertX directories +INSTALL_PATH="/app" +sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"]) from plugin_helper import Plugin_Object, Plugin_Objects, decodeBase64 from logger import mylog, append_line_to_file diff --git a/front/plugins/internet_speedtest/config.json b/front/plugins/internet_speedtest/config.json index f1462618..74dc4832 100755 --- a/front/plugins/internet_speedtest/config.json +++ b/front/plugins/internet_speedtest/config.json @@ -449,7 +449,7 @@ { "function": "CMD", "type": "readonly", - "default_value": "python3 /home/pi/pialert/front/plugins/internet_speedtest/script.py", + "default_value": "python3 /app/front/plugins/internet_speedtest/script.py", "options": [], "localized": [ "name", diff --git a/front/plugins/internet_speedtest/script.py b/front/plugins/internet_speedtest/script.py index 35246139..7029edde 100755 --- a/front/plugins/internet_speedtest/script.py +++ b/front/plugins/internet_speedtest/script.py @@ -8,7 +8,8 @@ from datetime import datetime import speedtest # Register NetAlertX directories -sys.path.extend(["/home/pi/pialert/front/plugins", "/home/pi/pialert/netalertx"]) +INSTALL_PATH="/app" +sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"]) from plugin_helper import Plugin_Objects from logger import mylog, append_line_to_file diff --git a/front/plugins/maintenance/README.md b/front/plugins/maintenance/README.md index e19cafc8..b7e46290 100755 --- a/front/plugins/maintenance/README.md +++ b/front/plugins/maintenance/README.md @@ -2,7 +2,7 @@ A plugin responsible for general maintenance tasks. These currently include: -- pialert.log cleanup +- app.log cleanup ### Usage diff --git a/front/plugins/maintenance/config.json b/front/plugins/maintenance/config.json index c4981453..c7ed7cec 100755 --- a/front/plugins/maintenance/config.json +++ b/front/plugins/maintenance/config.json @@ -54,7 +54,7 @@ { "function": "CMD", "type": "readonly", - "default_value": "python3 /home/pi/pialert/front/plugins/maintenance/maintenance.py", + "default_value": "python3 /app/front/plugins/maintenance/maintenance.py", "options": [], "localized": ["name", "description"], "name": [ @@ -164,7 +164,7 @@ }], "description": [{ "language_code":"en_us", - "string" : "How many last pialert.log lines to keep. If LOG_LEVEL is set to debug the app generates about 10000 lines per hour, so when debugging an issue the recommended setting should cover the bug occurence timeframe. For example for a bug with a 3 day periodical appearence the value 1000000 should be sufficient. Setting this value to 1000000 generates approximatelly a 50MB pialert.log file. Set to 0 to disable log purging." + "string" : "How many last app.log lines to keep. If LOG_LEVEL is set to debug the app generates about 10000 lines per hour, so when debugging an issue the recommended setting should cover the bug occurence timeframe. For example for a bug with a 3 day periodical appearence the value 1000000 should be sufficient. Setting this value to 1000000 generates approximatelly a 50MB app.log file. Set to 0 to disable log purging." }] } ], diff --git a/front/plugins/maintenance/maintenance.py b/front/plugins/maintenance/maintenance.py index 4743c44f..24d7fe8a 100755 --- a/front/plugins/maintenance/maintenance.py +++ b/front/plugins/maintenance/maintenance.py @@ -11,9 +11,10 @@ from io import StringIO from datetime import datetime from collections import deque -sys.path.extend(["/home/pi/pialert/front/plugins", "/home/pi/pialert/netalertx"]) +# Register NetAlertX directories +INSTALL_PATH="/app" +sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"]) -# Register NetAlertX modules NetAlertX directories from plugin_helper import Plugin_Object, Plugin_Objects, decodeBase64 from logger import mylog, append_line_to_file from helper import timeNowTZ, get_setting_value @@ -37,7 +38,7 @@ def main(): mylog('verbose', [f'[{pluginName}] Cleaning file']) - logFile = logPath + "/pialert.log" + logFile = logPath + "/app.log" # Using a deque to efficiently keep the last N lines lines_to_keep = deque(maxlen=MAINT_LOG_LENGTH) diff --git a/front/plugins/nmap_scan/config.json b/front/plugins/nmap_scan/config.json index 3444d6a8..f8fe7a2c 100755 --- a/front/plugins/nmap_scan/config.json +++ b/front/plugins/nmap_scan/config.json @@ -345,7 +345,7 @@ { "function": "CMD", "type": "text", - "default_value":"python3 /home/pi/pialert/front/plugins/nmap_scan/script.py ips={ips} macs={macs} timeout={timeout} args={args}", + "default_value":"python3 /app/front/plugins/nmap_scan/script.py ips={ips} macs={macs} timeout={timeout} args={args}", "options": [], "localized": ["name", "description"], "name" : [{ diff --git a/front/plugins/nmap_scan/script.py b/front/plugins/nmap_scan/script.py index 141d91e6..5db4306c 100755 --- a/front/plugins/nmap_scan/script.py +++ b/front/plugins/nmap_scan/script.py @@ -9,8 +9,9 @@ import base64 import subprocess from time import strftime -sys.path.append("/home/pi/pialert/front/plugins") -sys.path.append('/home/pi/pialert/netalertx') +# Register NetAlertX directories +INSTALL_PATH="/app" +sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"]) from plugin_helper import Plugin_Object, Plugin_Objects, decodeBase64 from logger import mylog, append_line_to_file @@ -133,7 +134,7 @@ def performNmapScan(deviceIPs, deviceMACs, timeoutSec, args): # regular logging for line in newLines: - append_line_to_file (logPath + '/pialert_nmap.log', line +'\n') + append_line_to_file (logPath + '/app_nmap.log', line +'\n') index = 0 diff --git a/front/plugins/nslookup_scan/config.json b/front/plugins/nslookup_scan/config.json index ba0fad8c..e9641408 100755 --- a/front/plugins/nslookup_scan/config.json +++ b/front/plugins/nslookup_scan/config.json @@ -60,7 +60,7 @@ { "function": "CMD", "type": "readonly", - "default_value": "python3 /home/pi/pialert/front/plugins/nslookup_scan/nslookup.py", + "default_value": "python3 /app/front/plugins/nslookup_scan/nslookup.py", "options": [], "localized": ["name", "description"], "name": [ diff --git a/front/plugins/nslookup_scan/nslookup.py b/front/plugins/nslookup_scan/nslookup.py index 7637a3ea..68649cfc 100755 --- a/front/plugins/nslookup_scan/nslookup.py +++ b/front/plugins/nslookup_scan/nslookup.py @@ -14,8 +14,9 @@ import re from io import StringIO from datetime import datetime -sys.path.append("/home/pi/pialert/front/plugins") -sys.path.append('/home/pi/pialert/netalertx') +# Register NetAlertX directories +INSTALL_PATH="/app" +sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"]) from plugin_helper import Plugin_Object, Plugin_Objects, decodeBase64 from logger import mylog, append_line_to_file diff --git a/front/plugins/pholus_scan/config.json b/front/plugins/pholus_scan/config.json index df3ed439..2c726eea 100755 --- a/front/plugins/pholus_scan/config.json +++ b/front/plugins/pholus_scan/config.json @@ -106,7 +106,7 @@ { "function": "CMD", "type": "readonly", - "default_value": "python3 /home/pi/pialert/front/plugins/pholus_scan/script.py userSubnets={subnets} timeoutSec={timeout}", + "default_value": "python3 /app/front/plugins/pholus_scan/script.py userSubnets={subnets} timeoutSec={timeout}", "options": [], "localized": [ "name", @@ -219,7 +219,7 @@ }, { "language_code": "es_es", - "string": "Cuántos días de entradas de escaneo de Pholus deben conservarse (globalmente, ¡no específico del dispositivo!). El archivo pialert_pholus.log no se modifica. Introduzca 0 para desactivar." + "string": "Cuántos días de entradas de escaneo de Pholus deben conservarse (globalmente, ¡no específico del dispositivo!). Introduzca 0 para desactivar." } ] }, diff --git a/front/plugins/pholus_scan/pholus/pholus3.py b/front/plugins/pholus_scan/pholus/pholus3.py index 12272adc..05f3bd53 100755 --- a/front/plugins/pholus_scan/pholus/pholus3.py +++ b/front/plugins/pholus_scan/pholus/pholus3.py @@ -18,7 +18,7 @@ from scapy.utils import PcapWriter sys.setrecursionlimit(30000) logging.getLogger("scapy.runtime").setLevel(logging.ERROR)#supress Scapy warnings` -logPath = '/home/pi/pialert/front/log' +logPath = '/app/front/log' # DEBUG isDebug = False @@ -43,13 +43,13 @@ def write_file (pPath, pText): file.close() # Empty the last run log file -write_file(logPath + "/pialert_pholus_lastrun.log", "") +write_file(logPath + "/pholus_lastrun.log", "") def file_print(*args): result = '' - file = open(logPath + "/pialert_pholus_lastrun.log", "a") + file = open(logPath + "/pholus_lastrun.log", "a") for arg in args: result += str(arg) print(result) @@ -57,7 +57,7 @@ def file_print(*args): file.close() # Empty the last run log file -write_file(logPath + "/pialert_pholus_subp_pr.log", "") +write_file(logPath + "/pholus_subp_pr.log", "") # For separate logging of the multiprocess subprocess def file_print_pr(*args): @@ -66,7 +66,7 @@ def file_print_pr(*args): result = '' - file = open(logPath + "/pialert_pholus_subp_pr.log", "a") + file = open(logPath + "/pholus_subp_pr.log", "a") for arg in args: result += str(arg) print(result) diff --git a/front/plugins/pholus_scan/script.py b/front/plugins/pholus_scan/script.py index a722d78d..2c7d4171 100755 --- a/front/plugins/pholus_scan/script.py +++ b/front/plugins/pholus_scan/script.py @@ -10,8 +10,9 @@ import subprocess from time import strftime -sys.path.append("/home/pi/pialert/front/plugins") -sys.path.append('/home/pi/pialert/netalertx') +# Register NetAlertX directories +INSTALL_PATH="/app" +sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"]) from logger import mylog from plugin_helper import Plugin_Object, Plugin_Objects @@ -135,7 +136,7 @@ def execute_pholus_on_interface(interface, timeoutSec, mask): # the scan always lasts 2x as long, so the desired user time from settings needs to be halved adjustedTimeout = str(round(int(timeoutSec) / 2, 0)) - # python3 -m trace --trace /home/pi/pialert/pholus/pholus3.py eth1 -rdns_scanning 192.168.1.0/24 -stimeout 600 + # python3 -m trace --trace /app/pholus/pholus3.py eth1 -rdns_scanning 192.168.1.0/24 -stimeout 600 pholus_args = ['python3', fullPholusPath, interface, "-rdns_scanning", mask, "-stimeout", adjustedTimeout] # Execute command @@ -157,7 +158,7 @@ def execute_pholus_on_interface(interface, timeoutSec, mask): mylog('verbose', [f'[{pluginName}] Scan: Pholus SUCCESS']) # check the last run output - f = open(logPath + '/pialert_pholus_lastrun.log', 'r+') + f = open(logPath + '/pholus_lastrun.log', 'r+') newLines = f.read().split('\n') f.close() diff --git a/front/plugins/plugin_helper.py b/front/plugins/plugin_helper.py index ebe17cfa..501ea23a 100755 --- a/front/plugins/plugin_helper.py +++ b/front/plugins/plugin_helper.py @@ -5,8 +5,10 @@ import re import base64 from datetime import datetime -sys.path.append("/home/pi/pialert/front/plugins") -sys.path.append('/home/pi/pialert/netalertx') +INSTALL_PATH = "/app" + +sys.path.append(f"{INSTALL_PATH}/front/plugins") +sys.path.append(f'{INSTALL_PATH}/server') from logger import mylog from const import confFileName @@ -18,7 +20,7 @@ def read_config_file(): config_dir[key] """ - filename = '/home/pi/pialert/config/' + confFileName + filename = f'{INSTALL_PATH}/config/' + confFileName print('[plugin_helper] reading config file') @@ -31,8 +33,8 @@ def read_config_file(): return confDict -pialertConfigFile = read_config_file() -timeZoneSetting = pialertConfigFile['TIMEZONE'] +configFile = read_config_file() +timeZoneSetting = configFile['TIMEZONE'] timeZone = pytz.timezone(timeZoneSetting) # ------------------------------------------------------------------- diff --git a/front/plugins/set_password/README.md b/front/plugins/set_password/README.md index 2b96fa50..5f68c901 100755 --- a/front/plugins/set_password/README.md +++ b/front/plugins/set_password/README.md @@ -8,8 +8,8 @@ A simple script-based plugin for setting the password. ### Notes -- The plugin is executed on the `RUN` type `before_config_save` so it's possible to update the `pialert.conf` file before the data is loaded into the app. -- The executed command is stored in the `CMD` setting: `/home/pi/pialert/back/pialert-cli set_password {password}` +- The plugin is executed on the `RUN` type `before_config_save` so it's possible to update the `app.conf` file before the data is loaded into the app. +- The executed command is stored in the `CMD` setting: `/app/back/pialert-cli set_password {password}` - The `{password}` parameter is replaced via the parameter and setting below: ```json @@ -39,7 +39,7 @@ A simple script-based plugin for setting the password. "description": [ { "language_code": "en_us", - "string": "The default password is 123456. To change the password run /home/pi/pialert/back/pialert-cli set_password {password} in the container" + "string": "The default password is 123456. To change the password run /app/back/pialert-cli set_password {password} in the container" } ] } diff --git a/front/plugins/set_password/config.json b/front/plugins/set_password/config.json index a4b7c2cd..bc401aa1 100755 --- a/front/plugins/set_password/config.json +++ b/front/plugins/set_password/config.json @@ -68,7 +68,7 @@ { "function": "CMD", "type": "readonly", - "default_value":"/home/pi/pialert/back/pialert-cli set_password {password}", + "default_value":"/app/back/pialert-cli set_password {password}", "options": [], "localized": ["name", "description"], "name" : [{ @@ -108,11 +108,11 @@ "description": [ { "language_code": "en_us", - "string": "The default password is 123456. To change it, you can either use this plugin (follow the instructions in the SETPWD_RUN setting) or run /home/pi/pialert/back/pialert-cli set_password {password} in the container." + "string": "The default password is 123456. To change it, you can either use this plugin (follow the instructions in the SETPWD_RUN setting) or run /app/back/pialert-cli set_password {password} in the container." }, { "language_code": "es_es", - "string": "La contraseña predeterminada es 123456. Para cambiar la contraseña, ejecute /home/pi/pialert/back/pialert-cli set_password {password} en el contenedor" + "string": "La contraseña predeterminada es 123456. Para cambiar la contraseña, ejecute /app/back/pialert-cli set_password {password} en el contenedor" } ] } diff --git a/front/plugins/snmp_discovery/config.json b/front/plugins/snmp_discovery/config.json index 8ea925ef..8349d297 100755 --- a/front/plugins/snmp_discovery/config.json +++ b/front/plugins/snmp_discovery/config.json @@ -332,7 +332,7 @@ { "function": "CMD", "type": "text", - "default_value":"python3 /home/pi/pialert/front/plugins/snmp_discovery/script.py routers={s-quote}{routers}{s-quote}", + "default_value":"python3 /app/front/plugins/snmp_discovery/script.py routers={s-quote}{routers}{s-quote}", "options": [], "localized": ["name", "description"], "name" : [{ diff --git a/front/plugins/snmp_discovery/script.py b/front/plugins/snmp_discovery/script.py index c4303ed2..fa9d7066 100755 --- a/front/plugins/snmp_discovery/script.py +++ b/front/plugins/snmp_discovery/script.py @@ -1,8 +1,5 @@ #!/usr/bin/env python -# Example call -# python3 /home/pi/pialert/front/plugins/snmp_discovery/script.py routers='snmpwalk -v 2c -c public -OXsq 192.168.1.1 .1.3.6.1.2.1.3.1.1.2' - from __future__ import unicode_literals import pathlib import subprocess @@ -10,8 +7,9 @@ import argparse import os import sys -sys.path.append("/home/pi/pialert/front/plugins") -sys.path.append('/home/pi/pialert/netalertx') +# Register NetAlertX directories +INSTALL_PATH="/app" +sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"]) from plugin_helper import Plugin_Object, Plugin_Objects, decodeBase64, handleEmpty from logger import mylog diff --git a/front/plugins/undiscoverables/config.json b/front/plugins/undiscoverables/config.json index bb6f7ca7..c8110b37 100755 --- a/front/plugins/undiscoverables/config.json +++ b/front/plugins/undiscoverables/config.json @@ -110,7 +110,7 @@ { "function": "CMD", "type": "text", - "default_value": "python3 /home/pi/pialert/front/plugins/undiscoverables/script.py devices={devices}", + "default_value": "python3 /app/front/plugins/undiscoverables/script.py devices={devices}", "options": [], "localized": [ "name", diff --git a/front/plugins/undiscoverables/script.py b/front/plugins/undiscoverables/script.py index bb0b32f3..cd6c6e46 100755 --- a/front/plugins/undiscoverables/script.py +++ b/front/plugins/undiscoverables/script.py @@ -7,8 +7,9 @@ import argparse import sys import hashlib -sys.path.append("/home/pi/pialert/front/plugins") -sys.path.append('/home/pi/pialert/netalertx') +# Register NetAlertX directories +INSTALL_PATH="/app" +sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"]) from plugin_helper import Plugin_Object, Plugin_Objects, decodeBase64 from logger import mylog, append_line_to_file diff --git a/front/plugins/unifi_import/config.json b/front/plugins/unifi_import/config.json index f4654b1a..cca7d88b 100755 --- a/front/plugins/unifi_import/config.json +++ b/front/plugins/unifi_import/config.json @@ -521,7 +521,7 @@ "type": "text.select" }, { - "default_value": "python3 /home/pi/pialert/front/plugins/unifi_import/script.py username={username} password={password} host={host} sites={sites} port={port} verifyssl={verifyssl} version={version} fullimport={fullimport}", + "default_value": "python3 /app/front/plugins/unifi_import/script.py username={username} password={password} host={host} sites={sites} port={port} verifyssl={verifyssl} version={version} fullimport={fullimport}", "description": [ { "language_code": "en_us", diff --git a/front/plugins/unifi_import/script.py b/front/plugins/unifi_import/script.py index 62e5e824..7729a3be 100755 --- a/front/plugins/unifi_import/script.py +++ b/front/plugins/unifi_import/script.py @@ -1,10 +1,6 @@ #!/usr/bin/env python # Inspired by https://github.com/stevehoek/Pi.Alert -# Example call -# python3 /home/pi/pialert/front/plugins/unifi_import/script.py username=pialert password=passw0rd host=192.168.1.1 site=default protocol=https port=443 verifyssl=false version='UDMP-unifiOS' -# python3 /home/pi/pialert/front/plugins/unifi_import/script.py username=pialert password=passw0rd host=192.168.1.1 sites=sdefault port=8443 verifyssl=false version=v5 - from __future__ import unicode_literals from time import strftime import argparse @@ -18,9 +14,9 @@ from requests import Request, Session, packages from requests.packages.urllib3.exceptions import InsecureRequestWarning from pyunifi.controller import Controller -# Add your paths here -sys.path.append("/home/pi/pialert/front/plugins") -sys.path.append('/home/pi/pialert/netalertx') +# Register NetAlertX directories +INSTALL_PATH="/app" +sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"]) from plugin_helper import Plugin_Object, Plugin_Objects from logger import mylog diff --git a/front/plugins/vendor_update/config.json b/front/plugins/vendor_update/config.json index 465d29c2..cdd15f72 100755 --- a/front/plugins/vendor_update/config.json +++ b/front/plugins/vendor_update/config.json @@ -87,7 +87,7 @@ { "function": "CMD", "type": "readonly", - "default_value": "python3 /home/pi/pialert/front/plugins/vendor_update/script.py", + "default_value": "python3 /app/front/plugins/vendor_update/script.py", "options": [], "localized": [ "name", diff --git a/front/plugins/vendor_update/script.py b/front/plugins/vendor_update/script.py index 51f9179c..41d61d4f 100755 --- a/front/plugins/vendor_update/script.py +++ b/front/plugins/vendor_update/script.py @@ -11,8 +11,9 @@ import sqlite3 from io import StringIO from datetime import datetime -sys.path.append("/home/pi/pialert/front/plugins") -sys.path.append('/home/pi/pialert/netalertx') +# Register NetAlertX directories +INSTALL_PATH="/app" +sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"]) from plugin_helper import Plugin_Object, Plugin_Objects, decodeBase64, handleEmpty from logger import mylog, append_line_to_file diff --git a/front/plugins/website_monitor/config.json b/front/plugins/website_monitor/config.json index 5d009952..35117950 100755 --- a/front/plugins/website_monitor/config.json +++ b/front/plugins/website_monitor/config.json @@ -335,7 +335,7 @@ { "function": "CMD", "type": "text", - "default_value":"python3 /home/pi/pialert/front/plugins/website_monitor/script.py urls={urls}", + "default_value":"python3 /app/front/plugins/website_monitor/script.py urls={urls}", "options": [], "localized": ["name", "description"], "name" : [{ diff --git a/front/plugins/website_monitor/script.py b/front/plugins/website_monitor/script.py index 0d5efacc..5d809698 100755 --- a/front/plugins/website_monitor/script.py +++ b/front/plugins/website_monitor/script.py @@ -1,8 +1,6 @@ #!/usr/bin/env python # Based on the work of https://github.com/leiweibau/Pi.Alert -# Example call -# python3 /home/pi/pialert/front/plugins/website_monitor/script.py urls=http://google.com,http://bing.com import argparse import requests import pathlib @@ -10,7 +8,9 @@ import sys import os from requests.packages.urllib3.exceptions import InsecureRequestWarning -sys.path.extend(["/home/pi/pialert/front/plugins", "/home/pi/pialert/netalertx"]) +# Register NetAlertX directories +INSTALL_PATH="/app" +sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"]) from plugin_helper import Plugin_Objects from datetime import datetime diff --git a/front/settings.php b/front/settings.php index c7cab866..40a1a886 100755 --- a/front/settings.php +++ b/front/settings.php @@ -9,8 +9,8 @@ require 'php/templates/header.php'; ini_set ('max_execution_time','30'); // check permissions -$dbPath = "../db/pialert.db"; -$confPath = "../config/pialert.conf"; +$dbPath = "../db/app.db"; +$confPath = "../config/app.conf"; checkPermissions([$dbPath, $confPath]); diff --git a/install/index.html b/install/index.html index 1db50a9c..71c48272 100755 --- a/install/index.html +++ b/install/index.html @@ -7,5 +7,5 @@ # Puche 2021 GNU GPLv3 #--------------------------------------------------------------------------- --> - + diff --git a/install/install.debian.sh b/install/install.debian.sh index bb6fab50..548ffd38 100755 --- a/install/install.debian.sh +++ b/install/install.debian.sh @@ -8,7 +8,7 @@ echo "[INSTALL] Run install.debian.sh" echo "---------------------------------------------------------" # Set environment variables -INSTALL_DIR=/home/pi # Specify the installation directory here +INSTALL_DIR=/app # Specify the installation directory here # Check if script is run as root if [[ $EUID -ne 0 ]]; then @@ -24,15 +24,15 @@ apt-get install sudo -y apt-get install -y git # Clean the directory -rm -R $INSTALL_DIR/pialert +rm -R $INSTALL_DIR/ # Clone the application repository -git clone https://github.com/jokob-sk/NetAlertX "$INSTALL_DIR/pialert" +git clone https://github.com/jokob-sk/NetAlertX "$INSTALL_DIR/" # Check for buildtimestamp.txt existence, otherwise create it -if [ ! -f $INSTALL_DIR/pialert/front/buildtimestamp.txt ]; then - date +%s > $INSTALL_DIR/pialert/front/buildtimestamp.txt +if [ ! -f $INSTALL_DIR/front/buildtimestamp.txt ]; then + date +%s > $INSTALL_DIR/front/buildtimestamp.txt fi # Start NetAlertX -"$INSTALL_DIR/pialert/install/start.debian.sh" +"$INSTALL_DIR/install/start.debian.sh" diff --git a/install/netalertx.debian.conf b/install/netalertx.debian.conf index 81134d52..537675ad 100755 --- a/install/netalertx.debian.conf +++ b/install/netalertx.debian.conf @@ -1,10 +1,10 @@ server { listen 20211 default_server; - root /var/www/html/pialert; + root /var/www/html/app; index index.php; - #rewrite /pialert/(.*) / permanent; - add_header X-Forwarded-Prefix "/pialert" always; - proxy_set_header X-Forwarded-Prefix "/pialert"; + #rewrite /app/(.*) / permanent; + add_header X-Forwarded-Prefix "/app" always; + proxy_set_header X-Forwarded-Prefix "/app"; location ~* \.php$ { # Set Cache-Control header to prevent caching on the first load diff --git a/install/netalertx.template.conf b/install/netalertx.template.conf index e2d526a1..08c858a4 100755 --- a/install/netalertx.template.conf +++ b/install/netalertx.template.conf @@ -1,9 +1,9 @@ server { listen ${LISTEN_ADDR}:${PORT} default_server; - root ${INSTALL_DIR}/pialert/front; + root ${INSTALL_DIR}/front; index index.php; - add_header X-Forwarded-Prefix "/pialert" always; - proxy_set_header X-Forwarded-Prefix "/pialert"; + add_header X-Forwarded-Prefix "/app" always; + proxy_set_header X-Forwarded-Prefix "/app"; location ~* \.php$ { # Set Cache-Control header to prevent caching on the first load diff --git a/install/start.debian.sh b/install/start.debian.sh index 84e77b3a..961f7df9 100755 --- a/install/start.debian.sh +++ b/install/start.debian.sh @@ -5,22 +5,26 @@ echo "[INSTALL] Run start.debian.sh" echo "---------------------------------------------------------" -INSTALL_DIR=/home/pi # Specify the installation directory here +INSTALL_DIR=/app # Specify the installation directory here # DO NOT CHANGE ANYTHING BELOW THIS LINE! -WEB_UI_DIR=/var/www/html/pialert -NGINX_CONFIG_FILE=/etc/nginx/conf.d/pialert.conf +CONF_FILE=app.conf +DB_FILE=app.db +NGINX_CONF_FILE=netalertx.debian.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 -FILEDB=$INSTALL_DIR/pialert/db/pialert.db +INSTALL_PATH=$INSTALL_DIR/ +FILEDB=$INSTALL_PATH/db/$DB_FILE # DO NOT CHANGE ANYTHING ABOVE THIS LINE! # if custom variables not set we do not need to do anything if [ -n "${TZ}" ]; then - FILECONF=$INSTALL_DIR/pialert/config/pialert.conf + FILECONF=$INSTALL_PATH/config/$CONF_FILE if [ -f "$FILECONF" ]; then - sed -ie "s|Europe/Berlin|${TZ}|g" $INSTALL_DIR/pialert/config/pialert.conf + sed -ie "s|Europe/Berlin|${TZ}|g" $INSTALL_PATH/config/$CONF_FILE else - sed -ie "s|Europe/Berlin|${TZ}|g" $INSTALL_DIR/pialert/back/pialert.conf_bak + sed -ie "s|Europe/Berlin|${TZ}|g" $INSTALL_PATH/back/$CONF_FILE.bak fi fi @@ -33,8 +37,8 @@ fi # Run setup scripts echo "[INSTALL] Run setup scripts" -"$INSTALL_DIR/pialert/install/user-mapping.debian.sh" -"$INSTALL_DIR/pialert/install/install_dependencies.debian.sh" # if modifying this file transfer the changes into the root Dockerfile.debian as well! +"${INSTALL_PATH}/install/user-mapping.debian.sh" +"${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" @@ -44,7 +48,7 @@ if [ -L /etc/nginx/sites-enabled/default ] ; then sudo rm /etc/nginx/sites-enabled/default elif [ -f /etc/nginx/sites-enabled/default ]; then echo "Disabling default NGINX site, moving config to /etc/nginx/sites-available" - sudo mv /etc/nginx/sites-enabled/default /etc/nginx/sites-available/default.bkp_pialert + sudo mv /etc/nginx/sites-enabled/default /etc/nginx/sites-available/default.bkp_netalertx fi # Clear existing directories and files @@ -58,21 +62,21 @@ if [ -f $NGINX_CONFIG_FILE ]; then sudo rm $NGINX_CONFIG_FILE fi -# create symbolic link to the pialert install directory -ln -s $INSTALL_DIR/pialert/front $WEB_UI_DIR +# create symbolic link to the install directory +ln -s $INSTALL_PATH/front $WEB_UI_DIR # create symbolic link to NGINX configuaration coming with NetAlertX -sudo ln -s "$INSTALL_DIR/pialert/install/netalertx.debian.conf" /etc/nginx/conf.d/pialert.conf +sudo ln -s "${INSTALL_PATH}/install/netalertx.debian.conf" /etc/nginx/conf.d/$NGINX_CONF_FILE # Use user-supplied port if set if [ -n "${PORT}" ]; then echo "Setting webserver to user-supplied port ($PORT)" - sudo sed -i 's/listen 20211/listen '"$PORT"'/g' /etc/nginx/conf.d/pialert.conf + sudo sed -i 's/listen 20211/listen '"$PORT"'/g' /etc/nginx/conf.d/$NGINX_CONF_FILE fi # Change web interface address if set if [ -n "${LISTEN_ADDR}" ]; then - echo "Setting webserver to user-supplied address ($LISTEN_ADDR)" - sed -ie 's/listen /listen '"${LISTEN_ADDR}":'/g' /etc/nginx/conf.d/pialert.conf + echo "Setting webserver to user-supplied address (${LISTEN_ADDR})" + sed -ie 's/listen /listen '"${LISTEN_ADDR}":'/g' /etc/nginx/conf.d/$NGINX_CONF_FILE fi # Run the hardware vendors update at least once @@ -85,8 +89,8 @@ 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" + if [ -f "${INSTALL_PATH}/back/update_vendors.sh" ]; then + "${INSTALL_PATH}/back/update_vendors.sh" else echo "update_vendors.sh script not found in $INSTALL_DIR." fi @@ -95,39 +99,39 @@ fi # Create an empty log files # Create the execution_queue.log file if it doesn't exist -touch "$INSTALL_DIR/pialert/front/log/execution_queue.log" -# Create the pialert_front.log file if it doesn't exist -touch "$INSTALL_DIR/pialert/front/log/pialert_front.log" +touch "${INSTALL_PATH}/front/log/execution_queue.log" +# Create the app_front.log file if it doesn't exist +touch "${INSTALL_PATH}/front/log/app_front.log" # Fixing file permissions echo "[INSTALL] Fixing file permissions" -echo "[INSTALL] Fixing WEB_UI_DIR: $WEB_UI_DIR" +echo "[INSTALL] Fixing WEB_UI_DIR: ${WEB_UI_DIR}" chmod -R a+rwx $WEB_UI_DIR -echo "[INSTALL] Fixing INSTALL_DIR: $INSTALL_DIR" +echo "[INSTALL] Fixing INSTALL_DIR: ${INSTALL_DIR}" -chmod -R a+rw $INSTALL_DIR/pialert/front/log +chmod -R a+rw $INSTALL_PATH/front/log chmod -R a+rwx $INSTALL_DIR -echo "[INSTALL] Copy starter pialert.db and pialert.conf if they don't exist" +echo "[INSTALL] Copy starter $DB_FILE and $CONF_FILE if they don't exist" # DANGER ZONE: ALWAYS_FRESH_INSTALL if [ "$ALWAYS_FRESH_INSTALL" = true ]; then - echo "[INSTALL] ❗ ALERT /db and /config folders are cleared because the ALWAYS_FRESH_INSTALL is set to: $ALWAYS_FRESH_INSTALL❗" - # Delete content of "$INSTALL_DIR/pialert/config/" - rm -rf "$INSTALL_DIR/pialert/config/"* + echo "[INSTALL] ❗ ALERT /db and /config folders are cleared because the ALWAYS_FRESH_INSTALL is set to: ${ALWAYS_FRESH_INSTALL}❗" + # Delete content of "/config/" + rm -rf "${INSTALL_PATH}/config/"* - # Delete content of "$INSTALL_DIR/pialert/db/" - rm -rf "$INSTALL_DIR/pialert/db/"* + # Delete content of "/db/" + rm -rf "${INSTALL_PATH}/db/"* fi -# Copy starter pialert.db and pialert.conf if they don't exist -cp -n "$INSTALL_DIR/pialert/back/pialert.conf" "$INSTALL_DIR/pialert/config/pialert.conf" -cp -n "$INSTALL_DIR/pialert/back/pialert.db" "$FILEDB" +# Copy starter $DB_FILE and $CONF_FILE if they don't exist +cp -n "${INSTALL_PATH}/back/$CONF_FILE" "${INSTALL_PATH}/config/$CONF_FILE" +cp -n "${INSTALL_PATH}/back/$DB_FILE" "$FILEDB" echo "[INSTALL] Fixing permissions after copied starter config & DB" @@ -136,13 +140,13 @@ if [ -f "$FILEDB" ]; then fi chmod -R a+rwx $INSTALL_DIR # second time after we copied the files -chmod -R a+rw $INSTALL_DIR/pialert/config -sudo chgrp -R www-data $INSTALL_DIR/pialert +chmod -R a+rw $INSTALL_PATH/config +sudo chgrp -R www-data $INSTALL_PATH # Check if buildtimestamp.txt doesn't exist -if [ ! -f "$INSTALL_DIR/pialert/front/buildtimestamp.txt" ]; then +if [ ! -f "${INSTALL_PATH}/front/buildtimestamp.txt" ]; then # Create buildtimestamp.txt - date +%s > "$INSTALL_DIR/pialert/front/buildtimestamp.txt" + date +%s > "${INSTALL_PATH}/front/buildtimestamp.txt" fi # start PHP @@ -159,7 +163,7 @@ fi # Activate the virtual python environment source myenv/bin/activate -echo "[INSTALL] 🚀 Starting app - navigate to your :$PORT" +echo "[INSTALL] 🚀 Starting app - navigate to your :${PORT}" # Start the NetAlertX python script -python $INSTALL_DIR/pialert/netalertx/ +python $INSTALL_PATH/server/ diff --git a/netalertx/README.md b/server/README.md similarity index 100% rename from netalertx/README.md rename to server/README.md diff --git a/netalertx/__init__.py b/server/__init__.py similarity index 100% rename from netalertx/__init__.py rename to server/__init__.py diff --git a/netalertx/__main__.py b/server/__main__.py similarity index 99% rename from netalertx/__main__.py rename to server/__main__.py index f9deff11..15eb5ece 100755 --- a/netalertx/__main__.py +++ b/server/__main__.py @@ -20,7 +20,7 @@ import time import datetime import multiprocessing -# Register NetAlertX modules NetAlertX directories +# Register NetAlertX modules import conf from const import * from logger import mylog diff --git a/netalertx/api.py b/server/api.py similarity index 98% rename from netalertx/api.py rename to server/api.py index fd2da52b..7c262b8a 100755 --- a/netalertx/api.py +++ b/server/api.py @@ -1,7 +1,7 @@ import json -# Register NetAlertX modules NetAlertX directories +# Register NetAlertX modules import conf from const import (apiPath, sql_appevents, sql_devices_all, sql_events_pending_alert, sql_settings, sql_plugins_events, sql_plugins_history, sql_plugins_objects,sql_language_strings, sql_notifications_all) from logger import mylog diff --git a/netalertx/appevent.py b/server/appevent.py similarity index 99% rename from netalertx/appevent.py rename to server/appevent.py index 97343a61..6a92aaf6 100755 --- a/netalertx/appevent.py +++ b/server/appevent.py @@ -2,7 +2,7 @@ import datetime import json import uuid -# Register NetAlertX modules NetAlertX directories +# Register NetAlertX modules import conf from const import applicationPath, logPath, apiPath, confFileName from logger import logResult, mylog, print_log diff --git a/netalertx/conf.py b/server/conf.py similarity index 100% rename from netalertx/conf.py rename to server/conf.py diff --git a/netalertx/const.py b/server/const.py similarity index 95% rename from netalertx/const.py rename to server/const.py index 703bf0b1..b4a30413 100755 --- a/netalertx/const.py +++ b/server/const.py @@ -3,9 +3,9 @@ #=============================================================================== # PATHS #=============================================================================== -applicationPath = '/home/pi/pialert' -dbFileName = 'pialert.db' -confFileName = 'pialert.conf' +applicationPath = '/app' +dbFileName = 'app.db' +confFileName = 'app.conf' confPath = "/config/" + confFileName dbPath = '/db/' + dbFileName diff --git a/netalertx/database.py b/server/database.py similarity index 99% rename from netalertx/database.py rename to server/database.py index 0adc5b4b..b04768b4 100755 --- a/netalertx/database.py +++ b/server/database.py @@ -3,7 +3,7 @@ import sqlite3 import base64 -# Register NetAlertX modules NetAlertX directories +# Register NetAlertX modules from const import fullDbPath, sql_devices_stats, sql_devices_all from logger import mylog diff --git a/netalertx/device.py b/server/device.py similarity index 100% rename from netalertx/device.py rename to server/device.py diff --git a/netalertx/flows.py b/server/flows.py similarity index 100% rename from netalertx/flows.py rename to server/flows.py diff --git a/netalertx/helper.py b/server/helper.py similarity index 99% rename from netalertx/helper.py rename to server/helper.py index 4b0d9366..122c30c3 100755 --- a/netalertx/helper.py +++ b/server/helper.py @@ -18,6 +18,9 @@ import conf from const import * from logger import mylog, logResult +# Register NetAlertX directories +INSTALL_PATH="/app" + #------------------------------------------------------------------------------- # DateTime #------------------------------------------------------------------------------- @@ -201,11 +204,11 @@ def filePermissions(): (confR_access, dbR_access) = checkPermissionsOK() # Initial check if confR_access == False: - initialiseFile(fullConfPath, "/home/pi/pialert/back/pialert.conf" ) + initialiseFile(fullConfPath, f"{INSTALL_PATH}/back/app.conf" ) # check and initialize .db if dbR_access == False: - initialiseFile(fullDbPath, "/home/pi/pialert/back/pialert.db") + initialiseFile(fullDbPath, f"{INSTALL_PATH}/back/app.db") # last attempt fixPermissions() diff --git a/netalertx/initialise.py b/server/initialise.py similarity index 99% rename from netalertx/initialise.py rename to server/initialise.py index 0debeaad..4613c329 100755 --- a/netalertx/initialise.py +++ b/server/initialise.py @@ -264,7 +264,8 @@ replacements = { r'REPORT_MQTT=True': 'MQTT_RUN=\'on_notification\'', r'PIHOLE_CMD=': 'PIHOLE_CMD_OLD=', r'\bINCLUDED_SECTIONS\b': 'NTFPRCS_INCLUDED_SECTIONS', - r'\bDIG_GET_IP_ARG\b': 'INTRNT_DIG_GET_IP_ARG' + r'\bDIG_GET_IP_ARG\b': 'INTRNT_DIG_GET_IP_ARG', + r'\/home/pi/pialert\b': '/app' } def renameSettings(config_file): diff --git a/netalertx/logger.py b/server/logger.py similarity index 98% rename from netalertx/logger.py rename to server/logger.py index 7992e433..32e49a64 100755 --- a/netalertx/logger.py +++ b/server/logger.py @@ -51,7 +51,7 @@ def file_print (*args): result += str(arg) print(result) - append_to_file_with_timeout(logPath + "/pialert.log", result + '\n', 5) + append_to_file_with_timeout(logPath + "/app.log", result + '\n', 5) #------------------------------------------------------------------------------- # Function to append to the file diff --git a/netalertx/networkscan.py b/server/networkscan.py similarity index 100% rename from netalertx/networkscan.py rename to server/networkscan.py diff --git a/netalertx/notification.py b/server/notification.py similarity index 97% rename from netalertx/notification.py rename to server/notification.py index b4e518b5..a7d4ee1f 100755 --- a/netalertx/notification.py +++ b/server/notification.py @@ -5,7 +5,7 @@ import socket import subprocess from json2table import convert -# Register NetAlertX modules NetAlertX directories +# Register NetAlertX modules import conf from const import applicationPath, logPath, apiPath, confFileName from logger import logResult, mylog, print_log @@ -110,13 +110,13 @@ class Notification_obj: # Report "VERSION" in Header & footer VERSIONFILE = subprocess.check_output(['php', applicationPath + '/front/php/templates/version.php']).decode('utf-8') - mail_text = mail_text.replace ('', VERSIONFILE) - mail_html = mail_html.replace ('', VERSIONFILE) + mail_text = mail_text.replace ('', VERSIONFILE) + mail_html = mail_html.replace ('', VERSIONFILE) # Report "BUILD" in Header & footer BUILDFILE = subprocess.check_output(['php', applicationPath + '/front/php/templates/build.php']).decode('utf-8') - mail_text = mail_text.replace ('', BUILDFILE) - mail_html = mail_html.replace ('', BUILDFILE) + mail_text = mail_text.replace ('', BUILDFILE) + mail_html = mail_html.replace ('', BUILDFILE) # Start generating the TEXT & HTML notification messages html, text = construct_notifications(self.JSON, "new_devices") diff --git a/netalertx/plugin.py b/server/plugin.py similarity index 99% rename from netalertx/plugin.py rename to server/plugin.py index c6c34b5b..5d94ae7b 100755 --- a/netalertx/plugin.py +++ b/server/plugin.py @@ -7,7 +7,7 @@ import base64 from collections import namedtuple -# Register NetAlertX modules NetAlertX directories +# Register NetAlertX modules import conf from const import pluginsPath, logPath, applicationPath from logger import mylog @@ -265,8 +265,8 @@ def execute_plugin(db, plugin, pluginsState = plugins_state() ): else: mylog('debug', [f'[Plugins] The file {file_path} does not exist']) - # pialert-db-query - if plugin['data_source'] == 'pialert-db-query': + # app-db-query + if plugin['data_source'] == 'app-db-query': # replace single quotes wildcards q = set_CMD.replace("{s-quote}", '\'') @@ -303,7 +303,7 @@ def execute_plugin(db, plugin, pluginsState = plugins_state() ): else: mylog('none', ['[Plugins] Skipped invalid sql result']) - # pialert-db-query + # app-db-query if plugin['data_source'] == 'sqlite-db-query': # replace single quotes wildcards # set_CMD should contain a SQL query diff --git a/netalertx/plugin_utils.py b/server/plugin_utils.py similarity index 100% rename from netalertx/plugin_utils.py rename to server/plugin_utils.py diff --git a/netalertx/reporting.py b/server/reporting.py similarity index 99% rename from netalertx/reporting.py rename to server/reporting.py index 4c094aa7..727368f6 100755 --- a/netalertx/reporting.py +++ b/server/reporting.py @@ -13,7 +13,6 @@ import datetime import json -# Register NetAlertX modules NetAlertX directories import conf from const import applicationPath, logPath, apiPath, confFileName from helper import timeNowTZ, get_file_content, write_file, get_timezone_offset, get_setting_value diff --git a/netalertx/scheduler.py b/server/scheduler.py similarity index 100% rename from netalertx/scheduler.py rename to server/scheduler.py diff --git a/test/test_helper.py b/test/test_helper.py index 1e678321..8ca8d75d 100755 --- a/test/test_helper.py +++ b/test/test_helper.py @@ -1,7 +1,7 @@ import sys import pathlib -sys.path.append(str(pathlib.Path(__file__).parent.parent.resolve()) + "/pialert/") +sys.path.append(str(pathlib.Path(__file__).parent.parent.resolve()) + "/server/") import datetime
  • - NetAlertX Report + Net Alertx Report