stunc: Added stun related params

- Moved stun related datamodel parameters from bbf to stunc
- Rename/align stun uci with package
- Updated schema and docs
This commit is contained in:
vdutta 2021-05-12 23:36:59 +05:30
parent 567e6d9870
commit b87959cc61
3 changed files with 23 additions and 29 deletions

View file

@ -8,9 +8,9 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=stunc 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_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/stunc.git PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/stunc.git
@ -29,7 +29,7 @@ define Package/$(PKG_NAME)
CATEGORY:=Utilities CATEGORY:=Utilities
SUBMENU:=TRx69 SUBMENU:=TRx69
TITLE:=BBF STUN Client 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 endef
define Package/$(PKG_NAME)/description define Package/$(PKG_NAME)/description
@ -43,9 +43,11 @@ define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/usr/sbin $(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_DIR) $(1)/etc/config $(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DIR) $(1)/etc/init.d $(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) $(PKG_BUILD_DIR)/stunc $(1)/usr/sbin/
$(INSTALL_BIN) ./files/etc/init.d/stunc $(1)/etc/init.d/stunc $(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 endef
$(eval $(call BuildPackage,$(PKG_NAME))) $(eval $(call BuildPackage,$(PKG_NAME)))

View file

@ -1,6 +1,6 @@
config stun 'stun' config stunc 'stunc'
option enable '0' option enabled '0'
option username 'stun' option username 'stun'
option password 'stun' option password 'stun'
option server_address 'stun.l.google.com' option server_address 'stun.l.google.com'

View file

@ -1,23 +1,20 @@
#!/bin/sh /etc/rc.common #!/bin/sh /etc/rc.common
# STUN client software
# Copyright (C) 2020 iopsys Software Solutions AB
# Author: Omar Kallel <omar.kallel@pivasoftware.com>
START=90 START=99
STOP=15
USE_PROCD=1 USE_PROCD=1
PROG="/usr/sbin/stunc" PROG="/usr/sbin/stunc"
log() { log() {
#echo "${@}" >/dev/console #echo "${@}" >/dev/console
echo "${@}"|logger -t stun -p info echo "${@}"|logger -t stunc -p info
} }
validate_stun_section() validate_stun_section()
{ {
uci_validate_section stun stun stun \ uci_validate_section stunc stunc stunc \
'enable:bool' \ 'enabled:bool' \
'Username:string' \ 'Username:string' \
'Password:string' \ 'Password:string' \
'server_address:host' \ 'server_address:host' \
@ -26,31 +23,26 @@ validate_stun_section()
'log_level:uinteger:0' 'log_level:uinteger:0'
} }
service_running() {
ubus wait_for tr069
return $?;
}
start_service() { start_service() {
local enable server_address local enabled server_address
config_load stun config_load stunc
validate_stun_section || { validate_stun_section || {
log "Validation failed for stun section"; log "Validation failed for stunc section";
exit 1; return 1;
} }
if [ "$enable" -eq 0 ]; then if [ "$enabled" -eq 0 ]; then
exit 0; return 0;
fi fi
if [ -z "${server_address}" ]; then if [ -z "${server_address}" ]; then
log "Stun server address not defined or invalid" log "Stun server address not defined or invalid"
exit 0; return 0;
fi fi
procd_open_instance stun procd_open_instance stunc
procd_set_param command "$PROG" procd_set_param command ${PROG}
procd_set_param respawn "3" "7" "0" procd_set_param respawn "3" "7" "0"
procd_close_instance procd_close_instance
@ -63,5 +55,5 @@ reload_service() {
service_triggers() service_triggers()
{ {
procd_add_reload_trigger stun procd_add_reload_trigger stunc
} }