UCI: expanded a bit, clarified difference between single and multiple values
[web.git] / docs / uci.txt
1 ---
2 ---
3 The UCI Configuration System
4 ============================
5
6 == UCI - Unified Configuration Interface
7
8 _LEDE_ uses UCI to store its configuration. This is a human readable file format using typed and named sections. Each section contains a number of options. Options can be single values or lists of values. All configuration files are stored in the /etc/config/ folder. You can manually edit these files.
9
10 ----
11 root@lede:/# cat etc/config/system
12 config system
13 option hostname lede
14 option timezone UTC
15
16 config timeserver ntp
17 list server 0.openwrt.pool.ntp.org
18 list server 1.openwrt.pool.ntp.org
19 list server 2.openwrt.pool.ntp.org
20 list server 3.openwrt.pool.ntp.org
21 option enabled 1
22 option enable_server 0
23 ----
24
25 Alternatively you may use the uci CLI to read/modify their content. Using the CLI has the advantage that you do not need to worry about the validity of the syntax. Some users do however prefer to make changes manually, they should be aware that even minor syntax errors will make the whole file unparsable and not just the specific section and/or option that was modified. UCI by default will print all the known settings (`uci show`), but also allows you to print just the settings for a subsystem, like you can see below:
26
27 ----
28 root@lede:/# uci show system
29 system.@system[0]=system
30 system.@system[0].hostname='lede'
31 system.@system[0].timezone='UTC'
32 system.ntp=timeserver
33 system.ntp.server='0.openwrt.pool.ntp.org' '1.openwrt.pool.ntp.org' '2.openwrt.pool.ntp.org' '3.openwrt.pool.ntp.org'
34 system.ntp.enabled='1'
35 system.ntp.enable_server='0'
36 ----
37
38 When using the CLI to modify values, you will find that all changes first get staged and not commited to the file directly. You can see the affected keys with `uci changes`. Single value options get set with `uci set key='value'`, list options (like 'system.ntp.server' above) with `uci add_list key='value'`. If you want to permanently store changes you need to commit them (see example below). Just like printing settings, you can commit all changes or just do so for a subset. After calling the commit command, you can also make the system reload and apply the changes that you made. (This will only affect services that correctly use link:procd.html[procd] init scripts.)
39
40 ----
41 root@lede:/# uci set system.@system[0].hostname=foo
42 root@lede:/# uci commit system
43 root@lede:/# reload_config
44 root@lede:/#
45 ----
46
47