I'd like to have a script that shuts off the WiFi radio if the WAN in unreachable. I am thinking that I could could a ping command to establish if the WAN is reachable and then use a call to /sbin/wifi
to stop or start depending on the result.
To be clear, the ping command is probably a poor choice. I'd prefer some direct measure of WAN (on my router is eth0.2).
- Is there is better test for WAN connectivity?
- Is there a better toggle of the radio?
2b) If not, how can I call/sbin/wifi
to check the status of the radio and bring it up/down depending on the current state?
Something like this:
#!/bin/ash
if ! ping -q -W1 -c1 1.1.1.1 1>/dev/null; then
# WAN is down
/sbin/wifi down
else
/bin/true
# ping is successful so take no action
# need to add a check to see radio status and turn on if not
fi