In this example I used a green led to indicate that internet connection is available and a red one to warn when internet connection is not available (Router ADB P.DG A4001N1), but if you have just one led, you can set a fixed light when internet is available and a flash light when it is not available.
let's create the script:
nano /root/internet-check.sh
#!/bin/sh
#
#start looping
while [ true ]; do
#checking if internet is available (google)
/usr/bin/wget -o -q --spider http://google.com > /dev/null
if [[ $? -eq 0 ]]; then
#internet is available, switch on the green led and off the red one
/bin/echo "0" > /sys/devices/gpio-leds/leds/A4001N1:red:inet/brightness
/bin/echo "1" > /sys/devices/gpio-leds/leds/A4001N1:green:inet/brightness
else
#internet is not available, switch off the green led and on the red one
/bin/echo "0" > /sys/devices/gpio-leds/leds/A4001N1:green:inet/brightness
/bin/echo "1" > /sys/devices/gpio-leds/leds/A4001N1:red:inet/brightness
fi
#sleep 60 seconds and then repeat checking
sleep 60
done
note: change ".../sys/devices/gpio-leds/leds/A4001N1:green:inet/..." with the correct path for your router.
then give the right permissions to the above script:
chmod 755 /root/internet-check.sh
test the script:
/bin/sh /root/internet-check.sh
to launch the script at the startup, put the following line right before the "exit 0" line in the "/etc/rc.local" file
/bin/sh /root/internet-check.sh &