From 6fe053bcf7673590332dfa7759e17a0424212d2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Bl=C3=A4se?= Date: Sat, 12 Dec 2020 20:07:38 +0100 Subject: [PATCH] fff-layer3-config: Autoconfigure layer3 router after update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This adds a script to init.d to automatically call the appropriate configure-layer3 commands after an upgrade, so the configuration of the device is restored. The changes are applied if configure-layer3 is successful. Otherwise, they are reverted. Due to this, no additional checks for the configuration are necessary: The configure-layer3 script will fail if the config version is wrong or no configuration exists at all. After executing the script destroys itself. With START=99, the execution happens _after_ uci-defaults and configurenetwork, and no interference is expected. Signed-off-by: Fabian Bläse [convert to init.d, extend commit message, rebase] Signed-off-by: Christian Dresel Reviewed-by: Robert Langhammer Reviewed-by: Adrian Schmutzler --- src/packages/fff/fff-layer3-config/Makefile | 2 +- .../files/etc/init.d/fff-layer3-update | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100755 src/packages/fff/fff-layer3-config/files/etc/init.d/fff-layer3-update diff --git a/src/packages/fff/fff-layer3-config/Makefile b/src/packages/fff/fff-layer3-config/Makefile index cd499a51..9d4eb716 100644 --- a/src/packages/fff/fff-layer3-config/Makefile +++ b/src/packages/fff/fff-layer3-config/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=fff-layer3-config -PKG_RELEASE:=2 +PKG_RELEASE:=3 PKG_BUILD_DIR:=$(BUILD_DIR)/fff-layer3-config diff --git a/src/packages/fff/fff-layer3-config/files/etc/init.d/fff-layer3-update b/src/packages/fff/fff-layer3-config/files/etc/init.d/fff-layer3-update new file mode 100755 index 00000000..2f06d1c8 --- /dev/null +++ b/src/packages/fff/fff-layer3-config/files/etc/init.d/fff-layer3-update @@ -0,0 +1,17 @@ +#!/bin/sh /etc/rc.common + +START=99 + +boot() { + # Reapply gateway settings, if configuration succeeds + if yes | configure-layer3 -c; then + configure-layer3 -a + else + configure-layer3 -r + fi + + # first we disable the init.d + /etc/init.d/fff-layer3-update disable + # we must delete the symlink manually + rm -f /etc/rc.d/S99fff-layer3-update +}