Created
February 10, 2015 05:55
-
-
Save lattera/995ffa5e61c18ece601d to your computer and use it in GitHub Desktop.
Script to bring re0 up on my laptop
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
#!/usr/local/bin/zsh | |
runit="true" | |
while [ ${runit} = "true" ]; do | |
ps wwaux | grep dhclient | grep -q re0 | |
if [ ${?} -eq 0 ]; then | |
breakout="false" | |
while [ ${breakout} = "false" ]; do | |
breakout="true" | |
for pid in $(ps wwaux | grep dhclient | grep re0 | awk '{print $2;}'); do | |
kill ${PID} | |
sleep 3 | |
kill -KILL ${pid} | |
breakout="false" | |
done | |
done | |
fi | |
ifconfig re0 down | |
ifconfig re0 -tso | |
sleep 15 | |
ifconfig re0 up | |
sleep 15 | |
ifconfig re0 | grep -qF 'status: active' | |
if [ ${?} -eq 0 ]; then | |
dhclient re0 | |
ifconfig re0 | grep -q inet | |
if [ ${?} -eq 0 ]; then | |
ifconfig re0 | grep -qF 'inet 0.0.0.0' | |
if [ ! ${?} -eq 0 ]; then | |
pfctl -ef /etc/pf.conf | |
break | |
fi | |
fi | |
else | |
runit="false" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment