kmyths Posted June 20, 2012 Share Posted June 20, 2012 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 Quote Link to comment Share on other sites More sharing options...
Anton Posted June 20, 2012 Share Posted June 20, 2012 Neat little script, thanks! this will be handy for squeezing all the juice we can out our pineapples :D, would be cool if this could also be a module with auto start, lets face it we dont really need to see and of the leds when we are, "pen testing" lol - Anton. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.