[SOLVED]Enable/Disable multiple interfaces and Wi-Fi with 1 command

I have an Archer C60 v1 and have AP + Guests on 2.4G and 5G. In the 5 I also have a client interface to have internet in case of an internet outage on the WAN. I have not been able to have the 3 Wi-Fi interfaces turned on in the 5G one. Therefore I use this command to turn off the main and guest AP and turn on the client Wi-Fi:

uci set wireless.telecentro.disabled="0" && uci set wireless.5g_ap.disabled="1" && uci set wireless.5g_ap_invitados.disabled="1" && uci commit wireless && wifi reload && uci set network.wan.disabled="1" && uci set network.telecentro.disabled="0" && uci commit network && service network restart

Another command to do the opposite:

uci set wireless.telecentro.disabled="1" && uci set wireless.5g_ap.disabled="0" && uci set wireless.5g_ap_invitados.disabled="0" && uci commit wireless && wifi reload && uci set network.wan.disabled="0" && uci set network.telecentro.disabled="1" && uci commit network && service network restart

I've tried entering these commands into the Commands app but can't get them to work.

well, there's a syntax error somewhere, try running one command at a time, skipping the &&, or try using ; as command separator, instead of &&.

1 Like

This is not valid. Either you'll have disabled='1' or you'll delete the disabled option.

1 Like

Why would it be invalid?
disabled 0 sounds quite ok to me.

This is more likely about escaping quotes or ampersands, like the screenshot shows.

Similar error has been shown e.g. in Error when executing command from luci-app-commands

A better approach would be to write the commands into executable scripts in /etc, which scripts you then launch via luci-app-commands

How does the stored command from luci-app-commands actually show up in /etc/config/luci ?

config command
        option name 'Encender Wi-Fi TeleCentro'
        option command 'uci set wireless.telecentro.disabled="0";uci set wireless.5g_ap.disabled="1";uci set wireless.5g_ap_invitados.disabled="1";uci commit wireless;wifi reload;uci set network.wan.disabled="1";uci set network.telecentro.disabled="0";uci commit network;service network restart'

config command
        option name 'Apagar Wi-Fi TeleCentro'
        option command 'uci set wireless.telecentro.disabled="1";uci set wireless.5g_ap.disabled="0";uci set wireless.5g_ap_invitados.disabled="0";uci commit wireless;wifi reload;uci set network.wan.disabled="0";uci set network.telecentro.disabled="1";uci commit network;service network restart'

I have already changed it and it shows the same error.

then try one command at a time ....

1 Like

My wrong, it is not invalid. I was used to the uci command applied from luci to delete the option disabled instead of making it 0.

1 Like

Neither works with the change to ;.

What would be a better way with scripts in /etc?

I use this kind of approach in launching more complex stuff from luci-app-commands:

root@router1:~# tail /etc/config/luci
        option route 'openwrt.org'

config command
        option name 'Backup LuCI stats'
        option command '/etc/storeStats.sh'

config command
        option name 'Restore LuCI stats backup'
        option command '/etc/restoreStats.sh'

and the launched script...

root@router1:~# cat /etc/storeStats.sh
/etc/init.d/collectd stop
logger -t "LuCI statistics" Create backup archive
mkdir -p /etc/backup.stats
cd /tmp/rrd/$(uname -n)
tar c -zvf /etc/backup.stats/stats.tar.gz *
cp /etc/backup.stats/stats.tar.gz /etc/backup.stats/stats-$(date +%Y%m%dT%H%M).tar.gz
/etc/init.d/collectd start

Luci-app-commands is not meant to be a full-fledged replacement of a shell. It has limitations.

1 Like

Late but I was able to get it:


uci -q set wireless.5g_invitados.disabled=1
uci -q set wireless.2g.disabled=0
uci -q set wireless.5g_sta.disabled=0
uci commit wireless
uci del network.cfg030f15.ports
service network restart
uci del dhcp.lan.ignore
uci commit dhcp
service dnsmasq restart


uci -q set wireless.5g_invitados.disabled=0
uci -q set wireless.2g.disabled=1
uci -q set wireless.5g_sta.disabled=1
uci commit wireless
uci add_list network.cfg030f15.ports='eth0.1'
service network restart
uci set dhcp.lan.ignore='1'
uci commit dhcp
service dnsmasq restart
1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.