[v5,03/11] fff-network: Prevent resetting network config on each reboot

Submitted by Adrian Schmutzler on July 28, 2017, 11:03 a.m.

Details

Message ID 1501239812-2062-1-git-send-email-freifunk@adrianschmutzler.de
State Superseded
Headers show

Commit Message

Adrian Schmutzler July 28, 2017, 11:03 a.m.
This only sets the switch configs if they are not set yet.
If the network.* file is edited, add FORCEPARSE=1 to apply
the changes.

Fixes #56

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>

Tested-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
---
 src/packages/fff/fff-network/files/usr/sbin/configurenetwork | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/packages/fff/fff-network/files/usr/sbin/configurenetwork b/src/packages/fff/fff-network/files/usr/sbin/configurenetwork
index 63b216a..6f9944a 100755
--- a/src/packages/fff/fff-network/files/usr/sbin/configurenetwork
+++ b/src/packages/fff/fff-network/files/usr/sbin/configurenetwork
@@ -12,7 +12,7 @@ 
 BOARD="$(uci get board.model.name)"
 . /etc/network.$BOARD
 
-if ! uci get network.$SWITCHDEV.ifname; then
+if ! uci -q get network.$SWITCHDEV > /dev/null || [ "$FORCEPARSE" = '1' ] ; then
 
     SWITCHHW=$(swconfig list | awk '{ print $4 }')
 
@@ -65,7 +65,7 @@  if ! uci get network.$SWITCHDEV.ifname; then
     /etc/init.d/network restart
 fi
 
-if [ "$ONE_PORT" = "YES" ]; then
+if [ "$ONE_PORT" = "YES" ] && ( ! uci -q get network.$SWITCHDEV.ifname || [ "$FORCEPARSE" = '1' ] ) ; then
     uci set network.$SWITCHDEV=interface
     uci set network.$SWITCHDEV.ifname=$SWITCHDEV
     if [ "$ETHMODE" = "WAN" ]; then

Comments

Tobias Klaus July 31, 2017, 10:11 p.m.
Hey,

sieht gut aus und behebt ein Problem, das mich auch schon echt genervt hat.

Eine kleine Rückfrage inline.

Viele Grüße
Tobias

Am Freitag, 28. Juli 2017, 13:03:32 CEST schrieb Adrian Schmutzler:
> This only sets the switch configs if they are not set yet.
> If the network.* file is edited, add FORCEPARSE=1 to apply
> the changes.
> 
> Fixes #56
> 
> Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
> 
> Tested-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
> ---
>  src/packages/fff/fff-network/files/usr/sbin/configurenetwork | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/packages/fff/fff-network/files/usr/sbin/configurenetwork
> b/src/packages/fff/fff-network/files/usr/sbin/configurenetwork index
> 63b216a..6f9944a 100755
> --- a/src/packages/fff/fff-network/files/usr/sbin/configurenetwork
> +++ b/src/packages/fff/fff-network/files/usr/sbin/configurenetwork
> @@ -12,7 +12,7 @@
>  BOARD="$(uci get board.model.name)"
>  . /etc/network.$BOARD
> 
> -if ! uci get network.$SWITCHDEV.ifname; then
> +if ! uci -q get network.$SWITCHDEV > /dev/null || [ "$FORCEPARSE" = '1' ] ;
> then
> 
>      SWITCHHW=$(swconfig list | awk '{ print $4 }')
> 
> @@ -65,7 +65,7 @@ if ! uci get network.$SWITCHDEV.ifname; then
>      /etc/init.d/network restart
>  fi
> 
> -if [ "$ONE_PORT" = "YES" ]; then
> +if [ "$ONE_PORT" = "YES" ] && ( ! uci -q get network.$SWITCHDEV.ifname || [
Hier könnte man auch einfach auf "uci -q get network.$SWITCHDEV" testen und 
würde sich dann das uci set 2 Zeilen drunter sparen. Oder übersehe ich das 
was?

> "$FORCEPARSE" = '1' ] ) ; then uci set network.$SWITCHDEV=interface
>      uci set network.$SWITCHDEV.ifname=$SWITCHDEV
>      if [ "$ETHMODE" = "WAN" ]; then
Adrian Schmutzler Aug. 1, 2017, 9:18 p.m.
Hallo Tobias,

