From d3a161229419bc22d1cd886963d8f2b7c239bd3e Mon Sep 17 00:00:00 2001 From: Vivek Kumar Dutta Date: Mon, 13 May 2024 12:30:08 +0530 Subject: [PATCH] obuspa: fixes for downgrade --- obuspa/Makefile | 2 +- obuspa/files/etc/init.d/obuspa | 73 +++++++++++++++------------------- 2 files changed, 34 insertions(+), 41 deletions(-) diff --git a/obuspa/Makefile b/obuspa/Makefile index 868cc0e87..78e98a740 100644 --- a/obuspa/Makefile +++ b/obuspa/Makefile @@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=obuspa -PKG_VERSION:=7.0.5.23 +PKG_VERSION:=7.0.5.24 LOCAL_DEV:=0 ifneq ($(LOCAL_DEV),1) diff --git a/obuspa/files/etc/init.d/obuspa b/obuspa/files/etc/init.d/obuspa index 1242fd536..cd663694d 100755 --- a/obuspa/files/etc/init.d/obuspa +++ b/obuspa/files/etc/init.d/obuspa @@ -217,12 +217,10 @@ validate_controller_section() 'Enable:bool:1' \ 'EndpointID:string' \ 'assigned_role_name:string' \ - 'AssignedRole:string' \ 'Protocol:or("STOMP","CoAP","MQTT", "WebSocket")' \ 'Destination:string' \ 'Topic:string' \ 'ParameterName:list(string)' \ - 'Reference:string' \ 'mqtt:string' \ 'stomp:string' \ 'Host:string' \ @@ -230,7 +228,7 @@ validate_controller_section() 'Path:string' \ 'EnableEncryption:bool' \ 'PeriodicNotifInterval:uinteger' \ - 'SessionMode:string:Allow' \ + 'SessionMode:string' \ 'ProvisioningCode:string' } @@ -255,7 +253,6 @@ validate_mtp_section() 'Path:string' \ 'mqtt:string' \ 'stomp:string' \ - 'Reference:string' \ 'PublishQoS:uinteger' \ 'EnableEncryption:bool' } @@ -324,7 +321,7 @@ configure_controller() local EndpointID Enable local Protocol Destination local Topic mqtt stomp assigned_role_name AssignedRole ParameterName ProvisioningCode - local Host Port Path EnableEncryption Reference SessionMode PeriodicNotifInterval + local Host Port Path EnableEncryption PeriodicNotifInterval local dm_ref sec sec="${1}" @@ -346,16 +343,12 @@ configure_controller() fi dm_ref="" - if [ -z "${Reference}" ]; then - if [ "${Protocol}" = "STOMP" ]; then - stomp="${stomp/stomp_/cpe-}" - dm_ref=$(get_refrence_path "Device.STOMP.Connection." "${stomp}") - elif [ "${Protocol}" = "MQTT" ]; then - mqtt="${mqtt/mqtt_/cpe-}" - dm_ref=$(get_refrence_path "Device.MQTT.Client." "${mqtt}") - fi - else - dm_ref="${Reference}" + if [ "${Protocol}" = "STOMP" ]; then + stomp="${stomp/stomp_/cpe-}" + dm_ref=$(get_refrence_path "Device.STOMP.Connection." "${stomp}") + elif [ "${Protocol}" = "MQTT" ]; then + mqtt="${mqtt/mqtt_/cpe-}" + dm_ref=$(get_refrence_path "Device.MQTT.Client." "${mqtt}") fi db_set "${BASEPATH}.Alias" "${sec}" @@ -370,16 +363,15 @@ configure_controller() db_set "${BASEPATH}.PeriodicNotifInterval" "${PeriodicNotifInterval}" fi - if [ -n "${SessionMode}" ]; then - db_set "${BASEPATH}.E2ESession.SessionMode" "${SessionMode}" - fi + #if [ -n "${SessionMode}" ]; then + # db_set "${BASEPATH}.E2ESession.SessionMode" "${SessionMode}" + #fi if [ -n "${assigned_role_name}" ]; then AssignedRole=$(get_role_index "${assigned_role_name}") - fi - - if [ -n "${AssignedRole}" ]; then - db_set "${BASEPATH}.AssignedRole" "${AssignedRole}" + if [ -n "${AssignedRole}" ]; then + db_set "${BASEPATH}.AssignedRole" "${AssignedRole}" + fi fi db_set "${BASEPATH}.MTP.1.Alias" "${sec}" @@ -559,16 +551,12 @@ configure_mtp() { fi dm_ref="" - if [ -z "${Reference}" ]; then - if [ "${Protocol}" = "STOMP" ]; then - stomp="${stomp/stomp_/cpe-}" - dm_ref=$(get_refrence_path "Device.STOMP.Connection." "${stomp}") - elif [ "${Protocol}" = "MQTT" ]; then - mqtt="${mqtt/mqtt_/cpe-}" - dm_ref=$(get_refrence_path "Device.MQTT.Client." "${mqtt}") - fi - else - dm_ref="${Reference}" + if [ "${Protocol}" = "STOMP" ]; then + stomp="${stomp/stomp_/cpe-}" + dm_ref=$(get_refrence_path "Device.STOMP.Connection." "${stomp}") + elif [ "${Protocol}" = "MQTT" ]; then + mqtt="${mqtt/mqtt_/cpe-}" + dm_ref=$(get_refrence_path "Device.MQTT.Client." "${mqtt}") fi db_set "${BASEPATH}.Alias" "${sec}" @@ -776,8 +764,8 @@ sync_db_controller() { local cntrs copts sec pvalue protocol - copts="Enable EndpointID AssignedRole PeriodicNotifInterval" - popts="Destination Topic Reference Host Port Path EnableEncryption" + copts="Enable EndpointID PeriodicNotifInterval" + popts="Destination Topic Host Port Path EnableEncryption" cntrs="$(get_instances_from_db_dump Device.LocalAgent.Controller.)" for cntr in $cntrs; do @@ -809,8 +797,7 @@ sync_db_localagent_mtp() local mtps opts popts sec pvalue protocol opts="Enable" - popts="ResponseTopicConfigured Destination Port Path Reference EnableEncryption PublishQoS" - ropts="mqtt stomp" + popts="ResponseTopicConfigured Destination Port Path EnableEncryption PublishQoS" mtps="$(get_instances_from_db_dump Device.LocalAgent.MTP.)" for inst in $mtps; do @@ -833,9 +820,6 @@ sync_db_localagent_mtp() pvalue="$(get_param_value_from_dump "${inst}"."${protocol}"."${param}")" uci_set obuspa "${sec}" "${param}" "${pvalue}" done - for param in ${ropts}; do - uci_set obuspa "${sec}" "${param}" "" - done done } @@ -1002,6 +986,9 @@ db_init() reverse_update_db_with_uci fi + # Remove ControllerTrust.Role., if present in db for backward compatibility + delete_sql_db_entry_with_pattern "Device.LocalAgent.ControllerTrust.Role." + # Remove reset file if present [ -f "${RESET_FILE}" ] && mv ${RESET_FILE} ${RESET_FILE}.old @@ -1034,11 +1021,17 @@ db_init() } start_service() { - local enabled + local enabled role_file mkdir -p /tmp/obuspa/ config_load obuspa config_get_bool enabled global enabled 0 + config_get role_file global role_file "" + # Use the default role file if not defined in uci, but present in path + if [ -z "${role_file}" ] && [ -f "/etc/obuspa/roles.json" ] ; then + uci -q set obuspa.global.role_file="/etc/obuspa/roles.json" + uci_commit obuspa + fi procd_open_instance ${CONFIGURATION} if [ "${enabled}" -eq 1 ]; then