How do I undo a uci set command?

I'm just staring to learn OpenWrt and made a mistake with the "uci set" command as follows and I can't figure out how to undo it. I'm not sure what file stores these configs so I can manually edit and fix. Thanks for any help.

I typed this:

uci set wireless.radio0=country='US'   (notice the "=" before the word "country")
uci set wireless.radio1=country='US'

Instead of typing this:

uci set wireless.radio0.country='US'
uci set wireless.radio1.country='US'

As a result, the "uci show wireless" command show both the error and the correct version per below and my wireless radios no longer come up in the Luci interface. When I go to the wireless tab in Luci I get error message "Unable to dispatch: /cgi-bin/luci/admin/notwork/wireless".

root@OpenWrt:~# uci show wireless
wireless.radio0=country=US
wireless.radio0.type='mac80211'
wireless.radio0.channel='36'
wireless.radio0.hwmode='11a'
wireless.radio0.path='pci0000:00/0000:00:00.0'
wireless.radio0.htmode='VHT80'
wireless.radio0.disabled='1'
wireless.radio0.country='US'
wireless.default_radio0=wifi-iface
wireless.default_radio0.device='radio0'
wireless.default_radio0.network='lan'
wireless.default_radio0.mode='ap'
wireless.default_radio0.ssid='OpenWrt'
wireless.default_radio0.encryption='none'
wireless.radio1=country=US
wireless.radio1.type='mac80211'
wireless.radio1.channel='11'
wireless.radio1.hwmode='11g'
wireless.radio1.path='platform/ahb/18100000.wmac'
wireless.radio1.htmode='HT20'
wireless.radio1.disabled='1'
wireless.radio1.country='US'
wireless.default_radio1=wifi-iface
wireless.default_radio1.device='radio1'
wireless.default_radio1.network='lan'
wireless.default_radio1.mode='ap'
wireless.default_radio1.ssid='OpenWrt'
wireless.default_radio1.encryption='none'
root@OpenWrt:~#
uci delete wireless.radio1=country=US
uci delete wireless.radio0=country=US
uci commit wireless
wifi up
3 Likes

Two options:

Re-run the uci command with the correct syntax - it should overwrite.

Directly edit the config file. vi is in the default install.

https://openwrt.org/docs/guide-user/base-system/uci

No. As the option name was wrong, a command with the correct option name does not overwrite the wrong value (like OP has already noticed).

Editing the /etc/config/wireless file (with nano, vi, or whatever text editor) is likely the easiest option for most users in the similar situation.

2 Likes

Thanks for all of the responses.

Yes, I verified this to be true. Thanks for catching that in my post.

The incorrect Option Name does not appear in this file so I'm not sure what to edit.

The changes do not affect persistent configuration until you commit them:

uci commit [config]

You can simply revert uncommitted changes:

uci revert [config]
3 Likes

If the file is right then you don't have to do anything. The uci command ultimately pokes lines into the file. I really prefer to edit the file directly so it is possible to see the whole picture.

Until you commit or until you restart the service?
From my understanding the commit will write the configuration file, but it will not be applied until the service restart or reboot.

To clarify, in general:

  • Service runtime is separate from the UCI runtime.
    Restarting the service converts the UCI runtime into the service runtime.

  • UCI runtime is the sum of the UCI persistent and changes.
    Committing changes replaces the UCI persistent with the UCI runtime.

1 Like