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
-
- 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
2 Likes
so I revisited these scripts and noticed a change where
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
is now called
vpn_led=/sys/devices/platform/leds/leds/gl-usb150:orange:wlan/brightness
vpn_trig=/sys/devices/platform/leds/leds/gl-usb150:orange:wlan/trigger
and also you must go into http://192.168.22.1/cgi-bin/luci/admin/system/leds
and change ath9k-phy0 to gl-usb150:orange:wlan
this may be something different in the 3.2-19.07.7 or perhaps a gl-enhancement
(we never call it a bug or a mistake to the good guys) both leds on the device are physically green and I don’t remember what version I wrote this for. if someone could please verify if theirs is green or orange for wlan that has done a fresh install. I believe mine was an upgrade.
and a quick note that */1 means every minute in the crontab so */5 means every five minutes. and one last note if your wireguard tunnel is something other than 10.0.x.x or openvpn tunnel is something other than 10.8.x.x you can change the the two instances of ‘’’
if [ "$first_hop" == "10.8" ] && [ "$enabled" == "1" ];then
to
if [ "$first_hop" == "10.8" ] || [ "$enabled" == "1" ];then
and
elif [ "$first_hop" == "10.0" ] && [ "$wgenabled" == "1" ]; then
to
elif [ "$first_hop" == "10.0" ] || [ "$wgenabled" == "1" ]; then
1 Like