From 86bab4da2235265bc81f77a39a228b24dde58bc1 Mon Sep 17 00:00:00 2001 From: vdutta Date: Wed, 16 Dec 2020 15:53:19 +0530 Subject: [PATCH] uspd: Multiple fixes - Uci Schema updated - Ubus schema updated - Config option for sock path - config option for transaction_timeout - config option to disable uspd - Align with latest bbf - Added tests --- uspd/Makefile | 4 ++-- uspd/files/uspd.config | 1 + uspd/files/uspd.init | 41 ++++++++++++++++++++++++++++++++++++++++- 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/uspd/Makefile b/uspd/Makefile index 6ab13a39d..aa1bf60d2 100644 --- a/uspd/Makefile +++ b/uspd/Makefile @@ -5,12 +5,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=uspd -PKG_VERSION:=2.1.7 +PKG_VERSION:=2.1.8 LOCAL_DEV:=0 ifneq ($(LOCAL_DEV),1) PKG_SOURCE_PROTO:=git -PKG_SOURCE_VERSION:=34791d784cffe69e0c3b69fb75bc219b25a9b5ab +PKG_SOURCE_VERSION:=1dec7e4bcc8004d142fca195d82a013c1e6dbcb2 PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/uspd.git PKG_SOURCE:=$(PKG_NAME)-$(PKG_SOURCE_VERSION).tar.gz endif diff --git a/uspd/files/uspd.config b/uspd/files/uspd.config index 86a3c9df9..ec28bfe11 100644 --- a/uspd/files/uspd.config +++ b/uspd/files/uspd.config @@ -1,3 +1,4 @@ config uspd 'usp' option granularitylevel '0' + option debug '0' option loglevel '1' diff --git a/uspd/files/uspd.init b/uspd/files/uspd.init index 14c778c11..17901cd22 100644 --- a/uspd/files/uspd.init +++ b/uspd/files/uspd.init @@ -6,9 +6,48 @@ STOP=10 USE_PROCD=1 PROG=/usr/sbin/uspd +validate_uspd_usp_section() +{ + uci_validate_section uspd uspd "usp" \ + 'enabled:bool:true' \ + 'granularitylevel:uinteger' \ + 'debug:bool:false' \ + 'loglevel:uinteger' \ + 'sock:string' \ + 'transaction_timeout:string' +} + +configure_uspd() +{ + local enabled debug sock transaction_timeout + + config_load uspd + + validate_uspd_usp_section || { + log "Validation of usp section failed" + return 1; + } + + [ ${enabled} -eq 0 ] && exit 0 + + if [ ${debug} -eq 1 ]; then + procd_set_param stdout 1 + procd_set_param stderr 1 + fi + + if [ -n "${sock}" ]; then + procd_append_param command -s ${sock} + fi + + if [ -n "${transaction_timeout}" ]; then + procd_append_param command -t ${transaction_timeout} + fi +} + start_service() { - procd_open_instance + procd_open_instance usp procd_set_param command ${PROG} + configure_uspd procd_set_param respawn procd_close_instance }