Created
June 30, 2017 22:19
-
-
Save airways/796ef2400406d6bf94b6e559d55550d2 to your computer and use it in GitHub Desktop.
Start pppd if ethernet connection has no network, kill it if ethernet comes up
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/sh | |
CONNECTION=1 | |
while [ 1 ] | |
do | |
if ping -q -c 1 -w 1 -I eth0 google.com > /dev/null ; then | |
if [ $CONNECTION -eq 0 ] ; then | |
echo "Ethernet connection is up, killing pppd" | |
killall pppd | |
CONNECTION=1 | |
fi | |
else | |
if [ $CONNECTION -eq 1 ] ; then | |
echo "No ethernet connection, dialing pppd" | |
pppd call gsm | |
CONNECTION=0 | |
fi | |
fi | |
sleep 60 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment