Hello people,
tl;dr version:
How can I turn LED lights on/off from a cronjob? Or, is there a better way of turning a LED based on a command output?
Long version:
I recently installed OpenWRT on a tp-link Archer C7 router and it's working great!
I have configured it to use PIA vpn provider with OpenVPN. Anyone interested I did a quick script for setting up and enable specific configs
I have also configured the router's WPS button to turn on/off the OpenVPN service as a quick way to turn the VPN on/off.
One thing that I haven't been able to do yet, is to make the LEDs work the way I want.
I would like to have the router's WPS LED to be ON
when OpenVPN is running and OFF
when it's not.
But I couldn't yet make it work with a cronjob. Maybe I'm missing something regarding how cronjobs work? Not sure.
Here's the cronjob I'm trying:
* * * * * echo "$([ $(pgrep -f openvpn) ] && echo default-on || echo none)" > /sys/class/leds/tp-link\:green\:wps/trigger
Manually running the command has the desired effect, but nothing happens with the cronjob.
Nothing very useful from the logs (from my understanding at least) either.
Ultimately, I want the light to be on/off according to the output of a command. I'm going for a cronjob as this is what I can think of. Happy to try another way if there's any.
Another thing that came to my mind is some sort of hook for OpenVPN, like: OpenVPN starts, turn light on. OpenVPN stops, turn ligh off. But I have not found such a thing yet.
Any ideas where to go from here?