diff options
Diffstat (limited to 'modules/luci-base')
-rw-r--r-- | modules/luci-base/Makefile | 1 | ||||
-rw-r--r-- | modules/luci-base/root/etc/config/ucitrack | 56 | ||||
-rwxr-xr-x | modules/luci-base/root/etc/init.d/ucitrack | 41 | ||||
-rwxr-xr-x | modules/luci-base/root/sbin/luci-reload | 45 |
4 files changed, 32 insertions, 111 deletions
diff --git a/modules/luci-base/Makefile b/modules/luci-base/Makefile index 6913568948..789e6a4bf6 100644 --- a/modules/luci-base/Makefile +++ b/modules/luci-base/Makefile @@ -36,7 +36,6 @@ include $(INCLUDE_DIR)/host-build.mk define Package/luci-base/conffiles /etc/luci-uploads /etc/config/luci -/etc/config/ucitrack endef define Package/luci-base/postinst diff --git a/modules/luci-base/root/etc/config/ucitrack b/modules/luci-base/root/etc/config/ucitrack deleted file mode 100644 index bb4cdbc3c4..0000000000 --- a/modules/luci-base/root/etc/config/ucitrack +++ /dev/null @@ -1,56 +0,0 @@ -config network - option init network - list affects dhcp - -config wireless - list affects network - -config firewall - option init firewall - list affects luci-splash - list affects qos - list affects miniupnpd - -config olsr - option init olsrd - -config dhcp - option init dnsmasq - list affects odhcpd - -config odhcpd - option init odhcpd - -config dropbear - option init dropbear - -config httpd - option init httpd - -config fstab - option exec '/sbin/block mount' - -config qos - option init qos - -config system - option init led - option exec '/etc/init.d/log reload' - list affects luci_statistics - list affects dhcp - -config luci_splash - option init luci_splash - -config upnpd - option init miniupnpd - -config ntpclient - option init ntpclient - -config samba - option init samba - -config tinyproxy - option init tinyproxy - diff --git a/modules/luci-base/root/etc/init.d/ucitrack b/modules/luci-base/root/etc/init.d/ucitrack index 57ac11857f..495949f64f 100755 --- a/modules/luci-base/root/etc/init.d/ucitrack +++ b/modules/luci-base/root/etc/init.d/ucitrack @@ -3,6 +3,8 @@ START=80 USE_PROCD=1 +. "$IPKG_INSTROOT/usr/share/libubox/jshn.sh" + register_init() { local config="$1" local init="$2" @@ -15,13 +17,25 @@ register_init() { } register_trigger() { - local sid="$1" + local uci="$1" + local file="$2" + local config init exec affects affected + local prev - config_get config "$sid" TYPE - config_get init "$sid" init - config_get exec "$sid" exec - config_get affects "$sid" affects + json_set_namespace config prev + json_init + json_load_file "${file}" >/dev/null 2>&1 + json_get_var config 'config' + [ "$config" = "$uci" ] || { + json_set_namespace "$prev" + return + } + json_get_var init 'init' + json_get_var exec 'exec' + json_get_values affects 'affects' + json_cleanup + json_set_namespace "$prev" if [ -n "$init" ]; then register_init "$config" "/etc/init.d/$init" "reload" @@ -48,10 +62,19 @@ register_trigger() { done } -service_triggers() { - config_foreach register_trigger +check_trigger() { + local config="$1" + + local file + + for file in /usr/share/ucitrack/*.json; do + [ -f "$file" ] || continue + register_trigger "$config" "$file" + done } -start_service() { - config_load ucitrack +service_triggers() { + for config in /etc/config/*; do + check_trigger "${config##*/}" + done } diff --git a/modules/luci-base/root/sbin/luci-reload b/modules/luci-base/root/sbin/luci-reload deleted file mode 100755 index cc41da2bb7..0000000000 --- a/modules/luci-base/root/sbin/luci-reload +++ /dev/null @@ -1,45 +0,0 @@ -#!/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" |