Skip to content

Instantly share code, notes, and snippets.

@erm3nda
Created June 27, 2019 02:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erm3nda/6ea9957125d5ed9a96ee24281ae41ed8 to your computer and use it in GitHub Desktop.
Save erm3nda/6ea9957125d5ed9a96ee24281ae41ed8 to your computer and use it in GitHub Desktop.
WPS automation
#!/bin/bash
# automate WPS Push Button using wpa_supplicant
# see also: https://w1.fi/cgit/hostap/plain/wpa_supplicant/README-WPS
# make this script run at boot-time
INHIBIT="/etc/wpa_supplicant/wps_inhibit"
if [ -e $INHIBIT ]; then
exit 0
fi
while /bin/true; do
state="$( wpa_cli status | sed -n 's/wpa_state=\(.*\)/\1/p')"
if [ "$state" = "COMPLETED" ]; then
touch $INHIBIT
exit 0
fi
wpa_cli wps_pbc
# wps_pbc returns immediately but will start an action that lasts 2 minutes
sleep 120
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment