Created
July 28, 2013 02:46
-
-
Save tzarskyz/6097156 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
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