Message ID | 20200322182620.318397-1-fabian@blaese.de |
---|---|
State | Superseded |
Headers | show |
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..157edad --- /dev/null +++ b/src/packages/fff/fff-gateway/files/etc/uci-defaults/98a-configure-gateway @@ -0,0 +1,10 @@ +#!/bin/sh + +yes | configuregateway -c +success=$? + +if [[ $success -eq 0 ]]; then + configuregateway -a +else + configuregateway -r +fi
Reviewed-by: Christian Dresel <fff@chrisi01.de> Gruß Christian On 22.03.20 19:26, Fabian Bläse wrote: > 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> > --- > .../files/etc/uci-defaults/98a-configure-gateway | 10 ++++++++++ > 1 file changed, 10 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..157edad > --- /dev/null > +++ b/src/packages/fff/fff-gateway/files/etc/uci-defaults/98a-configure-gateway > @@ -0,0 +1,10 @@ > +#!/bin/sh > + > +yes | configuregateway -c > +success=$? > + > +if [[ $success -eq 0 ]]; then > + configuregateway -a > +else > + configuregateway -r > +fi >
Hi, > -----Original Message----- > From: franken-dev [mailto:franken-dev-bounces@freifunk.net] On Behalf > Of Fabian Bläse > Sent: Sonntag, 22. März 2020 19:26 > To: franken-dev@freifunk.net > Subject: [RFC PATCH] fff-gateway: Autoconfigure gateway after update > > 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> > --- > .../files/etc/uci-defaults/98a-configure-gateway | 10 ++++++++++ > 1 file changed, 10 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..157edad > --- /dev/null > +++ b/src/packages/fff/fff-gateway/files/etc/uci-defaults/98a-configure- > +++ gateway > @@ -0,0 +1,10 @@ > +#!/bin/sh > + > +yes | configuregateway -c > +success=$? > + > +if [[ $success -eq 0 ]]; then Sieht nach bash aus. Besser: [ "$success" = "0" ] Grüße Adrian > + configuregateway -a > +else > + configuregateway -r > +fi > -- > 2.25.2
Hi, On 22.03.20 20:20, mail@adrianschmutzler.de wrote: >> 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..157edad >> --- /dev/null >> +++ b/src/packages/fff/fff-gateway/files/etc/uci-defaults/98a-configure- >> +++ gateway >> @@ -0,0 +1,10 @@ >> +#!/bin/sh >> + >> +yes | configuregateway -c >> +success=$? >> + >> +if [[ $success -eq 0 ]]; then > > Sieht nach bash aus. > > Besser: [ "$success" = "0" ] Warum ist das besser? Die busybox shell auf unseren Kisten kann mit [[ $success -eq 0 ]] umgehen.. Gruß Fabian
Hi,
> Besser: [ "$success" = "0" ]
Warum ist das besser?
Die busybox shell auf unseren Kisten kann mit [[ $success -eq 0 ]] umgehen..
Die kann zwar damit umgehen, das ist aber Nettigkeit, eigtl. sind die double brackets bash-spezifisch. Siehe shellcheck:
SC2039: In POSIX sh, [[ ]] is undefined.
Die Anführungszeichen sind mehr zur Sicherheit, das sollte in dem Fall auch ohne nicht kaputt gehen.
Gruß
Fabian
Hi, am einfachsten schiebt man sowas in das if als Bedingung. Ohne Umweg über eine Variable: if yes | configuregateway -c ; then Viele Grüße Robert Am 22.03.20 um 20:30 schrieb mail@adrianschmutzler.de: > Hi, > >> Besser: [ "$success" = "0" ] > Warum ist das besser? > Die busybox shell auf unseren Kisten kann mit [[ $success -eq 0 ]] umgehen.. > > Die kann zwar damit umgehen, das ist aber Nettigkeit, eigtl. sind die double brackets bash-spezifisch. Siehe shellcheck: > > SC2039: In POSIX sh, [[ ]] is undefined. > > Die Anführungszeichen sind mehr zur Sicherheit, das sollte in dem Fall auch ohne nicht kaputt gehen. > > Gruß > Fabian
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> --- .../files/etc/uci-defaults/98a-configure-gateway | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/packages/fff/fff-gateway/files/etc/uci-defaults/98a-configure-gateway