zwecks Rückfrage:

Für normale Geräte wird der erste Block (ab Zeile 15) ausgeführt und
network.$SWITCHDEV wird als _switch_ konfiguriert.

Für one-port Geräte wird zusätzlich (!) noch der zweite Block (ab Zeile 68)
ausgeführt und network.$SWITCH wird dann als _interface_, also nicht als
switch,  (um-)konfiguriert. Entsprechend macht die jetzige Bedingung (wie
von mir vorgeschlagen) Sinn um den ursprünglichen Ablauf der
configurenetwork-Datei nachzubilden.

Ob es Sinn macht (und notwendig ist), dass für one-port Geräte beide Blöcke
ausgeführt werden, kann ich nicht beurteilen. Das war aber auch weder deine
Frage noch Sinn meines Patches. ;-)

Grüße

Adrian

-----Original Message-----
From: franken-dev [mailto:franken-dev-bounces@freifunk.net] On Behalf Of
Tobias Klaus
Sent: Dienstag, 1. August 2017 00:12
To: franken-dev@freifunk.net; Adrian Schmutzler
<freifunk@adrianschmutzler.de>
Subject: Re: [PATCH v5 03/11] fff-network: Prevent resetting network config
on each reboot

Hey,

sieht gut aus und behebt ein Problem, das mich auch schon echt genervt hat.

Eine kleine Rückfrage inline.

Viele Grüße
Tobias

Am Freitag, 28. Juli 2017, 13:03:32 CEST schrieb Adrian Schmutzler:
> This only sets the switch configs if they are not set yet.
> If the network.* file is edited, add FORCEPARSE=1 to apply the 
> changes.
> 
> Fixes #56
> 
> Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
> 
> Tested-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
> ---
>  src/packages/fff/fff-network/files/usr/sbin/configurenetwork | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git 
> a/src/packages/fff/fff-network/files/usr/sbin/configurenetwork
> b/src/packages/fff/fff-network/files/usr/sbin/configurenetwork index 
> 63b216a..6f9944a 100755
> --- a/src/packages/fff/fff-network/files/usr/sbin/configurenetwork
> +++ b/src/packages/fff/fff-network/files/usr/sbin/configurenetwork
> @@ -12,7 +12,7 @@
>  BOARD="$(uci get board.model.name)"
>  . /etc/network.$BOARD
> 
> -if ! uci get network.$SWITCHDEV.ifname; then
> +if ! uci -q get network.$SWITCHDEV > /dev/null || [ "$FORCEPARSE" = 
> +'1' ] ;
> then
> 
>      SWITCHHW=$(swconfig list | awk '{ print $4 }')
> 
> @@ -65,7 +65,7 @@ if ! uci get network.$SWITCHDEV.ifname; then
>      /etc/init.d/network restart
>  fi
> 
> -if [ "$ONE_PORT" = "YES" ]; then
> +if [ "$ONE_PORT" = "YES" ] && ( ! uci -q get 
> +network.$SWITCHDEV.ifname || [
Hier könnte man auch einfach auf "uci -q get network.$SWITCHDEV" testen und
würde sich dann das uci set 2 Zeilen drunter sparen. Oder übersehe ich das
was?

> "$FORCEPARSE" = '1' ] ) ; then uci set network.$SWITCHDEV=interface
>      uci set network.$SWITCHDEV.ifname=$SWITCHDEV
>      if [ "$ETHMODE" = "WAN" ]; then


--
franken-dev mailing list
franken-dev@freifunk.net
http://lists.freifunk.net/mailman/listinfo/franken-dev-freifunk.net