aboutsummaryrefslogtreecommitdiff
path: root/utils/pservice
diff options
context:
space:
mode:
authorYousong Zhou <yszhou4tech@gmail.com>2019-08-06 04:14:47 +0000
committerYousong Zhou <yszhou4tech@gmail.com>2019-08-12 08:23:03 +0000
commit2b469232e64fdade79983130648203d562dce1d6 (patch)
treeeea0337329705d5b2d41ec1f4280118d5132a57f /utils/pservice
parent5d7d44d605dc71c3edf157bae3fe35f07a3f516f (diff)
pservice: shorten code
- use uci_load_validate() - remove stop_service() - fix validation of "args" option Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
Diffstat (limited to 'utils/pservice')
-rw-r--r--utils/pservice/Makefile2
-rwxr-xr-xutils/pservice/files/pservice.init42
2 files changed, 11 insertions, 33 deletions
diff --git a/utils/pservice/Makefile b/utils/pservice/Makefile
index 3d1923b90..56a2ac097 100644
--- a/utils/pservice/Makefile
+++ b/utils/pservice/Makefile
@@ -4,7 +4,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=pservice
PKG_VERSION:=2017-08-29
-PKG_RELEASE=1
+PKG_RELEASE=2
PKG_MAINTAINER:=Yousong Zhou <yszhou4tech@gmail.com>
diff --git a/utils/pservice/files/pservice.init b/utils/pservice/files/pservice.init
index 0a275f8f7..3a3ce022c 100755
--- a/utils/pservice/files/pservice.init
+++ b/utils/pservice/files/pservice.init
@@ -1,5 +1,5 @@
#!/bin/sh /etc/rc.common
-# Copyright (C) 2017 Yousong Zhou
+# Copyright (C) 2017-2019 Yousong Zhou
START=99
@@ -12,13 +12,14 @@ pservice_list_cb() {
procd_append_param "$param" "$val"
}
-pservice() {
+pservice_instance() {
local cfg="$1"
- eval "$(validate_pservice_section "$cfg" pservice_validate_mklocal)"
- validate_pservice_section "$cfg" || return 1
[ "$disabled" = 0 ] || return 0
- [ -x "$command" ] || return 1
+ [ -x "$command" ] || {
+ echo "$command is not executable" >&2
+ return 1
+ }
procd_open_instance "$name"
procd_set_param command "$command"
@@ -39,43 +40,20 @@ pservice() {
start_service() {
config_load 'pservice'
- config_foreach pservice pservice
-}
-
-stop_service() {
- true
+ config_foreach validate_pservice_section pservice pservice_instance
}
service_triggers() {
- procd_open_validate
- validate_pservice_section
- procd_close_validate
-}
-
-pservice_validate_mklocal() {
- local tuple opts
-
- shift 2
- for tuple in "$@"; do
- opts="${tuple%%:*} $opts"
- done
- [ -z "$opts" ] || echo "local $opts"
-}
-
-pservice_validate() {
- uci_validate_section pservice "$@"
+ procd_add_validation validate_pservice_section
}
validate_pservice_section() {
- local cfg="$1"; shift
- local func="$1"; shift
-
- "${func:-pservice_validate}" pservice "$cfg" \
+ uci_load_validate pservice pservice "$1" "$2" \
"disabled:bool:0" \
"name:string" \
"env:regex('^[a-zA-Z_][a-zA-Z0-9_]*=.*$')" \
"command:file" \
- "args:list(string)" \
+ "args:string" \
"stderr:bool:0" \
"stdout:bool:0" \
"respawn_threshold:uinteger:3600" \