From b87959cc61916ef6c599c6ca30fc26454ea6b330 Mon Sep 17 00:00:00 2001 From: vdutta Date: Wed, 12 May 2021 23:36:59 +0530 Subject: [PATCH] stunc: Added stun related params - Moved stun related datamodel parameters from bbf to stunc - Rename/align stun uci with package - Updated schema and docs --- stunc/Makefile | 10 ++++--- stunc/files/etc/config/{stun => stunc} | 4 +-- stunc/files/etc/init.d/stunc | 38 ++++++++++---------------- 3 files changed, 23 insertions(+), 29 deletions(-) rename stunc/files/etc/config/{stun => stunc} (84%) diff --git a/stunc/Makefile b/stunc/Makefile index 7c7c36cd4..5da35a237 100755 --- a/stunc/Makefile +++ b/stunc/Makefile @@ -8,9 +8,9 @@ include $(TOPDIR)/rules.mk PKG_NAME:=stunc -PKG_VERSION:=1.0.1 +PKG_VERSION:=1.0.2 -PKG_SOURCE_VERSION:=cd7c5d70bc97a2f1a26d5587ccf6f4c1e9ca82c8 +PKG_SOURCE_VERSION:=d578df0c8e4e7d1b642a5cf037ce468379270534 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/stunc.git @@ -29,7 +29,7 @@ define Package/$(PKG_NAME) CATEGORY:=Utilities SUBMENU:=TRx69 TITLE:=BBF STUN Client - DEPENDS:=+libubus +libuci +libubox +libjson-c +libopenssl +libblobmsg-json + DEPENDS:=+libubus +libuci +libubox +libjson-c +libopenssl +libblobmsg-json +libbbf_api endef define Package/$(PKG_NAME)/description @@ -43,9 +43,11 @@ define Package/$(PKG_NAME)/install $(INSTALL_DIR) $(1)/usr/sbin $(INSTALL_DIR) $(1)/etc/config $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_DIR) $(1)/usr/lib/bbfdm + $(INSTALL_BIN) $(PKG_BUILD_DIR)/libstunc.so $(1)/usr/lib/bbfdm/libstunc.so $(INSTALL_BIN) $(PKG_BUILD_DIR)/stunc $(1)/usr/sbin/ $(INSTALL_BIN) ./files/etc/init.d/stunc $(1)/etc/init.d/stunc - $(INSTALL_DATA) ./files/etc/config/stun $(1)/etc/config/stun + $(INSTALL_DATA) ./files/etc/config/stunc $(1)/etc/config/stunc endef $(eval $(call BuildPackage,$(PKG_NAME))) diff --git a/stunc/files/etc/config/stun b/stunc/files/etc/config/stunc similarity index 84% rename from stunc/files/etc/config/stun rename to stunc/files/etc/config/stunc index 3c8689c53..620af5b96 100644 --- a/stunc/files/etc/config/stun +++ b/stunc/files/etc/config/stunc @@ -1,6 +1,6 @@ -config stun 'stun' - option enable '0' +config stunc 'stunc' + option enabled '0' option username 'stun' option password 'stun' option server_address 'stun.l.google.com' diff --git a/stunc/files/etc/init.d/stunc b/stunc/files/etc/init.d/stunc index db3794da8..b8ef24ca0 100755 --- a/stunc/files/etc/init.d/stunc +++ b/stunc/files/etc/init.d/stunc @@ -1,23 +1,20 @@ #!/bin/sh /etc/rc.common -# STUN client software -# Copyright (C) 2020 iopsys Software Solutions AB -# Author: Omar Kallel -START=90 +START=99 +STOP=15 USE_PROCD=1 PROG="/usr/sbin/stunc" - log() { #echo "${@}" >/dev/console - echo "${@}"|logger -t stun -p info + echo "${@}"|logger -t stunc -p info } validate_stun_section() { - uci_validate_section stun stun stun \ - 'enable:bool' \ + uci_validate_section stunc stunc stunc \ + 'enabled:bool' \ 'Username:string' \ 'Password:string' \ 'server_address:host' \ @@ -26,31 +23,26 @@ validate_stun_section() 'log_level:uinteger:0' } -service_running() { - ubus wait_for tr069 - return $?; -} - start_service() { - local enable server_address + local enabled server_address - config_load stun + config_load stunc validate_stun_section || { - log "Validation failed for stun section"; - exit 1; + log "Validation failed for stunc section"; + return 1; } - if [ "$enable" -eq 0 ]; then - exit 0; + if [ "$enabled" -eq 0 ]; then + return 0; fi if [ -z "${server_address}" ]; then log "Stun server address not defined or invalid" - exit 0; + return 0; fi - procd_open_instance stun - procd_set_param command "$PROG" + procd_open_instance stunc + procd_set_param command ${PROG} procd_set_param respawn "3" "7" "0" procd_close_instance @@ -63,5 +55,5 @@ reload_service() { service_triggers() { - procd_add_reload_trigger stun + procd_add_reload_trigger stunc }