Last active
February 6, 2019 21:08
-
-
Save bionicvapourboy/061767d5b3b9b87f2038e141b8418f20 to your computer and use it in GitHub Desktop.
With some Access Poits or WiFi Extenders I need to reconnect in order to restore the normal connectivity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# With some access point my wifi loses connection | |
# The connection is usually restored as long I reconnect to the AP | |
# This script detects ping failure to the Google DNS server | |
# then try to turn off and on wifi network | |
# WARNING: It does not check the default WiFi to reconnect to | |
status="OFF"; | |
while true | |
do | |
if ping -q -c 1 -W 1 8.8.8.8 &>/dev/null;then | |
if [ "${status}" == "OFF" ];then | |
echo "Internet UP"; | |
status="ON" | |
fi | |
else | |
echo "Internet DOWN" | |
echo "Rebooting ..." | |
status="OFF" | |
networksetup -setairportpower en0 off; | |
networksetup -setairportpower en0 on; | |
fi | |
sleep 2 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment