From 8deb9495515b97898514e8ffb8f002c8afe3bfa7 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Thu, 26 Apr 2018 08:52:55 +0200 Subject: treewide: rework uci apply workflow Switch to rpcd based uci apply/rollback workflow which helps to avoid soft- bricking devices by requiring an explicit confirmation call after config apply. When a user now clicks "Save & Apply", LuCI first issues a call to uci apply which commits and reloads configuration, then goes into a polling countdown mode where it repeatedly attempts to call uci confirm. If the committed configuration is sane, the confirm call will go through and cancel rpcd's pending rollback timer. If the configuration change leads to a loss of connectivity (e.g. due to bad firewall rules or similar), the rollback mechanism will kick in after the timeout and revert configuration files and pending changes to the pre-apply state. In order to cover such rare cases where a lost of connectivity is expected and desired, the user is offered an "unchecked" apply option after timing out, which allows committing and applying the changes anyway, without the extra safety checks. As a consequence of this change, the luci-reload mechanism is now completely unsused since rpcd uses ubus config reload signals to reload affected services, which means that only procd-enabled services will receive proper reload treatment with the new workflow. Signed-off-by: Jo-Philipp Wich --- modules/luci-base/root/etc/config/luci | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'modules/luci-base/root/etc') diff --git a/modules/luci-base/root/etc/config/luci b/modules/luci-base/root/etc/config/luci index baa3ac5d1..82c2230e5 100644 --- a/modules/luci-base/root/etc/config/luci +++ b/modules/luci-base/root/etc/config/luci @@ -22,3 +22,9 @@ config internal ccache option enable 1 config internal themes + +config internal apply + option rollback 30 + option holdoff 4 + option timeout 5 + option display 1.5 -- cgit v1.2.3 From 9f796fad3a0cc89df57d4e27ef6d7223a093071c Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Wed, 2 May 2018 10:37:02 +0200 Subject: 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 --- modules/luci-base/root/etc/init.d/ucitrack | 57 ++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100755 modules/luci-base/root/etc/init.d/ucitrack (limited to 'modules/luci-base/root/etc') 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 000000000..27d34fa29 --- /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 +} -- cgit v1.2.3