Hi, I'm setting up a gl-inet mango v2, and I want the switch to control the AP network.
It seemed to me that procd was the recommended way, and with the docs this is what I put in /etc/rc.button/BTN_0:
#!/bin/sh
case "$ACTION" in
released)
uci set wireless.ap.disabled='1'
;;
pressed)
uci del wireless.ap.disabled
;;
esac
# update wifi
wifi
return 0
This works mostly fine, except that when I reboot it the configuration sets it to on, and this script doesn't run until the switch is flipped again.
I could do uci commit every time so it stores state across reboots, but it still won't detect the switch position on boot, so if I flip the switch before I power it on it wouldn't detect it obviously.
What's the proper way to do this? I rather not install more packages.
Interesting. I'll try changing it to switch, how would I configure it then? I saw somewhere in the docs that you can have the configuration in /etc/config/system, not sure how...
If this button is officially intended for switch wifi on or off you can assign also the correct input code like here:
I don't think it's officially intended to do anything, looks like it was meant to be customized. At any rate, I don't want it to rfkill the wifi, I'm keeping the station link on, as that's my uplink, I'm just disabling the AP as I don't really need it
there is a package called slide-switch to use sliding switch functionality. You can install it with opkg.
I think it is the same as your script (it supports more devices of course), but it also adds a init script in /etc/init.d/ and enables it with service xxxxx enable, so that on boot it will check the status of the slide switch and trigger the actions.
You can see here the source (it is a script so you can copy what it does if you want) and read the documentation