From b3bdcea1377e2115e2eedb6cfe290a81e3b1cd0b Mon Sep 17 00:00:00 2001 From: Vivek Kumar Dutta Date: Tue, 15 Oct 2024 17:40:58 +0530 Subject: [PATCH] obuspa: Fix miss-configs caused by uci update --- obuspa/Makefile | 2 +- obuspa/files/etc/init.d/obuspa | 36 +++++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/obuspa/Makefile b/obuspa/Makefile index 0537dec39..3393ab291 100644 --- a/obuspa/Makefile +++ b/obuspa/Makefile @@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=obuspa -PKG_VERSION:=9.0.0.9 +PKG_VERSION:=9.0.0.10 LOCAL_DEV:=0 ifneq ($(LOCAL_DEV),1) diff --git a/obuspa/files/etc/init.d/obuspa b/obuspa/files/etc/init.d/obuspa index e2a329d01..3cd19c51c 100755 --- a/obuspa/files/etc/init.d/obuspa +++ b/obuspa/files/etc/init.d/obuspa @@ -40,7 +40,7 @@ db_set_reset_file() shift value="$*" - if [ -n "${param}" ] && [ -n "${value}" ]; then + if [ -n "${param}" ]; then echo "${param} \"${value}\"">>${RESET_FILE} else echo >>${RESET_FILE} @@ -368,9 +368,21 @@ configure_controller() db_set "${BASEPATH}.MTP.1.Protocol" "${Protocol}" # only support configuration of one mtp path per controller using uci if [ "${Protocol}" = "MQTT" ]; then + # Cleanup + db_set "${BASEPATH}.MTP.1.WebSocket.Host" "" + db_set "${BASEPATH}.MTP.1.WebSocket.Path" "" + db_set "${BASEPATH}.MTP.1.STOMP.Reference" "" + db_set "${BASEPATH}.MTP.1.STOMP.Destination" "" + db_set "${BASEPATH}.MTP.1.MQTT.Reference" "${dm_ref}" db_set "${BASEPATH}.MTP.1.MQTT.Topic" "${Topic}" elif [ "${Protocol}" = "STOMP" ]; then + # Cleanup + db_set "${BASEPATH}.MTP.1.WebSocket.Host" "" + db_set "${BASEPATH}.MTP.1.WebSocket.Path" "" + db_set "${BASEPATH}.MTP.1.MQTT.Reference" "" + db_set "${BASEPATH}.MTP.1.MQTT.Topic" "" + db_set "${BASEPATH}.MTP.1.STOMP.Reference" "${dm_ref}" db_set "${BASEPATH}.MTP.1.STOMP.Destination" "${Destination}" elif [ "${Protocol}" = "CoAP" ]; then @@ -379,6 +391,12 @@ configure_controller() db_set "${BASEPATH}.MTP.1.CoAP.Port" "${Port}" db_set "${BASEPATH}.MTP.1.CoAP.EnableEncryption" "${EnableEncryption}" elif [ "${Protocol}" = "WebSocket" ]; then + # Cleanup + db_set "${BASEPATH}.MTP.1.STOMP.Reference" "" + db_set "${BASEPATH}.MTP.1.STOMP.Destination" "" + db_set "${BASEPATH}.MTP.1.MQTT.Reference" "" + db_set "${BASEPATH}.MTP.1.MQTT.Topic" "" + db_set "${BASEPATH}.MTP.1.WebSocket.Host" "${Host}" db_set "${BASEPATH}.MTP.1.WebSocket.Port" "${Port}" db_set "${BASEPATH}.MTP.1.WebSocket.Path" "${Path}" @@ -509,18 +527,34 @@ configure_mtp() { db_set "${BASEPATH}.Enable" "${Enable}" db_set "${BASEPATH}.Protocol" "${Protocol}" if [ "${Protocol}" = "MQTT" ]; then + # cleanup + db_set "${BASEPATH}.WebSocket.Path" "" + db_set "${BASEPATH}.STOMP.Reference" "" + db_set "${BASEPATH}.STOMP.Destination" "" + db_set "${BASEPATH}.MQTT.Reference" "${dm_ref}" db_set "${BASEPATH}.MQTT.ResponseTopicConfigured" "${ResponseTopicConfigured}" if [ -n "${PublishQoS}" ]; then db_set "${BASEPATH}.MQTT.PublishQoS" "${PublishQoS}" fi elif [ "${Protocol}" = "STOMP" ]; then + # cleanup + db_set "${BASEPATH}.WebSocket.Path" "" + db_set "${BASEPATH}.MQTT.Reference" "" + db_set "${BASEPATH}.MQTT.ResponseTopicConfigured" "" + db_set "${BASEPATH}.STOMP.Reference" "${dm_ref}" db_set "${BASEPATH}.STOMP.Destination" "${Destination}" elif [ "${Protocol}" = "CoAP" ]; then db_set "${BASEPATH}.CoAP.Path" "${Path}" db_set "${BASEPATH}.CoAP.Port" "${Port}" elif [ "${Protocol}" = "WebSocket" ]; then + # cleanup + db_set "${BASEPATH}.MQTT.Reference" "" + db_set "${BASEPATH}.MQTT.ResponseTopicConfigured" "" + db_set "${BASEPATH}.STOMP.Reference" "" + db_set "${BASEPATH}.STOMP.Destination" "" + db_set "${BASEPATH}.WebSocket.Path" "${Path}" db_set "${BASEPATH}.WebSocket.Port" "${Port}" db_set "${BASEPATH}.WebSocket.EnableEncryption" "${EnableEncryption}"