Differences

This shows you the differences between two versions of the page.

doc:uci [2012/11/16 09:41]
steven
doc:uci [2013/05/23 16:15] (current)
nousername
Line 1: Line 1:
====== The UCI System ====== ====== The UCI System ======
-The abbreviation //UCI// stands for //**__U__**nified **__C__**onfiguration **__I__**nterface// and is intended to centralize the configuration of OpenWrt. +The abbreviation [[doc:techref:uci|UCI]] stands for //**__U__**nified **__C__**onfiguration **__I__**nterface// and is intended to centralize the configuration of OpenWrt.
-Configuration should be easy, straight forward and documented here, making life easier! (UCI is the successor to the nvram-based configuration found in the White Russian series of OpenWrt.)+Configuration should be easy, straightforward and documented here, making life easier! UCI is the successor to the NVRAM-based configuration found in the White Russian series of OpenWrt.
-Many programs have their own config files lying around somewhere, like ''/etc/network/interfaces'' or ''/etc/exports'' or ''/etc/dnsmasq.conf'' ''/etc/samba/samba.conf'' and they often use different syntax. With OpenWrt you don't have to bother with any of them and only need to change the UCI configuration files!+Many programs have their own configuration files lying around somewhere, like ''/etc/network/interfaces'', ''/etc/exports'', ''/etc/dnsmasq.conf'' or ''/etc/samba/samba.conf'' and they often use different syntaxes. With OpenWrt you don't have to bother with any of them and only need to change the UCI configuration files.
-You no longer have to reboot your system to make configuration changes! You can use the [[doc:uci#command.line.utility|UCI command line utility]] instead. And please do not forget that quite some daemons are included in the official binaries, but they are not enabled by default! For example the cron daemon is not activated by default, thus only editing the crontab won't do anything. You have to either start the daemon with ''/etc/init.d/cron start'' or enable it with ''/etc/init.d/cron enable''. You can ''disable'', ''stop'' and ''restart'' most of those daemons, too. There are some [[doc:howto:notuci.config]] you may want to tend to.+You no longer have to reboot your system to make configuration changes. You can use the [[doc:uci#command.line.utility|UCI command line utility]] instead. And please do not forget that quite some daemons are included in the official binaries, but they are not enabled by default! For example the ''cron'' daemon is not activated by default, thus only editing the ''crontab'' won't do anything. You have to either start the daemon with ''/etc/init.d/cron start'' or enable it with ''/etc/init.d/cron enable''. You can ''disable'', ''stop'' and ''restart'' most of those daemons, too. There are some [[doc:howto:notuci.config|not UCI configuration files]] you may want to tend to.
===== Common Principles ===== ===== Common Principles =====
Line 25: Line 25:
| [[doc:uci:wireless|/etc/config/wireless]] | Wireless settings and wifi network definition | | [[doc:uci:wireless|/etc/config/wireless]] | Wireless settings and wifi network definition |
^ IPv6 ^^ ^ IPv6 ^^
-| [[doc:uci:6relayd|/etc/config/6relayd]] | IPv6-Relay and Server (RD, DHCPv6 & NDP-Proxy) |+| [[doc:uci:6relayd|/etc/config/6relayd]] | IPv6-Server and Relay (RD, DHCPv6 & NDP) |
| [[doc:uci:ahcpd|/etc/config/ahcpd]] | Ad-Hoc Configuration Protocol (AHCP) server and forwarder configuration | | [[doc:uci:ahcpd|/etc/config/ahcpd]] | Ad-Hoc Configuration Protocol (AHCP) server and forwarder configuration |
| [[doc:uci:aiccu|/etc/config/aiccu]] | AICCU client configuration | | [[doc:uci:aiccu|/etc/config/aiccu]] | AICCU client configuration |
Line 152: Line 152:
| ''commit''  | ''[<config>]'' | Writes changes of the given configuration file, or if none is given, all configration files, to the filesystem. All "uci set", "uci add", "uci rename" and "uci delete" commands are staged into a temporary location and written to flash at once with "uci commit". This is not needed after editing configuration files with a text editor, but for scripts, GUIs and other programs working directly with UCI files. | | ''commit''  | ''[<config>]'' | Writes changes of the given configuration file, or if none is given, all configration files, to the filesystem. All "uci set", "uci add", "uci rename" and "uci delete" commands are staged into a temporary location and written to flash at once with "uci commit". This is not needed after editing configuration files with a text editor, but for scripts, GUIs and other programs working directly with UCI files. |
| ''batch''    | - | Executes a multi-line UCI script which is typically wrapped into a //here// document syntax. | | ''batch''    | - | Executes a multi-line UCI script which is typically wrapped into a //here// document syntax. |
-| ''export''  | ''[<config>]'' | Exports the configuration in a machine readable format. It is used internally to evaluate configration files as shell scripts. |+| ''export''  | ''[<config>]'' | Exports the configuration in a machine readable format. It is used internally to evaluate configuration files as shell scripts. |
| ''import''  | ''[<config>]'' | Imports configuration files in UCI syntax. | | ''import''  | ''[<config>]'' | Imports configuration files in UCI syntax. |
| ''changes''  | ''[<config>]'' | List staged changes to the given configuration file or if none given, all configuration files. | | ''changes''  | ''[<config>]'' | List staged changes to the given configuration file or if none given, all configuration files. |
Line 202: Line 202:
80 80
root@OpenWrt:~#'' | root@OpenWrt:~#'' |
 +
 +=== append an entry to a list ===
 +
 +| ''uci add_list system.ntp.server='0.de.pool.ntp.org''' |
 +
 +=== replace a list completely ===
 +
 +| ''uci delete system.ntp.server
 +uci add_list system.ntp.server='0.de.pool.ntp.org'
 +uci add_list system.ntp.server='1.de.pool.ntp.org'
 +uci add_list system.ntp.server='2.de.pool.ntp.org'
 +'' |
=== UCI paths === === UCI paths ===
Line 234: Line 246:
uci get foo.third.name uci get foo.third.name
''| ''|
 +
 +If you show it, you get :
 +
 +|''# **uci show foo**
 +foo.first=bar
 +foo.first.name=Mr. First
 +//foo.@bar[0]=bar//
 +//foo.@bar[0].name=Mr. Second//
 +foo.third=bar
 +foo.third.name=Mr. Third
 +''|
 +
 +But if you used "uci show foo.@bar[0]", you will see:
 +
 +|''# **uci show foo.@bar[0]**
 +//foo.first=bar//
 +//foo.first.name=Mr. First// :-(
 +''|
 +
=== Query interface state === === Query interface state ===
Line 277: Line 308:
=== Get SSID === === Get SSID ===
<code> uci get wireless.@wifi-iface[-1].ssid</code> <code> uci get wireless.@wifi-iface[-1].ssid</code>
 +
 +==== Defaults: ====
 +
 +To set some system defaults the first time the device boots, create a script in the folder
 +<code>/etc/uci-defaults/</code>
 +All scripts in that folder are automatically executed by ''/etc/init.d/S10boot'' and if they exited with code 0 __deleted afterwards__ (scripts that did not exit with code 0 are not deleted and will be re-executed during the next boot until they also successfully exit).
===== Porting UCI to a different Linux distribution ===== ===== Porting UCI to a different Linux distribution =====
  * [[https://forum.openwrt.org/viewtopic.php?id=15243]]   * [[https://forum.openwrt.org/viewtopic.php?id=15243]]

Back to top

doc/uci.1353055262.txt.bz2 · Last modified: 2012/11/16 09:41 by steven