configurehood: Improve conditions for configap setup

Submitted by Adrian Schmutzler on Feb. 7, 2018, 2:28 p.m.

Details

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

Commit Message

Adrian Schmutzler Feb. 7, 2018, 2:28 p.m.
This addresses a bunch of issues:
- Previously, only the presence of w2configap was checked. With
  only 5 GHz, this would have caused a recreation every 5 min.
  (Note that this is only valid for a 5 GHz only device, as we
  always create all interfaces for disabled radios)
- The two outer if-statements are merged
- We now check for presence of wXmesh to enable wXconfigap. Although
  this is no necessity (as the hood file contains the whole config)
  this assumes that a disabled wXmesh means no intent of the owner
  to connect to other devices on this radio.
- With the dependency of wXconfigap from wXmesh, this patch now
  enables the deactivation of hood file transmitting by disabling
  meshing in the hood file

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
---
 .../fff/fff-hoods/files/usr/sbin/configurehood     | 41 ++++++++++++----------
 1 file changed, 22 insertions(+), 19 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
index 80e82ec..90d81d1 100755
--- a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
+++ b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
@@ -38,27 +38,30 @@  hasInternet() {
 
 # Hidden AP check
 
-if [ -s "$hoodfilecopy" ] && ! uci -q get wireless.w2configap > /dev/null ; then
-	if isGatewayAvailable ; then
-
-		for radio in $(uci show wireless | sed -n 's,.*\.\([a-z0-9]*\)=wifi-device,\1,p'); do
-			channel=$(uci get "wireless.${radio}.channel")
-			iface="configap2"
-			if [ "$channel" -gt "14" ]; then
-				iface="configap5"
-			fi
-			uci set network.${iface}=interface
-			uci set network.${iface}.proto='static'
-			uci set network.${iface}.ip6addr='fe80::1/64'
-			if ! wifiAddAP "$radio" "config.franken.freifunk.net" "$iface" "configap" "1"; then
-				echo "Can't add Config interface on $radio."
-				exit 1
-			fi
-		done
+if [ -s "$hoodfilecopy" ] && isGatewayAvailable ; then
+	for radio in $(uci show wireless | sed -n 's,.*\.\([a-z0-9]*\)=wifi-device,\1,p'); do
+		freq="2"
+		if [ "$(uci get "wireless.${radio}.channel")" -gt "14" ]; then
+			freq="5"
+		fi
+		# Break: wXconfig is up
+		uci -q get "wireless.w${freq}configap" > /dev/null && continue
+		# Break: No mesh interface
+		(uci -q get "wireless.w${freq}mesh" > /dev/null || uci -q get "wireless.w${freq}ibss" > /dev/null) || continue
+		
+		# Create configap
+		iface="configap$freq"
+		uci set network.${iface}=interface
+		uci set network.${iface}.proto='static'
+		uci set network.${iface}.ip6addr='fe80::1/64'
 		uci commit network
+		if ! wifiAddAP "$radio" "config.franken.freifunk.net" "$iface" "configap" "1"; then
+			echo "Can't add Config interface on $radio."
+			exit 1
+		fi
+	done
 
-		wifi
-	fi
+	wifi
 fi
 
 lat=$(uci -q get fff.system.latitude)

Comments

Christian Dresel Feb. 7, 2018, 4:49 p.m.
Hallo

Sieht soweit gut aus, mit den sed stolper ich noch etwas rum aber es tut
wohl was es soll (alle radios ausgeben) :) Daher

Reviewed-by: Christian Dresel <fff@chrisi01.de>

mfg

Christian

