credits to original script modified from keolafu for ar750
Here’s what it does GL-USB150 has two lights power and wwan.
by default the power stays on and wwan just flashes with traffic.
Here is what the scripts below change them too
power button is blinking when there is no internet connectivity and solid when internet is up
wlan button is solid when you are connected to openvpn with a default route of 10.8.x.x address and blinking when it is connected to wireguard with a default route of 10.0.x.x address.
-
goto http://192.168.8.1/cgi-bin/luci/admin/system/leds and uncheck “default” and set both triggers to “none”
-
grab a beer
-
- upload the two scripts below (e.g. to /usr/bin/). If sftp does not work you can use in your ssh console: cat > full-path-and-filename and simply copy and paste the content of the script (use ctrl-d to get back to your prompt).
Be careful, the cat > command overwrites everything of the file. Check better twice the correct spelling of the filename before you enter into the command
- upload the two scripts below (e.g. to /usr/bin/). If sftp does not work you can use in your ssh console: cat > full-path-and-filename and simply copy and paste the content of the script (use ctrl-d to get back to your prompt).
-
- chmod u+x full-path-and-filename
-
- now you can check the scripts by calling them without arguments.
-
- to let them call frequently by the system add the cron configuration with the glinet admin web tool or crontab -e
inet_check.sh
#!/bin/sh
# /usr/bin/inet_check.sh
# crontab -e
# */1 * * * * test -x /usr/bin/inet_check.sh && /usr/bin/inet_check.sh
#
inet_led=/sys/devices/platform/leds-gpio/leds/gl-usb150:green:power/brightness
inet_trig=/sys/devices/platform/leds-gpio/leds/gl-usb150:green:power/trigger
nc -z -w 5 8.8.8.8 53 >/dev/null 2>&1
online=$?
if [ $online -eq 0 ]; then
echo "none" > $inet_trig
echo 1 > $inet_led
else
echo "timer" > $inet_trig
fi
vpn_check.sh
#!/bin/sh
# /usr/bin/vpn_test.sh
#
# wlan led is off when wireguard or openvpn is not connected
# wlan led is solid when you are connected to openvpn with a 10.8.x.x address
# and
# wlan led is blinking when it is connected to a wireguard 10.0.x.x address.
# leds may be wrong if you are connectd to one of these networks by wan or wwan
#
# crontab -e
# or place below line without "# "
# */1 * * * * test -x /usr/bin/vpn_check.sh && /usr/bin/vpn_check.sh
# or via browser
# in http:/192.168.8.1/cgi-bin/luci/admin/system/crontab
#
enabled=$(uci get glconfig.openvpn.enable)
wgenabled=$(uci get wireguard.@proxy[0].enable)
vpn_led=/sys/devices/platform/leds-gpio/leds/gl-usb150:green:wlan/brightness
vpn_trig=/sys/devices/platform/leds-gpio/leds/gl-usb150:green:wlan/trigger
first_hop1=$(traceroute 8.8.8.8 2>&1 | head -2 | tail -1 | awk '{print $2}')
first_hop="${first_hop1:0:4}"
if [ "$first_hop" == "10.8" ] && [ "$enabled" == "1" ];then
echo "none" > $vpn_trig
echo 1 > $vpn_led
elif [ "$first_hop" == "10.0" ] && [ "$wgenabled" == "1" ]; then
echo "timer" > $vpn_trig
echo 1 > $vpn_led
else
echo "none" > $vpn_trig
echo 0 > $vpn_led
exit 0;
fi