From e7dfba0d03aa18f7b0f521702cb8d9172bf0d1c6 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 16 Aug 2014 15:15:24 +0200 Subject: [PATCH] gluon-setup-mode: cleanup and upgrade fix Since switching to Barrier Breaker/procd, we'd not notice if we were upgrading from a version before renaming the config file to gluon-setup-mode as the upgrade scripts run after the preinit. Fix this by checking later during setup mode init again and rebooting into the regular run mode if we detect this case. --- .../gluon/setup-mode/rc.d/S15gluon-setup-mode | 12 ++++++++++- .../files/lib/preinit/90_setup_mode | 21 ++++++------------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/gluon/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/S15gluon-setup-mode b/gluon/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/S15gluon-setup-mode index b6c1136..f62edc3 100755 --- a/gluon/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/S15gluon-setup-mode +++ b/gluon/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/S15gluon-setup-mode @@ -4,7 +4,17 @@ START=15 boot() { - lua -luci -e 'require "luci.model.uci"; uci_state=luci.model.uci.cursor_state(); uci_state:section("gluon-setup-mode", "setup_mode", nil, { running = "1" }); uci_state:save("gluon-setup-mode")' + local enabled="$(uci -q get 'gluon-setup-mode.@setup_mode[0].enabled')" + local configured="$(uci -q get 'gluon-setup-mode.@setup_mode[0].configured')" + uci set 'gluon-setup-mode.@setup_mode[0].enabled=0' uci commit gluon-setup-mode + + if [ "$enabled" = 1 -o "$configured" != 1 ]; then + lua -e 'uci_state=require("luci.model.uci").cursor_state(); uci_state:section("gluon-setup-mode", "setup_mode", nil, { running = "1" }); uci_state:save("gluon-setup-mode")' + else + # This can happen after an upgrade from a version before the config file was called gluon-setup-mode + # We'll just reboot to return to the normal mode... + reboot + fi } diff --git a/gluon/gluon-setup-mode/files/lib/preinit/90_setup_mode b/gluon/gluon-setup-mode/files/lib/preinit/90_setup_mode index 31f64f6..396b4f7 100644 --- a/gluon/gluon-setup-mode/files/lib/preinit/90_setup_mode +++ b/gluon/gluon-setup-mode/files/lib/preinit/90_setup_mode @@ -1,22 +1,13 @@ #!/bin/sh -check_enable() { - local enabled - local configured - - config_get enabled "$1" enabled - config_get configured "$1" configured - - if [ "$enabled" = 1 -o "$configured" != 1 ]; then - echo '/lib/gluon/setup-mode/rc.d' > /tmp/rc_d_path - fi -} - - setup_mode_enable() { - config_load gluon-setup-mode - config_foreach check_enable setup_mode + local enabled="$(uci -q get 'gluon-setup-mode.@setup_mode[0].enabled')" + local configured="$(uci -q get 'gluon-setup-mode.@setup_mode[0].configured')" + + if [ "$enabled" = 1 -o "$configured" != 1 ]; then + echo '/lib/gluon/setup-mode/rc.d' > /tmp/rc_d_path + fi } boot_hook_add preinit_main setup_mode_enable