Skip to content

Instantly share code, notes, and snippets.

@tzarskyz
Created July 28, 2013 02:46
Show Gist options
  • Save tzarskyz/6097156 to your computer and use it in GitHub Desktop.
Save tzarskyz/6097156 to your computer and use it in GitHub Desktop.
#!/bin/bash
oldgw=10.211.55.1
vpngw=10.100.0.1
function xxtest () {
ifconfig|grep $1&&return 1
return 0
}
function xxcon () {
poff
route del default gw $oldgw
route del default gw $vpngw
route add default gw $oldgw
pon inebium
echo "connecting"
until [[ `xxtest ppp0` ]]; do
echo "..."
sleep 1
done
echo "connected!"
route del default gw $oldgw
route del default gw $vpngw
route add default gw $vpngw
}
function xxnet () {
/etc/rc.d/network restart
echo "restarting network"
until [[ `xxtest eth0` ]]; do
echo "..."
sleep 1
done
echo "network restarted!"
}
while [[ 1 ]]; do
xxtest eth0
if [[ $? == 0 ]]; then
xxnet
fi
xxtest ppp0
if [[ $? == 0 ]]; then
xxcon
/etc/rc.d/dnsmasq restart
fi
sleep 15
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment