Last active
August 29, 2015 14:12
-
-
Save cdlewis/20260b2b101e7f09fed9 to your computer and use it in GitHub Desktop.
manual_dhcp.sh
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 | |
# Make sure only root can run our script | |
if [[ $EUID -ne 0 ]]; then | |
echo "This script must be run as root" 1>&2 | |
exit 1 | |
fi | |
while true; do | |
count=$(ping -c 2 -s 1 -t 2 google.com | grep -E " 5?0\.0% packet loss") | |
if [ -z "$count" ]; then | |
echo "$(date): Packet drop, renewing DHCP" | |
ipconfig set en0 DHCP | |
sleep 10 | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment