[PATCH v2] configurehood: Provide options to disable AP and Mesh for WiFi
Adrian Schmutzler
freifunk at adrianschmutzler.de
Fr Mär 9 23:43:35 CET 2018
Each WiFi interface can be disabled individually.
To apply the settings after having changed uci, one has to
uci commit fff
rm /www/hood/keyxchangev2data
configurehood
Fixes #97.
Fixes misconfiguration in case of mixed IBSS/802.11s.
Signed-off-by: Adrian Schmutzler <freifunk at adrianschmutzler.de>
---
Changes in v2:
- Use separate settings for 2.4 and 5 GHz (an no combined setting)
- Add default values to fff-config
- Add comments to fff-config setup script
- Fix double equal sign in affected area of configurehood
- Rewrite section to reduce ifs and logical operators
---
.../files/etc/uci-defaults/98-configure-fff | 9 +++++++
.../fff/fff-hoods/files/usr/sbin/configurehood | 31 ++++++++++++++--------
2 files changed, 29 insertions(+), 11 deletions(-)
diff --git a/src/packages/fff/fff-config/files/etc/uci-defaults/98-configure-fff b/src/packages/fff/fff-config/files/etc/uci-defaults/98-configure-fff
index aa6ac42..8433b7f 100644
--- a/src/packages/fff/fff-config/files/etc/uci-defaults/98-configure-fff
+++ b/src/packages/fff/fff-config/files/etc/uci-defaults/98-configure-fff
@@ -4,11 +4,19 @@
touch /etc/config/fff
+# default config values
if ! uci -q get fff.system > /dev/null ; then
uci -q set fff.system=fff
uci -q set "fff.system.hostname=FFF"
fi
+uci -q set fff.wifi=fff
+uci -q get fff.wifi.disablew2ap > /dev/null || uci -q set "fff.wifi.disablew2ap=0"
+uci -q get fff.wifi.disablew5ap > /dev/null || uci -q set "fff.wifi.disablew5ap=0"
+uci -q get fff.wifi.disablew2mesh > /dev/null || uci -q set "fff.wifi.disablew2mesh=0"
+uci -q get fff.wifi.disablew5mesh > /dev/null || uci -q set "fff.wifi.disablew5mesh=0"
+
+# apply config to other uci entries
FFF_hostname=$(uci -q get "fff.system.hostname")
test -n "${FFF_hostname}" && uci -q set "system. at system[0].hostname=${FFF_hostname}"
test -n "${FFF_hostname}" && echo "${FFF_hostname}" > /proc/sys/kernel/hostname
@@ -24,6 +32,7 @@ uci -q set "simple-tc.example.limit_egress=${traffic_out}"
uci -q commit
+# run configuration scripts
poe_passthrough=$(uci -q get "fff.poe_passthrough.active")
if [ "$poe_passthrough" = "1" ] && [ -s /usr/lib/fff-support/activate_poe_passthrough.sh ] ; then
/usr/lib/fff-support/activate_poe_passthrough.sh
diff --git a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
index fd4126e..ae92f96 100755
--- a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
+++ b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
@@ -260,26 +260,35 @@ if [ -s "$hoodfile" ]; then
fi
for phy in $(iw phy | awk '/^Wiphy/{ print $2 }'); do
- radio="$(wifiAddPhyCond "$phy" "2" "$chan2ghz")"
- radio5="$(wifiAddPhyCond "$phy" "5" "$chan5ghz")"
- [ -n "$radio5" ] && radio="$radio5"
+ radio="$(wifiAddPhyCond "$phy" "5" "$chan5ghz")"
+
+ if [ -n "$radio" ] ; then
+ # 5 GHz
+ mesh_type="$mesh_type5"
+ disableap="fff.wifi.disablew5ap"
+ disablemesh="fff.wifi.disablew5mesh"
+ else
+ # 2.4 GHz
+ radio="$(wifiAddPhyCond "$phy" "2" "$chan2ghz")"
+ mesh_type="$mesh_type2"
+ disableap="fff.wifi.disablew2ap"
+ disablemesh="fff.wifi.disablew2mesh"
+ fi
- if ! wifiAddAP "$radio" "$essid" "mesh" "ap" "0"; then
+ if [ "$(uci -q get "$disableap")" != "1" ] && ! wifiAddAP "$radio" "$essid" "mesh" "ap" "0"; then
echo "Can't add AP interface on $radio."
exit 1
fi
- # add 802.11s mesh if type == "802.11s"
- if ( [ -n "$radio5" ] && [ "$mesh_type5" == "802.11s" ] ) || [ "$mesh_type2" == "802.11s" ]; then
- if ! wifiAddMesh "$radio" "$mesh_id"; then
+ if [ "$(uci -q get "$disablemesh")" != "1" ] ; then
+ # add 802.11s mesh if type = "802.11s"
+ if [ "$mesh_type" = "802.11s" ] && ! wifiAddMesh "$radio" "$mesh_id"; then
echo "Can't add Mesh interface on $radio."
exit 1
fi
- fi
- # add IBSS mesh if type == "ibss"
- if ( [ -n "$radio5" ] && [ "$mesh_type5" == "ibss" ] ) || [ "$mesh_type2" == "ibss" ]; then
- if ! wifiAddAdHocMesh "$radio" "$mesh_essid" "$mesh_bssid"; then
+ # add IBSS mesh if type = "ibss"
+ if [ "$mesh_type" = "ibss" ] && ! wifiAddAdHocMesh "$radio" "$mesh_essid" "$mesh_bssid"; then
echo "Can't add AdHocMesh interface on $radio."
exit 1
fi
--
2.7.4
Mehr Informationen über die Mailingliste franken-dev