Skip to content

Instantly share code, notes, and snippets.

@fapestniegd
Created February 22, 2013 22:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fapestniegd/c60b3951625d00fe58db to your computer and use it in GitHub Desktop.
Save fapestniegd/c60b3951625d00fe58db to your computer and use it in GitHub Desktop.
#!/bin/bash
export PATH="/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin"
check_state(){
DGW=$(route -n | grep "^0.0.0.0 " | awk '{print $2}')
if [ -z "${DGW}" ]; then
echo 4
return;
fi
SA_COUNT=$(racoonctl show-sa isakmp| grep -v "^Destination" | wc -l)
if [ "${SA_COUNT}" -lt 1 ]; then
echo 5
return;
fi
ping -w1 -c1 10.100.0.6 > /dev/null 2>&1
if [ $? -ne 0 ];then
echo 6
return;
fi
echo 0
return;
}
while [ 1 ];do
if [ -f /tmp/current_error_level ]; then
ERROR_LEVEL=$(cat /tmp/current_error_level)
if [ -z "${ERROR_LEVEL}" ];then
echo 0 > /dev/error_led
ERROR_LEVEL=0
fi
export COUNT=0;
export ERROR=1;
export MAX=${ERROR_LEVEL};
while [ "${COUNT}" -lt "${MAX}" ]; do
if [ "${ERROR}" -eq "1" ];then
export ERROR=0
else
export ERROR=1;
export COUNT=$(expr ${COUNT} + 1);
fi
echo $ERROR > /dev/error_led;
sleep 0.4
done;
echo 0 > /dev/error_led
sleep 3
fi
check_state > /tmp/current_error_level
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment