From 9dd456bd2c7dd4d0a8e8d495ace6d7b124d45a23 Mon Sep 17 00:00:00 2001 From: Jokob-sk Date: Tue, 17 Oct 2023 07:38:49 +1100 Subject: [PATCH] =?UTF-8?q?MQTT,=20INSTALL=20scripts=20work=E2=A4=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.yml | 3 ++- dockerfiles/start.sh | 8 ++++---- dockerfiles/user-mapping.sh | 6 +++++- front/plugins/_publisher_mqtt/config.json | 13 ++++++++++--- front/plugins/_publisher_mqtt/mqtt.py | 13 ++++++++++--- 5 files changed, 31 insertions(+), 12 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 1baec208..0a0f6f0f 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -22,7 +22,8 @@ services: - ${APP_DATA_LOCATION}/pialert/dhcp_samples/dhcp1.leases:/mnt/dhcp1.leases - ${APP_DATA_LOCATION}/pialert/dhcp_samples/dhcp2.leases:/mnt/dhcp2.leases - ${APP_DATA_LOCATION}/pialert/dhcp_samples/pihole_dhcp_full.leases:/etc/pihole/dhcp.leases - - ${APP_DATA_LOCATION}/pihole/etc-pihole/pihole-FTL.db:/etc/pihole/pihole-FTL.dba + - ${APP_DATA_LOCATION}/pialert/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}/pialert:/home/pi/pialert/pialert - ${DEV_LOCATION}/dockerfiles:/home/pi/pialert/dockerfiles - ${APP_DATA_LOCATION}/pialert/php.ini:/etc/php/8.2/fpm/php.ini diff --git a/dockerfiles/start.sh b/dockerfiles/start.sh index ea6dc70b..e13620a5 100755 --- a/dockerfiles/start.sh +++ b/dockerfiles/start.sh @@ -102,11 +102,11 @@ date +%s > "$INSTALL_DIR/pialert/front/buildtimestamp.txt" /etc/init.d/nginx start # Start Nginx and your application to start at boot (if needed) -systemctl start nginx -systemctl enable nginx +# systemctl start nginx +# systemctl enable nginx -# systemctl enable pi-alert -sudo systemctl restart nginx +# # systemctl enable pi-alert +# sudo systemctl restart nginx # Activate the virtual python environment source myenv/bin/activate diff --git a/dockerfiles/user-mapping.sh b/dockerfiles/user-mapping.sh index 54803092..38abcda1 100755 --- a/dockerfiles/user-mapping.sh +++ b/dockerfiles/user-mapping.sh @@ -1,5 +1,9 @@ #!/bin/bash +echo "---------------------------------------------------------" +echo "[INSTALL] Run user-mapping.sh" +echo "---------------------------------------------------------" + if [ -z "${USER}" ]; then echo "We need USER to be set!"; exit 100 fi @@ -9,7 +13,7 @@ if [ -z "${HOST_USER_ID}" -a -z "${HOST_USER_GID}" ]; then echo "Nothing to do here." ; exit 0 fi -# reset user_?id to either new id or if empty old (still one of above +# reset user_id to either new id or if empty old (still one of above # might not be set) USER_ID=${HOST_USER_ID:=$USER_ID} USER_GID=${HOST_USER_GID:=$USER_GID} diff --git a/front/plugins/_publisher_mqtt/config.json b/front/plugins/_publisher_mqtt/config.json index f3b29c3d..8b1f2e13 100755 --- a/front/plugins/_publisher_mqtt/config.json +++ b/front/plugins/_publisher_mqtt/config.json @@ -26,7 +26,14 @@ "string" : "A plugin to publish a notification via the Apprise gateway." } ], - "params" : [], + "params" : [ + { + "name" : "devices", + "type" : "sql", + "value" : "SELECT dev_LastIP from DEVICES", + "timeoutMultiplier" : true + } + ], "database_column_definitions": [ { @@ -271,7 +278,7 @@ { "function": "CMD", "type": "readonly", - "default_value":"python3 /home/pi/pialert/front/plugins/_publisher_mqtt/mqtt.py", + "default_value":"python3 /home/pi/pialert/front/plugins/_publisher_mqtt/mqtt.py devices={devices}", "options": [], "localized": ["name", "description"], "name" : [{ @@ -294,7 +301,7 @@ { "function": "RUN_TIMEOUT", "type": "integer", - "default_value": 600, + "default_value": 10, "options": [], "localized": ["name", "description"], "name" : [{ diff --git a/front/plugins/_publisher_mqtt/mqtt.py b/front/plugins/_publisher_mqtt/mqtt.py index b4727969..eeb7db0d 100755 --- a/front/plugins/_publisher_mqtt/mqtt.py +++ b/front/plugins/_publisher_mqtt/mqtt.py @@ -100,9 +100,16 @@ class sensor_config: plugObj = getPluginObject({"Plugin":"MQTT", "Watched_Value3":hash_value}) - mylog('verbose', [f"[{pluginName}] Previous plugin object entry: {json.dumps(plugObj)}"]) + # mylog('verbose', [f"[{pluginName}] Previous plugin object entry: {json.dumps(plugObj)}"]) + + if plugObj == {}: + self.isNew = True + mylog('verbose', [f"[{pluginName}] New sensor entry mac : {mac}"]) + mylog('verbose', [f"[{pluginName}] New sensor entry input_string : {input_string}"]) + mylog('verbose', [f"[{pluginName}] New sensor entry hash_value : {hash_value}"]) + else: + self.isNew = False - self.isNew = plugObj == {} # Log sensor global plugin_objects @@ -117,7 +124,7 @@ class sensor_config: watched2 = sensorType, watched3 = hash_value, watched4 = mac, - extra = 'null', + extra = input_string, foreignKey = deviceId )