Last active
August 29, 2015 14:13
-
-
Save wcypierre/24dece267ae424ac8453 to your computer and use it in GitHub Desktop.
interface log
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 | |
# cron script for checking wlan connectivity | |
# change xxx to whatever IP you want to check. | |
IP_FOR_TEST="xxx" | |
PING_COUNT=1 | |
PING="/bin/ping" | |
IFUP="/sbin/ifup" | |
IFDOWN="/sbin/ifdown --force" | |
INTERFACE="wimax0" | |
FFLAG="/opt/check_lan/stuck.fflg" | |
# Red LED - uses GPIO17 | |
echo "17" > /sys/class/gpio/export | |
echo "out" > /sys/class/gpio/gpio17/direction | |
# Green LED - uses GPIO22 | |
echo "22" > /sys/class/gpio/export | |
echo "out" > /sys/class/gpio/gpio22/direction | |
# ping test | |
$PING -c $PING_COUNT $IP_FOR_TEST > /dev/null 2> /dev/null | |
if [ $? -ge 1 ] | |
then | |
logger "$INTERFACE seems to be down, trying to bring it up..." | |
echo "1" > /sys/class/gpio/gpio17/value # lit the red led since the interface is down | |
echo "0" > /sys/class/gpio/gpio22/value | |
if [ -e $FFLAG ] | |
then | |
logger "$INTERFACE is still down, REBOOT to recover ..." | |
rm -f $FFLAG 2>/dev/null | |
sudo reboot | |
else | |
touch $FFLAG | |
logger $(sudo $IFDOWN $INTERFACE) | |
sleep 10 | |
logger $(sudo $IFUP $INTERFACE) | |
fi | |
else | |
echo "0" > /sys/class/gpio/gpio17/value | |
echo "1" > /sys/class/gpio/gpio22/value | |
# logger "$INTERFACE is up" | |
rm -f $FFLAG 2>/dev/null | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment