Last active
September 25, 2015 03:11
-
-
Save chenyanzhe/035bd1da9c3c3c5b7626 to your computer and use it in GitHub Desktop.
Check network connection status.
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
#!/bin/sh | |
LOGTIME=$(date "+%Y-%m-%d %H:%M:%S") | |
wget --spider --quiet www.google.co.jp | |
if [ "$?" == "0" ]; then | |
echo '['$LOGTIME'] No Problem.' | |
exit 0 | |
else | |
wget --spider --quiet www.baidu.com | |
if [ "$?" == "0" ]; then | |
echo '['$LOGTIME'] Problem decteted, restarting.' | |
/usr/bin/updatelist | |
/etc/init.d/shadowsocks restart | |
/etc/init.d/chinadns restart | |
/etc/init.d/dnsmasq restart | |
else | |
echo '['$LOGTIME'] Network Problem. Do nothing.' | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment