diff --git a/.env b/.env index 7ac7cf6a..c75c843a 100644 --- a/.env +++ b/.env @@ -2,5 +2,9 @@ APP_DATA_LOCATION=/path/to/docker_appdata APP_CONFIG_LOCATION=/path/to/docker_config LOGS_LOCATION=/path/to/docker_logs +TZ=Europe/Paris +HOST_USER_ID=1000 +HOST_USER_GID=1000 +PORT=20211 diff --git a/README.md b/README.md index d5d95bde..a495bf29 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ JavaScript)* 📚 [Dockerfile instructions](https://github.com/jokob-sk/Pi.Alert/blob/main//dockerfiles/README.md). ![Main screen dark][main_dark] -Dark mode (and Activity over the last x scans) within this fork courtesy of [leiweibau](https://github.com/leiweibau/Pi.Alert) +Dark mode (and Device presence over time) within this fork courtesy of [leiweibau](https://github.com/leiweibau/Pi.Alert) ## How it works The system continuously scans the network for: @@ -164,7 +164,7 @@ Linux distributions. This code is a collaborative body of work, with special thanks to: - - [leiweibau](https://github.com/leiweibau/Pi.Alert): Dark mode (and Last X scans activity chart) + - [leiweibau](https://github.com/leiweibau/Pi.Alert): Dark mode (and Device presence over time) - [Macleykun](https://github.com/Macleykun): Help with Dockerfile clean-up - [Final-Hawk](https://github.com/Final-Hawk): Help with NTFY, styling and other fixes - Please see the [Git commit history](https://github.com/jokob-sk/Pi.Alert/commits/main) for a full list of people and their contributions to the project diff --git a/back/pialert.py b/back/pialert.py index 3cc7c5bb..268aa023 100644 --- a/back/pialert.py +++ b/back/pialert.py @@ -1480,17 +1480,31 @@ def send_email (pText, pHTML): #=============================================================================== # DB #=============================================================================== -def upgradeDB (): +def upgradeDB (): openDB() - # check if table exists - listOfTables = sql.execute( - """SELECT name FROM sqlite_master WHERE type='table' - AND name='Online_History'; """).fetchall() + # indicates, if Online_History table is available + onlineHistoryAvailable = sql.execute(""" + SELECT name FROM sqlite_master WHERE type='table' + AND name='Online_History'; + """).fetchall() != [] + + # Check if it is incompatible (Check if table has all required columns) + isIncompatible = False - if listOfTables == []: - print_log ('Upgrading DB (creating Online_History table)') + if onlineHistoryAvailable : + isIncompatible = sql.execute (""" + SELECT COUNT(*) AS CNTREC FROM pragma_table_info('Online_History') WHERE name='Archived_Devices' + """).fetchone()[0] == 0 + + # Drop table if available, but incompatible + if onlineHistoryAvailable and isIncompatible: + print_log ('Table is incompatible, Dropping the Online_History table)') + sql.execute("DROP TABLE Online_History;") + onlineHistoryAvailable = False + + if onlineHistoryAvailable == False : sql.execute(""" CREATE TABLE "Online_History" ( "Index" INTEGER, @@ -1503,6 +1517,7 @@ def upgradeDB (): ); """) + #------------------------------------------------------------------------------- def openDB (): diff --git a/docker-compose.yml b/docker-compose.yml index f629723b..b1ec288d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,7 +10,7 @@ services: - ${APP_DATA_LOCATION}/pialert/db/pialert.db:/home/pi/pialert/db/pialert.db - ${LOGS_LOCATION}/tmp:/home/pi/pialert/log environment: - - TZ=Europe/London - - PORT=20211 - - HOST_USER_ID=1000 - - HOST_USER_GID=1000 + - TZ=${TZ} + - PORT=${PORT} + - HOST_USER_ID=${HOST_USER_ID} + - HOST_USER_GID=${HOST_USER_GID} diff --git a/front/devices.php b/front/devices.php index 3e8563d4..91b2326d 100644 --- a/front/devices.php +++ b/front/devices.php @@ -106,7 +106,7 @@