My goal is to change the LED on my Opal to `gl_led both’ when openvpn is active and the toggle switch is in the ON position (with VPN enable as the action in settings).
I found a script for the mt1300 and adjusted it for the Opal and it works fine by adding it to rc.local. Looking at /usr/bin/switchaction
, I see a lock file listed at /var/lock/switch.lock
, but do not see the lock file in that directory when the switch is toggled and also, the LED is not staying at `gl_led both daemon’ and is alternating back to white solid.
Is there a way to make the LED stay “both solid” when the VPN is active?
Also, I want to add the script to the OVPN section at line 122 of usr/bin/switchaction
with a way to exit/quit the script if the lock file is not present. Is there another lock file created by the switch other than the following? The script repeats every 10 seconds, so having it run when the switch is on and exit the script when the switch is toggled off (lock file removed) should be just adding the same to the VPN LED script, but I have not been successful. I do not see any change in the /var/lock
directory when toggling the switch.
LOCK=/var/lock/switch.lock
if [ -f "$LOCK" ];then
exit 0
#!/bin/sh
ip="9.9.9.9"
count="1"
timeout="1"
gl_led off
gl_led white daemon
while true; do
status=$(ping -q -c "$count" -W "$timeout" "$ip" > /dev/null 2>&1 && echo "ok" || echo "fail")
if [ "$status" = "ok" ]; then
if [ -d /sys/class/net/tun* ]; then
gl_led both daemon
else
gl_led white_breath daemon
fi
else
gl_led blue_flash fast daemon
fi
sleep 10
done
Any input is appreciated on how to execute/quit the script based on the toggle switch position and also on how to keep the LED “solid both” when the ping is successful. It changes the LED every 10 seconds with the script in rc.local when the VPN is active, so that may be the best I can do.
The script will show “both solid” when the VPN is connected, “white breath” when the VPN is off and modem/WAN is connected and “blue_flash fast” if the modem/WAN is not connected and the VPN is trying to connect.