summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2018-05-02 10:37:02 +0200
committerJo-Philipp Wich <jo@mein.io>2018-05-05 23:11:23 +0200
commit9f796fad3a0cc89df57d4e27ef6d7223a093071c (patch)
tree0488108536112160261099b984e933ea959c73a6
parentfd1ddcc41955d7f259c4142b7530063607dcddf4 (diff)
luci-base: add transitional /etc/init.d/ucitrack
Ship an /etc/init.d/ucitrack for spawning a virtual service with the sole purpose to track the configurations and dependencies formerly handled by luci-reload. Once all LuCI supported services ship with procd compatible init scripts, the uci track support can be dropped. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rwxr-xr-xmodules/luci-base/root/etc/init.d/ucitrack57
1 files changed, 57 insertions, 0 deletions
diff --git a/modules/luci-base/root/etc/init.d/ucitrack b/modules/luci-base/root/etc/init.d/ucitrack
new file mode 100755
index 0000000000..27d34fa297
--- /dev/null
+++ b/modules/luci-base/root/etc/init.d/ucitrack
@@ -0,0 +1,57 @@
+#!/bin/sh /etc/rc.common
+
+START=80
+USE_PROCD=1
+
+register_init() {
+ local config="$1"
+ local init="$2"
+ shift; shift
+
+ if [ -x "$init" ] && "$init" enabled && ! grep -sqE 'USE_PROCD=.' "$init"; then
+ logger -t "ucitrack" "Setting up /etc/config/$config reload trigger for non-procd $init"
+ procd_add_config_trigger "config.change" "$config" "$init" "$@"
+ fi
+}
+
+register_trigger() {
+ local sid="$1"
+ local config init exec affects affected
+
+ config_get config "$sid" TYPE
+ config_get init "$sid" init
+ config_get exec "$sid" exec
+ config_get affects "$sid" affects
+
+ if [ -n "$init" ]; then
+ register_init "$config" "/etc/init.d/$init" "reload"
+ fi
+
+ if [ -n "$exec" ]; then
+ case "$exec" in
+ /etc/init.d/*)
+ set -- $exec
+ register_init "$config" "$@"
+ ;;
+ *)
+ logger -t "ucitrack" "Setting up non-init /etc/config/$config reload handler: $exec"
+ procd_add_config_trigger "config.change" "$config" "$exec"
+ ;;
+ esac
+ fi
+
+ for affected in $affects; do
+ logger -t "ucitrack" "Setting up /etc/config/$config reload dependency on /etc/config/$affected"
+ procd_add_config_trigger "config.change" "$affected" \
+ ubus call service event \
+ "$(printf '{"type":"config.change","data":{"package":"%s"}}' $config)"
+ done
+}
+
+service_triggers() {
+ config_foreach register_trigger
+}
+
+start_service() {
+ config_load ucitrack
+}