From 447d95a048b32afe9d91ff2c50ed49fc1500ea99 Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Tue, 12 Feb 2019 14:34:38 +0800 Subject: [PATCH] rtty: Update init script This replaces the use of uci_validate_section() with uci_load_validate(), which removes the need to declare local variables for every config option. This also adds a service_triggers() function. Signed-off-by: Jeffery To --- utils/rtty/Makefile | 2 +- utils/rtty/files/rtty.init | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/utils/rtty/Makefile b/utils/rtty/Makefile index f157251da..480ce3205 100644 --- a/utils/rtty/Makefile +++ b/utils/rtty/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=rtty PKG_VERSION:=6.5.0 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_VERSION:=v$(PKG_VERSION) diff --git a/utils/rtty/files/rtty.init b/utils/rtty/files/rtty.init index bc34124f1..f18497af8 100644 --- a/utils/rtty/files/rtty.init +++ b/utils/rtty/files/rtty.init @@ -5,13 +5,8 @@ START=99 BIN=/usr/sbin/rtty -start_rtty() { - . /lib/functions/network.sh - - local cfg="$1" - local interface ifname id description host port ssl - - uci_validate_section rtty rtty "${1}" \ +validate_rtty_section() { + uci_load_validate rtty rtty "$1" "$2" \ 'interface:uci("network", "@interface"):lan' \ 'id:maxlength(63)' \ 'description:maxlength(126)' \ @@ -19,8 +14,14 @@ start_rtty() { 'port:port' \ 'ssl:bool:0' \ 'keepalive:uinteger:5' +} - [ $? -ne 0 ] && { +start_rtty() { + . /lib/functions/network.sh + + local ifname + + [ "$2" = 0 ] || { echo "validation failed" >&2 return 1 } @@ -54,5 +55,10 @@ start_rtty() { start_service() { config_load rtty - config_foreach start_rtty rtty + config_foreach validate_rtty_section rtty start_rtty +} + +service_triggers() { + procd_add_reload_trigger "rtty" + procd_add_validation validate_rtty_section }