diff options
author | John Crispin <john@openwrt.org> | 2013-11-25 08:34:47 +0000 |
---|---|---|
committer | John Crispin <john@openwrt.org> | 2013-11-25 08:34:47 +0000 |
commit | 91de2648e948fc9163e16b2babd9e7e808bde94c (patch) | |
tree | 81d2c91fe1d2ddd9a8b7d46c52c97e7e2535a31d /package/system/procd | |
parent | acec292e325c764e6c9d0160f554e75f5d07aa7a (diff) | |
download | mtk-20170518-91de2648e948fc9163e16b2babd9e7e808bde94c.zip mtk-20170518-91de2648e948fc9163e16b2babd9e7e808bde94c.tar.gz mtk-20170518-91de2648e948fc9163e16b2babd9e7e808bde94c.tar.bz2 |
procd: update procd.sh to make use of the new validate_data tool
Signed-off-by: John Crispin <blogic@openwrt.org>
SVN-Revision: 38908
Diffstat (limited to 'package/system/procd')
-rw-r--r-- | package/system/procd/files/procd.sh | 60 |
1 files changed, 8 insertions, 52 deletions
diff --git a/package/system/procd/files/procd.sh b/package/system/procd/files/procd.sh index d058c4f..ddb6d95 100644 --- a/package/system/procd/files/procd.sh +++ b/package/system/procd/files/procd.sh @@ -217,59 +217,15 @@ _procd_kill() { uci_validate_section() { - local error=0 - - [ "$4" = "" ] && return 1 - [ "$3" = "" ] && { - json_add_object - json_add_string "package" "$1" - json_add_string "type" "$2" - json_add_object "data" - - shift; shift; shift - - while [ -n "$1" ]; do - local tmp=${1#*:} - json_add_string "${1%%:*}" "${tmp%%:*}" - shift - done - - json_close_object - json_close_object - return 0 - } - - local section="${3}" - config_load "${1}" + local package="$1" + local type="$2" + local name="$3" + local error shift; shift; shift - - while [ -n "$1" ]; do - local name=${1%%:*} - local tmp=${1#*:} - local type=${tmp%%:*} - local default="" - - [ "$tmp" = "$type" ] || default=${tmp#*:} - - shift - config_get "${name}" "${section}" "${name}" - eval val=\$$name - - [ "$type" = "bool" ] && { - case "$val" in - 1|on|true|enabled) val=1;; - 0|off|false|disabled) val=0;; - *) val="";; - esac - } - [ -z "$val" ] && val=${default} - eval $name=\"$val\" - [ -z "$val" ] || { - /sbin/validate_data "${type}" "${val}" - [ $? -eq 0 ] || error="$((error + 1))" - } - done - + local result=`/sbin/validate_data "$package" "$type" "$name" $@ 2> /dev/null` + error=$? + eval "$result" + [ "$error" = "0" ] || `/sbin/validate_data "$package" "$type" "$name" $@ 1> /dev/null` return $error } |