X-Git-Url: https://git.archive.openwrt.org/?a=blobdiff_plain;f=modules%2Fluci-base%2Froot%2Fsbin%2Fluci-reload;fp=modules%2Fluci-base%2Froot%2Fsbin%2Fluci-reload;h=cc41da2bb7fde75ba2bfcd1c0b0ab10a2a4f9eda;hb=1bb4822dca6113f73e3bc89e2acf15935e6f8e92;hp=0000000000000000000000000000000000000000;hpb=9edd0e46c3f880727738ce8ca6ff1c8b85f99ef4;p=project%2Fluci.git diff --git a/modules/luci-base/root/sbin/luci-reload b/modules/luci-base/root/sbin/luci-reload new file mode 100755 index 000000000..cc41da2bb --- /dev/null +++ b/modules/luci-base/root/sbin/luci-reload @@ -0,0 +1,45 @@ +#!/bin/sh +. /lib/functions.sh + +apply_config() { + config_get init "$1" init + config_get exec "$1" exec + config_get test "$1" test + + echo "$2" > "/var/run/luci-reload-status" + + [ -n "$init" ] && reload_init "$2" "$init" "$test" + [ -n "$exec" ] && reload_exec "$2" "$exec" "$test" +} + +reload_exec() { + local service="$1" + local ok="$3" + set -- $2 + local cmd="$1"; shift + + [ -x "$cmd" ] && { + echo "Reloading $service... " + ( $cmd "$@" ) 2>/dev/null 1>&2 + [ -n "$ok" -a "$?" != "$ok" ] && echo '!!! Failed to reload' $service '!!!' + } +} + +reload_init() { + [ -x /etc/init.d/$2 ] && /etc/init.d/$2 enabled && { + echo "Reloading $1... " + /etc/init.d/$2 reload >/dev/null 2>&1 + [ -n "$3" -a "$?" != "$3" ] && echo '!!! Failed to reload' $1 '!!!' + } +} + +lock "/var/run/luci-reload" + +config_load ucitrack + +for i in $*; do + config_foreach apply_config $i $i +done + +rm -f "/var/run/luci-reload-status" +lock -u "/var/run/luci-reload"