Skip to content

Instantly share code, notes, and snippets.

@lattera
Created February 10, 2015 05:55
Show Gist options
  • Save lattera/995ffa5e61c18ece601d to your computer and use it in GitHub Desktop.
Save lattera/995ffa5e61c18ece601d to your computer and use it in GitHub Desktop.
Script to bring re0 up on my laptop
#!/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