2016-09-01 07:05:40 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
RestoreWifi() {
|
2016-09-30 07:52:35 +00:00
|
|
|
echo "[$(date)] restore-wifi-async.sh: Restarting WiFi"
|
2019-07-30 23:00:51 +00:00
|
|
|
|
2016-09-01 07:05:40 +00:00
|
|
|
./enable-wifi.sh
|
2019-07-30 23:00:51 +00:00
|
|
|
|
|
|
|
# Much like we do in the UI, ensure wpa_supplicant did its job properly, first.
|
|
|
|
# Pilfered from https://github.com/shermp/Kobo-UNCaGED/pull/21 ;)
|
|
|
|
wpac_timeout=0
|
|
|
|
while ! wpa_cli status | grep -q "wpa_state=COMPLETED"; do
|
|
|
|
# If wpa_supplicant hasn't connected within 10 seconds, assume it never will, and tear down WiFi
|
|
|
|
if [ ${wpac_timeout} -ge 40 ]; then
|
|
|
|
echo "[$(date)] restore-wifi-async.sh: Failed to connect to preferred AP!"
|
|
|
|
./disable-wifi.sh
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
usleep 250000
|
|
|
|
wpac_timeout=$((wpac_timeout + 1))
|
|
|
|
done
|
|
|
|
|
2016-09-01 07:05:40 +00:00
|
|
|
./obtain-ip.sh
|
2019-07-30 23:00:51 +00:00
|
|
|
|
2016-09-30 07:52:35 +00:00
|
|
|
echo "[$(date)] restore-wifi-async.sh: Restarted WiFi"
|
2016-09-01 07:05:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
RestoreWifi &
|