fff-layer3: Autoconfigure layer3 Router after update

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 <fabian@blaese.de>
[convert to init.d, extend commit message, rebase]
Signed-off-by: Christian Dresel <freifunk@dresel.systems>
This commit is contained in:
Christian Dresel 2020-12-12 20:07:38 +01:00
parent 7e552761f6
commit 38e7dc18e0
2 changed files with 18 additions and 1 deletions

View File

@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=fff-layer3-config
PKG_RELEASE:=1
PKG_RELEASE:=2
PKG_BUILD_DIR:=$(BUILD_DIR)/fff-layer3-config

View File

@ -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
}