Uci use of openwrt

"Uci" is the abbreviation of "Unified Configuration Interface", which is intended to centralize the configuration of the entire OpenWrt system.

用法: uci [<options>] <command> [<arguments>]

命令:
	batch
	export     [<config>]
	import     [<config>]
	changes    [<config>]
	commit     [<config>]
	add        <config> <section-type>
	add_list   <config>.<section>.<option>=<string>
	show       [<config>[.<section>[.<option>]]]
	get        <config>.<section>[.<option>]
	set        <config>.<section>[.<option>]=<value>
	delete     <config>[.<section[.<option>]]
	rename     <config>.<section>[.<option>]=<name>
	revert     <config>[.<section>[.<option>]]

参数:
	-c <path>  set the search path for config files (default: /etc/config)
	-d <str>   set the delimiter for list values in uci show
	-f <file>  use <file> as input instead of stdin
	-m         when importing, merge data into an existing package
	-n         name unnamed sections on export (default)
	-N         don't name unnamed sections
	-p <path>  add a search path for config change files
	-P <path>  add a search path for config change files and use as default
	-q         quiet mode (don't print error messages)
	-s         force strict mode (stop on parser errors, default)
	-S         disable strict mode
	-X         do not use extended syntax on 'show'
  • Read the configuration, take /etc/config/wireless as an example
root@Eric:/# cat /etc/config/wireless

config wifi-device 'radio0'
        option type 'mac80211'
        option channel '11'
        option hwmode '11g'
        option path 'platform/10300000.wmac'
        option htmode 'HT20'
        option disabled '0'

config wifi-iface 'default_radio0'
        option device 'radio0'
        option network 'lan'
        option mode 'ap'
        option ssid 'OpenWrt-eric'
        option encryption 'none'
        
root@Eric:/# uci show wireless
wireless.radio0=wifi-device
wireless.radio0.type='mac80211'
wireless.radio0.channel='11'
wireless.radio0.hwmode='11g'
wireless.radio0.path='platform/10300000.wmac'
wireless.radio0.htmode='HT20'
wireless.radio0.disabled='0'
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-eric'
wireless.default_radio0.encryption='none'
  • Read a certain item
root@Eric:/# uci get wireless.radio0.type
mac80211
  • New configuration file server
root@Eric:/etc/config# touch server
  • Added configuration config mqtt, no section by default
root@Eric:/etc/config# uci add server mqtt
cfg01c4eb
root@Eric:/etc/config# uci commit server
root@Eric:/etc/config#
root@Eric:/etc/config# cat server

config mqtt

  • Increase option name=abc
root@Eric:/etc/config# uci set server.@mqtt[0].name=abc
root@Eric:/etc/config# uci commit server
root@Eric:/etc/config# cat server

config mqtt
        option name 'abc'
  • Delete option name, delete config mqtt
root@Eric:/etc/config# uci delete server.@mqtt[0].name
root@Eric:/etc/config# uci commit server
root@Eric:/etc/config# cat server

config mqtt

root@Eric:/etc/config#
root@Eric:/etc/config# uci delete server.@mqtt[0]
root@Eric:/etc/config# uci commit server
root@Eric:/etc/config# cat server

root@Eric:/etc/config#
  • Add config with name, mqtt=ali
root@Eric:/etc/config# uci set server.ali=mqtt
root@Eric:/etc/config# uci commit server
root@Eric:/etc/config# cat server

config mqtt 'ali'

root@Eric:/etc/config#
  • Increase option name=abc
root@Eric:/etc/config# uci set server.ali.name=abc
root@Eric:/etc/config# uci commit server
root@Eric:/etc/config# cat server

config mqtt 'ali'
        option name 'abc'

root@Eric:/etc/config#

  • Delete config mqtt
root@Eric:/etc/config# uci delete server.ali
root@Eric:/etc/config# uci commit server
root@Eric:/etc/config# cat server

root@Eric:/etc/config#


Guess you like

Origin blog.csdn.net/pyt1234567890/article/details/111407523