aboutsummaryrefslogtreecommitdiffstats
path: root/package/network
diff options
context:
space:
mode:
authorRaphaël Mélotte <raphael.melotte@mind.be>2021-10-29 10:45:06 +0200
committerDaniel Golle <daniel@makrotopia.org>2021-12-27 16:32:02 +0000
commit69ce75fb12526e11f79618a7cbedb32335b1f2bc (patch)
tree8cb549b119c201246ae16bafa6783de689657b76 /package/network
parentc555c34dd15c11a901ea4dfcadbcc0e4f3072160 (diff)
downloadupstream-69ce75fb12526e11f79618a7cbedb32335b1f2bc.tar.gz
upstream-69ce75fb12526e11f79618a7cbedb32335b1f2bc.tar.bz2
upstream-69ce75fb12526e11f79618a7cbedb32335b1f2bc.zip
hostapd: add fallback for WPS on stations
Up to now the WPS script triggered WPS on the stations only if it could not trigger it successfully on any hostapd instance. In a Multi-AP context, there can be a need (to establish a new wireless backhaul link) to trigger WPS on the stations, regardless of whether there is already a hostapd instance configured or not. The current script makes it impossible, as if hostapd is running and configured, WPS would always be triggered on hostapd only. To allow both possibilities, the following changes are made: - Change the "pressed" action to "release", so that we can make use of the "$SEEN" variables (to know for how long the button was pressed). - If the button is pressed for less than 3 seconds, keep the original behavior. - If the button is pressed for 3 seconds or more, trigger WPS on the stations, regardless of the status of any running hostapd instance. - Add comments explaining both behaviors. - While at it, replace the usage of '-a' with a '[] && []' construct (see [1]). This gives users a "fallback" mechanism to onboard a device to a Multi-AP network, even if the device already has a configured hostapd instance running. [1]: https://github.com/koalaman/shellcheck/wiki/SC2166 Signed-off-by: Raphaël Mélotte <raphael.melotte@mind.be>
Diffstat (limited to 'package/network')
-rw-r--r--package/network/services/hostapd/files/wps-hotplug.sh21
1 files changed, 14 insertions, 7 deletions
diff --git a/package/network/services/hostapd/files/wps-hotplug.sh b/package/network/services/hostapd/files/wps-hotplug.sh
index d00939d769..073bdd1868 100644
--- a/package/network/services/hostapd/files/wps-hotplug.sh
+++ b/package/network/services/hostapd/files/wps-hotplug.sh
@@ -38,13 +38,20 @@ wps_catch_credentials() {
done
}
-if [ "$ACTION" = "pressed" -a "$BUTTON" = "wps" ]; then
- wps_done=0
- ubusobjs="$( ubus -S list hostapd.* )"
- for ubusobj in $ubusobjs; do
- ubus -S call $ubusobj wps_start && wps_done=1
- done
- [ $wps_done = 0 ] || return 0
+if [ "$ACTION" = "released" ] && [ "$BUTTON" = "wps" ]; then
+ # If the button was pressed for 3 seconds or more, trigger WPS on
+ # wpa_supplicant only, no matter if hostapd is running or not. If
+ # was pressed for less than 3 seconds, try triggering on
+ # hostapd. If there is no hostapd instance to trigger it on or WPS
+ # is not enabled on them, trigger it on wpa_supplicant.
+ if [ "$SEEN" -lt 3 ] ; then
+ wps_done=0
+ ubusobjs="$( ubus -S list hostapd.* )"
+ for ubusobj in $ubusobjs; do
+ ubus -S call $ubusobj wps_start && wps_done=1
+ done
+ [ $wps_done = 0 ] || return 0
+ fi
wps_done=0
ubusobjs="$( ubus -S list wpa_supplicant.* )"
for ubusobj in $ubusobjs; do