Hey All,
This is just a simple script I wrote to help troubleshoot, maybe someone will find it useful.
It pings two IP addresses, then turns on or off the unused LAN/WAN LEDs based on the result.
This code runs an infinite loop, DO NOT add directly to rc.local.
#!/bin/sh
# Turn LEDs on/off based on network connectivity
# $LAN_HOST controls Lan LED, $WAN_HOST controls Wan LED
#
WAN_HOST="8.8.8.8" # Wan host to ping
LAN_HOST="172.16.42.42" # Lan host to ping
################
WAN_LED="/sys/devices/platform/leds-gpio/leds/alfa:blue:wan/brightness"
LAN_LED="/sys/devices/platform/leds-gpio/leds/alfa:blue:lan/brightness"
while : ; do
LAN_CHK=`ping -c 1 -w 4 $LAN_HOST | grep received | cut -d ' ' -f4`
WAN_CHK=`ping -c 1 -w 4 $WAN_HOST | grep received | cut -d ' ' -f4`
WAN_LED_CHK=`cat $WAN_LED`
LAN_LED_CHK=`cat $LAN_LED`
# Check Wan Connection
if [ $WAN_CHK == 0 ] ; then
if [ $WAN_LED_CHK == 1 ]; then
echo 0 > $WAN_LED
fi
else
if [ $WAN_LED_CHK == 0 ]; then
echo 1 > $WAN_LED
fi
fi
# Check Lan Connection
if [ $LAN_CHK == 0 ] ; then
if [ $LAN_LED_CHK == 1 ]; then
echo 0 > $LAN_LED
fi
else
if [ $LAN_LED_CHK == 0 ]; then
echo 1 > $LAN_LED
fi
fi
sleep 2
done