fff-gateway: Autoconfigure gateway after update

Submitted by Fabian Blaese on March 28, 2020, 4:10 p.m.

Details

Message ID 20200328161019.214390-1-fabian@blaese.de
State Rejected
Headers show

Commit Message

Fabian Blaese March 28, 2020, 4:10 p.m.
This adds a script to uci-defaults to automatically call
the appropriate configuregateway commands after an update,
so the configuration of the device is restored.

The changes are applied, if configuregateway is successful.
Otherwise, they are reverted. Due to this, no additional checks for
the configuration are necessary, because the configuregateway script
fails, if the config version is wrong or no configuration exists at all.

Signed-off-by: Fabian Bläse <fabian@blaese.de>
---
Changes from RFC:
- Move configuration command into the if statements condition
- Add comment to uci default script
---
 .../files/etc/uci-defaults/98a-configure-gateway          | 8 ++++++++
 1 file changed, 8 insertions(+)
 create mode 100644 src/packages/fff/fff-gateway/files/etc/uci-defaults/98a-configure-gateway

Patch hide | download patch | download mbox

diff --git a/src/packages/fff/fff-gateway/files/etc/uci-defaults/98a-configure-gateway b/src/packages/fff/fff-gateway/files/etc/uci-defaults/98a-configure-gateway
new file mode 100644
index 0000000..626f230
--- /dev/null
+++ b/src/packages/fff/fff-gateway/files/etc/uci-defaults/98a-configure-gateway
@@ -0,0 +1,8 @@ 
+#!/bin/sh
+
+# Reapply gateway settings, if configuration succeeds
+if yes | configuregateway -c; then
+	configuregateway -a
+else
+	configuregateway -r
+fi

Comments

Robert Langhammer March 28, 2020, 5:22 p.m.
Hi Fabian,

Reviewed-by: Robert Langhammer <rlanghammer@web.de>


Am 28.03.20 um 17:10 schrieb Fabian Bläse:
> This adds a script to uci-defaults to automatically call
> the appropriate configuregateway commands after an update,
> so the configuration of the device is restored.
>
> The changes are applied, if configuregateway is successful.
> Otherwise, they are reverted. Due to this, no additional checks for
> the configuration are necessary, because the configuregateway script
> fails, if the config version is wrong or no configuration exists at all.
>
> Signed-off-by: Fabian Bläse <fabian@blaese.de>
> ---
> Changes from RFC:
> - Move configuration command into the if statements condition
> - Add comment to uci default script
> ---
>  .../files/etc/uci-defaults/98a-configure-gateway          | 8 ++++++++
>  1 file changed, 8 insertions(+)
>  create mode 100644 src/packages/fff/fff-gateway/files/etc/uci-defaults/98a-configure-gateway
>
> diff --git a/src/packages/fff/fff-gateway/files/etc/uci-defaults/98a-configure-gateway b/src/packages/fff/fff-gateway/files/etc/uci-defaults/98a-configure-gateway
> new file mode 100644
> index 0000000..626f230
> --- /dev/null
> +++ b/src/packages/fff/fff-gateway/files/etc/uci-defaults/98a-configure-gateway
> @@ -0,0 +1,8 @@
> +#!/bin/sh
> +
> +# Reapply gateway settings, if configuration succeeds
> +if yes | configuregateway -c; then
> +	configuregateway -a
> +else
> +	configuregateway -r
> +fi
Fabian Blaese March 29, 2020, 11:19 a.m.
Hallo zusammen,

das ganze funktioniert leider noch nicht so ganz, wie ich mir das dachte.

configurenetwork wird durch dieses Skript in uci-defaults leider erst nach configuregateway ausgeführt.
Falls bereits eine Konfiguration vorliegt, werden ggf. schon Dinge konfiguriert, die configurenetwork nicht mehr richtig funktionieren lassen.

Ich hatte gehofft, das hier noch in ein Release vor einem configurenetwork Umbau zu bekommen.
Dafür folgender Vorschlag: configurenetwork in einem uci-defaults Skript vor configuregateway ausführen.
Dass configurenetwork danach in der rc.local erneut ausgeführt wird, sollte kein Problem sein.

Gruß
Fabian
Adrian Schmutzler March 29, 2020, 1:07 p.m.
Hallo,

wenn man das configurenetwork anfasst, geht immer was kaput.

Mir persönlich ist es total egal, aber ich würde empfehlen, mit dem autoconfigure zu warten, bis configurenetwork weg ist (sofern das geplant ist).

Das mit dem manuellen configuregateway ist zwar lästig, aber man weiß zumindest, was passiert. Irgendein configurenetwork Zeitverschiebungsbug wäre viel ekliger.

Disclaimer: Dies ist offensichtlich eine allgemeine Betrachtung. Ich habe mir nicht konkret angesehen, was passiert, wenn man configurenetwork entsprechend zusätzlich laufen lässt.
Dabei bitte beachten, dass configurenetwork ohnehin nur einmal "wirklich" läuft, da es hier ja einen entsprechenden Parameter in network.config gibt.

Beste Grüße

Adrian