On 07.02.2018 15:28, Adrian Schmutzler wrote:
> This addresses a bunch of issues:
> - Previously, only the presence of w2configap was checked. With
>   only 5 GHz, this would have caused a recreation every 5 min.
>   (Note that this is only valid for a 5 GHz only device, as we
>   always create all interfaces for disabled radios)
> - The two outer if-statements are merged
> - We now check for presence of wXmesh to enable wXconfigap. Although
>   this is no necessity (as the hood file contains the whole config)
>   this assumes that a disabled wXmesh means no intent of the owner
>   to connect to other devices on this radio.
> - With the dependency of wXconfigap from wXmesh, this patch now
>   enables the deactivation of hood file transmitting by disabling
>   meshing in the hood file
> 
> Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
> ---
>  .../fff/fff-hoods/files/usr/sbin/configurehood     | 41 ++++++++++++----------
>  1 file changed, 22 insertions(+), 19 deletions(-)
> 
> diff --git a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
> index 80e82ec..90d81d1 100755
> --- a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
> +++ b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
> @@ -38,27 +38,30 @@ hasInternet() {
>  
>  # Hidden AP check
>  
> -if [ -s "$hoodfilecopy" ] && ! uci -q get wireless.w2configap > /dev/null ; then
> -	if isGatewayAvailable ; then
> -
> -		for radio in $(uci show wireless | sed -n 's,.*\.\([a-z0-9]*\)=wifi-device,\1,p'); do
> -			channel=$(uci get "wireless.${radio}.channel")
> -			iface="configap2"
> -			if [ "$channel" -gt "14" ]; then
> -				iface="configap5"
> -			fi
> -			uci set network.${iface}=interface
> -			uci set network.${iface}.proto='static'
> -			uci set network.${iface}.ip6addr='fe80::1/64'
> -			if ! wifiAddAP "$radio" "config.franken.freifunk.net" "$iface" "configap" "1"; then
> -				echo "Can't add Config interface on $radio."
> -				exit 1
> -			fi
> -		done
> +if [ -s "$hoodfilecopy" ] && isGatewayAvailable ; then
> +	for radio in $(uci show wireless | sed -n 's,.*\.\([a-z0-9]*\)=wifi-device,\1,p'); do
> +		freq="2"
> +		if [ "$(uci get "wireless.${radio}.channel")" -gt "14" ]; then
> +			freq="5"
> +		fi
> +		# Break: wXconfig is up
> +		uci -q get "wireless.w${freq}configap" > /dev/null && continue
> +		# Break: No mesh interface
> +		(uci -q get "wireless.w${freq}mesh" > /dev/null || uci -q get "wireless.w${freq}ibss" > /dev/null) || continue
> +		
> +		# Create configap
> +		iface="configap$freq"
> +		uci set network.${iface}=interface
> +		uci set network.${iface}.proto='static'
> +		uci set network.${iface}.ip6addr='fe80::1/64'
>  		uci commit network
> +		if ! wifiAddAP "$radio" "config.franken.freifunk.net" "$iface" "configap" "1"; then
> +			echo "Can't add Config interface on $radio."
> +			exit 1
> +		fi
> +	done
>  
> -		wifi
> -	fi
> +	wifi
>  fi
>  
>  lat=$(uci -q get fff.system.latitude)
>
Tim Niemeyer Feb. 10, 2018, 6:34 p.m.
Hi

Reviewed-by: Tim Niemeyer <tim@tn-x.org>

Tim

Am 7. Februar 2018 15:28:33 MEZ schrieb Adrian Schmutzler <freifunk@adrianschmutzler.de>:
>This addresses a bunch of issues:
>- Previously, only the presence of w2configap was checked. With
>  only 5 GHz, this would have caused a recreation every 5 min.
>  (Note that this is only valid for a 5 GHz only device, as we
>  always create all interfaces for disabled radios)
>- The two outer if-statements are merged
>- We now check for presence of wXmesh to enable wXconfigap. Although
>  this is no necessity (as the hood file contains the whole config)
>  this assumes that a disabled wXmesh means no intent of the owner
>  to connect to other devices on this radio.
>- With the dependency of wXconfigap from wXmesh, this patch now
>  enables the deactivation of hood file transmitting by disabling
>  meshing in the hood file
>
>Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
>---
>.../fff/fff-hoods/files/usr/sbin/configurehood     | 41
>++++++++++++----------
> 1 file changed, 22 insertions(+), 19 deletions(-)
>
>diff --git a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
>b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
>index 80e82ec..90d81d1 100755
>--- a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
>+++ b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
>@@ -38,27 +38,30 @@ hasInternet() {
> 
> # Hidden AP check
> 
>-if [ -s "$hoodfilecopy" ] && ! uci -q get wireless.w2configap >
>/dev/null ; then
>-	if isGatewayAvailable ; then
>-
>-		for radio in $(uci show wireless | sed -n
>'s,.*\.\([a-z0-9]*\)=wifi-device,\1,p'); do
>-			channel=$(uci get "wireless.${radio}.channel")
>-			iface="configap2"
>-			if [ "$channel" -gt "14" ]; then
>-				iface="configap5"
>-			fi
>-			uci set network.${iface}=interface
>-			uci set network.${iface}.proto='static'
>-			uci set network.${iface}.ip6addr='fe80::1/64'
>-			if ! wifiAddAP "$radio" "config.franken.freifunk.net" "$iface"
>"configap" "1"; then
>-				echo "Can't add Config interface on $radio."
>-				exit 1
>-			fi
>-		done
>+if [ -s "$hoodfilecopy" ] && isGatewayAvailable ; then
>+	for radio in $(uci show wireless | sed -n
>'s,.*\.\([a-z0-9]*\)=wifi-device,\1,p'); do
>+		freq="2"
>+		if [ "$(uci get "wireless.${radio}.channel")" -gt "14" ]; then
>+			freq="5"
>+		fi
>+		# Break: wXconfig is up
>+		uci -q get "wireless.w${freq}configap" > /dev/null && continue
>+		# Break: No mesh interface
>+		(uci -q get "wireless.w${freq}mesh" > /dev/null || uci -q get
>"wireless.w${freq}ibss" > /dev/null) || continue
>+		
>+		# Create configap
>+		iface="configap$freq"
>+		uci set network.${iface}=interface
>+		uci set network.${iface}.proto='static'
>+		uci set network.${iface}.ip6addr='fe80::1/64'
> 		uci commit network
>+		if ! wifiAddAP "$radio" "config.franken.freifunk.net" "$iface"
>"configap" "1"; then
>+			echo "Can't add Config interface on $radio."
>+			exit 1
>+		fi
>+	done
> 
>-		wifi
>-	fi
>+	wifi
> fi
> 
> lat=$(uci -q get fff.system.latitude)
Tim Niemeyer Feb. 10, 2018, 11:07 p.m.
Hi

Applied.

Tim

Am Mittwoch, den 07.02.2018, 15:28 +0100 schrieb Adrian Schmutzler:
> This addresses a bunch of issues:
> - Previously, only the presence of w2configap was checked. With
>   only 5 GHz, this would have caused a recreation every 5 min.
>   (Note that this is only valid for a 5 GHz only device, as we
>   always create all interfaces for disabled radios)
> - The two outer if-statements are merged
> - We now check for presence of wXmesh to enable wXconfigap. Although
>   this is no necessity (as the hood file contains the whole config)
>   this assumes that a disabled wXmesh means no intent of the owner
>   to connect to other devices on this radio.
> - With the dependency of wXconfigap from wXmesh, this patch now
>   enables the deactivation of hood file transmitting by disabling
>   meshing in the hood file
> 
> Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
> ---
>  .../fff/fff-hoods/files/usr/sbin/configurehood     | 41
> ++++++++++++----------
>  1 file changed, 22 insertions(+), 19 deletions(-)
> 
> diff --git a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
> b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
> index 80e82ec..90d81d1 100755
> --- a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
> +++ b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
> @@ -38,27 +38,30 @@ hasInternet() {
>  
>  # Hidden AP check
>  
> -if [ -s "$hoodfilecopy" ] && ! uci -q get wireless.w2configap >
> /dev/null ; then
> -	if isGatewayAvailable ; then
> -
> -		for radio in $(uci show wireless | sed -n
> 's,.*\.\([a-z0-9]*\)=wifi-device,\1,p'); do
> -			channel=$(uci get
> "wireless.${radio}.channel")
> -			iface="configap2"
> -			if [ "$channel" -gt "14" ]; then
> -				iface="configap5"
> -			fi
> -			uci set network.${iface}=interface
> -			uci set network.${iface}.proto='static'
> -			uci set
> network.${iface}.ip6addr='fe80::1/64'
> -			if ! wifiAddAP "$radio"
> "config.franken.freifunk.net" "$iface" "configap" "1"; then
> -				echo "Can't add Config interface on
> $radio."
> -				exit 1
> -			fi
> -		done
> +if [ -s "$hoodfilecopy" ] && isGatewayAvailable ; then
> +	for radio in $(uci show wireless | sed -n 's,.*\.\([a-z0-
> 9]*\)=wifi-device,\1,p'); do
> +		freq="2"
> +		if [ "$(uci get "wireless.${radio}.channel")" -gt
> "14" ]; then
> +			freq="5"
> +		fi
> +		# Break: wXconfig is up
> +		uci -q get "wireless.w${freq}configap" > /dev/null
> && continue
> +		# Break: No mesh interface
> +		(uci -q get "wireless.w${freq}mesh" > /dev/null ||
> uci -q get "wireless.w${freq}ibss" > /dev/null) || continue
> +		
> +		# Create configap
> +		iface="configap$freq"
> +		uci set network.${iface}=interface
> +		uci set network.${iface}.proto='static'
> +		uci set network.${iface}.ip6addr='fe80::1/64'
>  		uci commit network
> +		if ! wifiAddAP "$radio"
> "config.franken.freifunk.net" "$iface" "configap" "1"; then
> +			echo "Can't add Config interface on $radio."
> +			exit 1
> +		fi
> +	done
>  
> -		wifi
> -	fi
> +	wifi
>  fi
>  
>  lat=$(uci -q get fff.system.latitude)
> -- 
> 2.7.4
>