Created
November 4, 2011 01:07
-
-
Save compermisos/1338412 to your computer and use it in GitHub Desktop.
Reboot network cards on Network Lost
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 | |
#(c)2011-2012 Jesus Christian Cruz Acono JesusChristian (At) Tequilavalley.com | |
#constant check network connectivity, on lost | |
#re-start Cards if lost are "more large" | |
#reboot the system. | |
#the script check connectivity by ping to "arbitrary IP" | |
######config zone###### | |
#IP to make the ping to check, in this moment uses GOOGLE IP (google cant negate the ping) | |
#you can use a "domain name" to "aditional" check de dns resolv | |
PINGIP="64.233.169.103" | |
#interfaces to check (eth. wlan etc) | |
ETHS="eth0 eth1 eth2 eth3" | |
#ifdonw comand | |
IFDOWN="/sbin/ifdown" | |
#if up comand | |
IFUP="/sbin/ifup" | |
#action comand | |
REBOOT="/sbin/reboot" | |
#default wait time | |
SLEEPTIME=45 | |
#defaul initial status | |
CONNECTION=1 | |
####execution zone, no config######## | |
for (( ; ; )) do | |
if ping -c 1 $PINGIP > /dev/null;then | |
CONNECTION=0 | |
else | |
if [ $CONNECTION = 0 ]; then | |
CONNECTION=1 | |
for ETH in $ETHS | |
do | |
$IFDOWN $ETH | |
$IFUP $ETH | |
done | |
fi | |
if [ $CONNECTION = 1 ]; then | |
$REBOOT | |
fi | |
fi | |
sleep $SLEEPTIME | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment