Optimize return value checks for luci-reload

This commit is contained in:
Steven Barth 2008-09-23 23:07:04 +00:00
parent c9bbacbbcc
commit 8e7544e059

View file

@ -4,22 +4,25 @@
apply_config() { apply_config() {
config_get init "$1" init config_get init "$1" init
config_get exec "$1" exec config_get exec "$1" exec
config_get test "$1" test
[ -n "$init" ] && reload_init "$2" "$init" [ -n "$init" ] && reload_init "$2" "$init" "$test"
[ -n "$exec" ] && reload_exec "$2" "$exec" [ -n "$exec" ] && reload_exec "$2" "$exec" "$test"
} }
reload_exec() { reload_exec() {
[ -x $2 ] && { [ -x $2 ] && {
echo "Reloading $1... " echo "Reloading $1... "
$2 >/dev/null 2>&1 || echo "!!! Failed to reload $1 !!!" $2 >/dev/null 2>&1
[ -n "$3" -a "$?" != "$3" ] && echo '!!! Failed to reload' $1 '!!!'
} }
} }
reload_init() { reload_init() {
[ -x /etc/init.d/$2 ] && /etc/init.d/$2 enabled && { [ -x /etc/init.d/$2 ] && /etc/init.d/$2 enabled && {
echo "Reloading $1... " echo "Reloading $1... "
/etc/init.d/$2 reload >/dev/null 2>&1 || echo "!!! Failed to reload $1 !!!" /etc/init.d/$2 reload >/dev/null 2>&1
[ -n "$3" -a "$?" != "$3" ] && echo '!!! Failed to reload' $1 '!!!'
} }
} }
@ -28,4 +31,4 @@ config_load ucitrack
for i in $* for i in $*
do do
config_foreach apply_config $i $i config_foreach apply_config $i $i
done done