Reuse 'uci show' output

Is there a way to import uci show output?

E.g., I need to import this config snippet (see a bottom of the page):

network.lan.ipaddr='192.168.2.1'
network.wwan=interface
network.wwan.proto='dhcp'
firewall.@zone[1]=zone
firewall.@zone[1].name='wwan'
firewall.@zone[1].input='REJECT'
firewall.@zone[1].output='ACCEPT'
firewall.@zone[1].forward='REJECT'
firewall.@zone[1].masq='1'
firewall.@zone[1].mtu_fix='1'
firewall.@zone[1].network='wwan'
wireless.@wifi-iface[1]=wifi-iface
wireless.@wifi-iface[1].network='wwan'
wireless.@wifi-iface[1].ssid='Violetta'
wireless.@wifi-iface[1].encryption='psk2'
wireless.@wifi-iface[1].device='radio0'
wireless.@wifi-iface[1].mode='sta'
wireless.@wifi-iface[1].bssid='C8:D5:FE:C8:61:B0'
wireless.@wifi-iface[1].key='myWifiPasswordHere'

If not, we probably should to edit the snippet on the Wiki to make it copy-pasteable?

1 Like

Import to what?

In PuTTy everything that is marked is copied.

But to get output as the configs are actually written you must use uci export

But it is impossible to write uci show result to a new device since it doesn’t have the actual uci functions code like add, del, set etc.

so we have to edit that config snippet adding set to each of the lines?
That's what I meant then - the sample is not copy-pasteable..

1 Like

It ain’t that easy!
https://openwrt.org/docs/guide-user/base-system/uci

If you want the actual uci code to program the router the easiest way is to make the changes in luci and press save and then copy the uci code from the blue settings to apply in the top of luci.

The best way to use uci show is to get the id number of listed settings

Like if you want to delete this zone you know it is zone number 1 you should delete.

The problem is I don't have neither luci nor inet access yet, that's why I need to apply that configuration first.

Adding set should seem to work, I could edit the Wiki to make it comfortable for others, if no better ideas..

1 Like

Good luck with that.

It's OK for the named sections, but for the unnamed it's not enough.

uci add firewall zone
uci set firewall.@zone[-1].name='wwan'
...
uci commit firewall
fw3 restart

And so on.

Thanks, but the idea was to override some sections I think?

Anyway, I followed the Wiki configuration almost exactly (just had to swap @wifi-iface[1] to @wifi-iface[0] and it gave me the trick..

1 Like