From 72e4b4f0cb8de1bb3f634a63c5be06a17be71392 Mon Sep 17 00:00:00 2001 From: Erik Karlsson Date: Fri, 14 Jun 2024 14:41:03 +0200 Subject: [PATCH] usp-js: depend on OBUSPA_ENABLE_TEST_CONTROLLER_LOCAL This avoids the need for duplicating local MQTT broker setup. --- usp-js/Makefile | 6 ++-- usp-js/files/etc/init.d/uspjs | 68 ----------------------------------- 2 files changed, 2 insertions(+), 72 deletions(-) delete mode 100755 usp-js/files/etc/init.d/uspjs diff --git a/usp-js/Makefile b/usp-js/Makefile index 1d842de5d..57fe20f28 100644 --- a/usp-js/Makefile +++ b/usp-js/Makefile @@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=usp-js -PKG_VERSION:=1.2.5 +PKG_VERSION:=1.2.6 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL:=https://dev.iopsys.eu/websdk/usp-js.git @@ -23,7 +23,7 @@ define Package/usp-js SECTION:=libs CATEGORY:=Libraries TITLE:=A JS library for USP(TR369) protocol - DEPENDS:=+quickjs +quickjs-websocket +@OBUSPA_ENABLE_TEST_CONTROLLER + DEPENDS:=+quickjs +quickjs-websocket +@OBUSPA_ENABLE_TEST_CONTROLLER_LOCAL EXTRA_DEPENDS:=obuspa mosquitto-ssl endef @@ -37,9 +37,7 @@ endef define Package/usp-js/install $(INSTALL_DIR) $(1)/usr/lib/usp-js - $(INSTALL_DIR) $(1)/etc $(CP) $(PKG_BUILD_DIR)/qjs/* $(1)/usr/lib/usp-js/ - $(CP) ./files/etc/* $(1)/etc/ endef $(eval $(call BuildPackage,usp-js)) diff --git a/usp-js/files/etc/init.d/uspjs b/usp-js/files/etc/init.d/uspjs deleted file mode 100755 index 2fb9786e8..000000000 --- a/usp-js/files/etc/init.d/uspjs +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/sh /etc/rc.common - -START=99 -STOP=01 -USE_PROCD=1 - -log() -{ - echo "$*"|logger -t usp-js -p debug -} - -get_oui_from_db() -{ - db -q get device.deviceinfo.ManufacturerOUI -} - -get_serial_from_db() -{ - db -q get device.deviceinfo.SerialNumber -} - -publish_endpoint() -{ - local AgentEndpointID serial oui user pass - - if ! uci -q get obuspa.testmqtt; then - return 0; - fi - - # return if mosquitto_pub is not present - if [ ! "$(command -v mosquitto_pub)" ]; then - log "mosquitto_pub not present can't publish EndpointID" - return 0; - fi - - # Get endpoint id from obuspa config first - config_load obuspa - config_get AgentEndpointID localagent EndpointID "" - if [ -z "${AgentEndpointID}" ]; then - serial=$(get_serial_from_db) - oui=$(get_oui_from_db) - AgentEndpointID="os::${oui}-${serial//+/%2B}" - fi - - config_get user testmqtt Username "" - config_get pass testmqtt Password "" - - # publish Agent's EndpointID in mosquito broker for discovery by usp-js - # This is a work around till obuspa adds supports for mDNS discovery - if [ -n "${user}" ] && [ -n "${pass}" ]; then - log "Publishing EndpointID ${AgentEndpointID} to local mqtt broker with username, password" - mosquitto_pub -r -t "obuspa/EndpointID" -m "${AgentEndpointID}" -u "${user}" -P "${pass}" - elif [ -n "${user}" ]; then - log "Publishing EndpointID ${AgentEndpointID} to local mqtt broker with username only" - mosquitto_pub -r -t "obuspa/EndpointID" -m "${AgentEndpointID}" -u "${user}" - else - log "Publishing EndpointID ${AgentEndpointID} to local mqtt broker" - mosquitto_pub -r -t "obuspa/EndpointID" -m "${AgentEndpointID}" - fi -} - -start_service() { - publish_endpoint -} - -service_triggers() { - procd_add_reload_trigger "obuspa" -}