Created
October 20, 2015 11:13
-
-
Save gdevlugt/a226d41980c917216d54 to your computer and use it in GitHub Desktop.
Simple rudimentary script for Mac OS X which restarts Wifi if the network is unreachable. I need this script because my Mac doesn't work nice with my ISP's cable modem by Ubee.
This file contains 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
#!/bin/bash | |
# | |
# Restart Wifi if network connection doesn't respond. | |
# Usage: Open Terminal, and execute this script. | |
# Optimally you want to use a terminal multiplexer like screen to keep it running | |
# | |
while : | |
do | |
ping -c 3 google.nl | |
if [[ $? -ne 0 ]]; then | |
osascript -e 'display notification "Could not ping google.nl, restarting Wifi connection" with title "Restarting Wifi" sound name "Submarine"' | |
networksetup -setairportpower en0 off | |
sleep 5 | |
networksetup -setairportpower en0 on | |
fi | |
sleep 5 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment