Skip to content

Instantly share code, notes, and snippets.

@almsx
Created November 4, 2011 02:02
Show Gist options
  • Save almsx/1338502 to your computer and use it in GitHub Desktop.
Save almsx/1338502 to your computer and use it in GitHub Desktop.
#! /bin/bash
#(c)2011 Alberto Luebbert alberto (At) ideashappy.com
#constant check network connectivity, on lost
#re-start Cards if lost are "more large"
#reboot the system.
#the script check connectivity by ping google
CONNECTION=1
IFDOWN="/sbin/ifdown"
IFUP="/sbin/ifup"
REBOOT="/sbin/reboot"
PINGIP="64.233.169.103"
ETHS="eth0 eth1 eth2 eth3"
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 45
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment