Hello,
New here to the forum so let me know if I need to move this somewhere. Been reading posts and openwrt documentation for a few hours now and mostly got my script working other than one small problem. Every time I toggle the switch the $action always reads “ON”.
Here is my script I’m adding to the /usr/bin/switchaction file;
#!/bin/sh
. /lib/functions/gl_util.sh
toggle_tor(){
local action=$1
if [ "$action" = "OFF" ];then
tor_switch off
else
tor_switch on
fi
}
toggle_wifi(){
local action=$1
if [ "$action" = "OFF" ]; then
uci set wireless.default_radio0.ssid='SSID1'
uci set wireless.default_radio0.hidden='1'
uci set wireless.default_radio1.ssid='SSID1'
uci set wireless.default_radio1.hidden='1'
uci commit wireless
wifi reload
logger -p notice -t wifi-toggle "SSID1"
fi
if [ "$action" = "ON" ]; then
uci set wireless.default_radio0.ssid='SSID2'
uci set wireless.default_radio0.hidden='0'
uci set wireless.default_radio1.ssid='SSID2'
uci set wireless.default_radio1.hidden='0'
uci commit wireless
wifi reload
logger -p notice -t wifi-toggle "SSID2"
fi
}
My system log only ever reads SSID2 regardless of what position I move the switch to. Wondering what could be causing this? Total newbie to coding in general too, so could be something super simple.
Any help would be awesome, Thanks