rtty: Update init script 8189/head
authorJeffery To <jeffery.to@gmail.com>
Tue, 12 Feb 2019 06:34:38 +0000 (14:34 +0800)
committerJeffery To <jeffery.to@gmail.com>
Tue, 12 Feb 2019 06:34:38 +0000 (14:34 +0800)
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 <jeffery.to@gmail.com>
utils/rtty/Makefile
utils/rtty/files/rtty.init

index f157251da774aa47012efbbd55bb02a0483cb102..480ce32051cef9f7204599fc0ced495afb77e3f1 100644 (file)
@@ -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)
index bc34124f188356be56a91a9d8b430e479dd4dfae..f18497af8acc2493847b2ecfd94eb1855417362f 100644 (file)
@@ -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
 }