[v7,1/2] fff-network: Prevent resetting network config on each reboot

Submitted by Adrian Schmutzler on Aug. 21, 2017, 4:46 p.m.

Details

Message ID 1503333988-5080-1-git-send-email-freifunk@adrianschmutzler.de
State Accepted
Headers show

Commit Message

Adrian Schmutzler Aug. 21, 2017, 4:46 p.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 | 8 ++++----
 1 file changed, 4 insertions(+), 4 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 7ecfa3b..5b06009 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 }')
 
@@ -62,10 +62,9 @@  if ! uci get network.$SWITCHDEV.ifname; then
     fi
 
     uci commit
-    /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
@@ -97,9 +96,10 @@  if [ "$ONE_PORT" = "YES" ]; then
         ETH0MAC="w2ap"
     fi
     uci commit
-    /etc/init.d/network restart
 fi
 
+/etc/init.d/network restart
+
 if [[ -n "$ETHMESHMAC" ]]; then
     if uci get network.ethmesh.macaddr
     then

Comments

Tobias Klaus Aug. 22, 2017, 9:28 a.m.
Hey,

sieht auch gut aus. 
Reviewed-by: Tobias Klaus <tk+ff@meskal.net>


Irgendwie hab ich das Gefühl, dass man sich das mit dem ifname mal genauer 
anschauen sollte.

Am Montag, 21. August 2017, 18:46:27 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 | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/src/packages/fff/fff-network/files/usr/sbin/configurenetwork
> b/src/packages/fff/fff-network/files/usr/sbin/configurenetwork index
> 7ecfa3b..5b06009 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 }')
> 
> @@ -62,10 +62,9 @@ if ! uci get network.$SWITCHDEV.ifname; then
>      fi
> 
>      uci commit
> -    /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
> @@ -97,9 +96,10 @@ if [ "$ONE_PORT" = "YES" ]; then
>          ETH0MAC="w2ap"
>      fi
>      uci commit
> -    /etc/init.d/network restart
>  fi
> 
> +/etc/init.d/network restart
> +
>  if [[ -n "$ETHMESHMAC" ]]; then
>      if uci get network.ethmesh.macaddr
>      then
Tim Niemeyer Sept. 17, 2017, 2:10 p.m.
Hi

Applied. Danke.

Tim

Am Montag, den 21.08.2017, 18:46 +0200 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 | 8
> ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/src/packages/fff/fff-
> network/files/usr/sbin/configurenetwork b/src/packages/fff/fff-
> network/files/usr/sbin/configurenetwork
> index 7ecfa3b..5b06009 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 }')
>  
> @@ -62,10 +62,9 @@ if ! uci get network.$SWITCHDEV.ifname; then
>      fi
>  
>      uci commit
> -    /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
> @@ -97,9 +96,10 @@ if [ "$ONE_PORT" = "YES" ]; then
>          ETH0MAC="w2ap"
>      fi
>      uci commit
> -    /etc/init.d/network restart
>  fi
>  
> +/etc/init.d/network restart
> +
>  if [[ -n "$ETHMESHMAC" ]]; then
>      if uci get network.ethmesh.macaddr
>      then
> -- 
> 2.7.4
>