Message ID | 1511173625-2869-1-git-send-email-freifunk@adrianschmutzler.de |
---|---|
State | Changes Requested |
Delegated to: | Adrian Schmutzler |
Headers | show |
diff --git a/src/packages/fff/fff-config/Makefile b/src/packages/fff/fff-config/Makefile index fe4f5df..690719a 100644 --- a/src/packages/fff/fff-config/Makefile +++ b/src/packages/fff/fff-config/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=fff-config -PKG_VERSION:=1 +PKG_VERSION:=2 PKG_RELEASE:=1 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) 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..02d716c 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 @@ -28,3 +28,24 @@ 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 fi + +. /lib/functions/fff/wireless + +if [ "$(uci -q get 'fff.wifi.disable24ghz')" = "1" ] ; then + radio="$(wifiGetPhy "2")" + [ -n "$radio" ] && uci -q set "wireless.${radio}.disabled=1" +fi + +if [ "$(uci -q get 'fff.wifi.disable5ghz')" = "1" ] ; then + radio="$(wifiGetPhy "5")" + [ -n "$radio" ] && uci -q set "wireless.${radio}.disabled=1" +fi + +if [ "$(uci -q get 'fff.wifi.disablewifi')" = "1" ] ; then + for phy in $(iw phy | awk '/^Wiphy/{ print $2 }'); do + radio="radio$(echo "$phy" | tr -d -C "0-9")" + uci -q set "wireless.${radio}.disabled=1" + done +fi + +uci -q commit wireless diff --git a/src/packages/fff/fff-wireless/files/lib/functions/fff/wireless b/src/packages/fff/fff-wireless/files/lib/functions/fff/wireless index 5b63397..8288703 100644 --- a/src/packages/fff/fff-wireless/files/lib/functions/fff/wireless +++ b/src/packages/fff/fff-wireless/files/lib/functions/fff/wireless @@ -228,4 +228,26 @@ wifiAddMesh() { echo "${iface}" return 0 } + +wifiGetPhy() { + # Returns the wifi-device (radioX) for a given frequency (2 or 5) + + if [ $# -ne "1" ] + then + return 1 + fi + + local freq=$1 + local radio="" + + for phy in $(iw phy | awk '/^Wiphy/{ print $2 }'); do + if iw phy "$phy" info | grep -q -m1 "${freq}... MHz"; then + radio="radio$(echo "$phy" | tr -d -C "0-9")" + fi + done + + echo "$radio" + return 0 # also returns success if outermost if is false +} + # vim: set noexpandtab:tabstop=4
Hi Am Montag, den 20.11.2017, 11:27 +0100 schrieb Adrian Schmutzler: > By specifying wifi.disable24ghz, wifi.disable5ghz or > wifi.disablewifi in /etc/config/fff, one can permanently > (upgrade-safe) disable WiFi devices (e.g. 5 GHz on C25). Das stimmt so nicht. Du führt hier nur ein Setting ein, welches beim initial-boot ausgewertet wird. Dadurch, dass dieses Setting entkoppelt vom eigenen Mechanismus ist, müsste da eine Funktion her. Diese Funktion kann * das WiFi an/abschalten * den disable State in der wireless config setzen * das disablewifi in der fff config setzen Grüße Tim > > Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de> > > > Tested-by: Adrian Schmutzler <freifunk@adrianschmutzler.de> > > --- > > Changes in v2: > none > --- > src/packages/fff/fff-config/Makefile | 2 +- > .../files/etc/uci-defaults/98-configure-fff | 21 +++++++++++++++++++++ > .../fff-wireless/files/lib/functions/fff/wireless | 22 ++++++++++++++++++++++ > 3 files changed, 44 insertions(+), 1 deletion(-) > > diff --git a/src/packages/fff/fff-config/Makefile b/src/packages/fff/fff-config/Makefile > index fe4f5df..690719a 100644 > --- a/src/packages/fff/fff-config/Makefile > +++ b/src/packages/fff/fff-config/Makefile > @@ -1,7 +1,7 @@ > include $(TOPDIR)/rules.mk > > PKG_NAME:=fff-config > -PKG_VERSION:=1 > +PKG_VERSION:=2 > PKG_RELEASE:=1 > > PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) > 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..02d716c 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 > @@ -28,3 +28,24 @@ 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 > fi > + > +. /lib/functions/fff/wireless > + > +if [ "$(uci -q get 'fff.wifi.disable24ghz')" = "1" ] ; then > > + radio="$(wifiGetPhy "2")" > > + [ -n "$radio" ] && uci -q set "wireless.${radio}.disabled=1" > +fi > + > +if [ "$(uci -q get 'fff.wifi.disable5ghz')" = "1" ] ; then > > + radio="$(wifiGetPhy "5")" > > + [ -n "$radio" ] && uci -q set "wireless.${radio}.disabled=1" > +fi > + > +if [ "$(uci -q get 'fff.wifi.disablewifi')" = "1" ] ; then > > + for phy in $(iw phy | awk '/^Wiphy/{ print $2 }'); do > > + radio="radio$(echo "$phy" | tr -d -C "0-9")" > > + uci -q set "wireless.${radio}.disabled=1" > > + done > +fi > + > +uci -q commit wireless > diff --git a/src/packages/fff/fff-wireless/files/lib/functions/fff/wireless b/src/packages/fff/fff-wireless/files/lib/functions/fff/wireless > index 5b63397..8288703 100644 > --- a/src/packages/fff/fff-wireless/files/lib/functions/fff/wireless > +++ b/src/packages/fff/fff-wireless/files/lib/functions/fff/wireless > @@ -228,4 +228,26 @@ wifiAddMesh() { > > echo "${iface}" > > return 0 > } > + > +wifiGetPhy() { > > + # Returns the wifi-device (radioX) for a given frequency (2 or 5) > + > > + if [ $# -ne "1" ] > > + then > > + return 1 > > + fi > + > > + local freq=$1 > > + local radio="" > + > > + for phy in $(iw phy | awk '/^Wiphy/{ print $2 }'); do > > + if iw phy "$phy" info | grep -q -m1 "${freq}... MHz"; then > > + radio="radio$(echo "$phy" | tr -d -C "0-9")" > > + fi > > + done > + > > + echo "$radio" > > + return 0 # also returns success if outermost if is false > +} > + > # vim: set noexpandtab:tabstop=4 > -- > 2.7.4 >