Check connectivity and switch on/off a LED (GL-AR150)
Written by pmd -
Shell script that will check if there is connectivity to a defined website every 60 seconds and switch ON/OFF the led :
while [ true ]; do
/usr/bin/wget -q --tries=2 --spider http://google.com
if [ $? -eq 0 ]; then
#echo "Connected ! LED OFF."
echo "none" > /sys/class/leds/gl-ar150:orange:wlan/trigger
#echo "Not connected ! LED ON."
echo "default-on" > /sys/class/leds/gl-ar150:orange:wlan/trigger
Schell script to autostart the above script :
killall -9 WANLED
Now let's make these script executable and started at startup:
# chmod +x /usr/bin/WANLED
# chmod +x /etc/init.d/WANLED
# /etc/init.d/WANLED enable
# /etc/init.d/WANLED start
Now the orange LED should be ON when there is no connectivity to Google.
FYI OpenWRT in use was : OpenWrt 19.07.2, r10947-65030d81f3
Source: LED, Start script at startup, LED on when Internet is available