From: Stijn Segers Date: Thu, 26 May 2016 20:10:21 +0000 (+0200) Subject: UCI Defaults: fixed a few formatting and typographic errors, reworked the page a... X-Git-Url: http://git.openwrt.org/?p=web.git;a=commitdiff_plain;h=ca5790a39ad278d6b00c34077d84ed90d58d8e80 UCI Defaults: fixed a few formatting and typographic errors, reworked the page a bit to fit in more with other pages (short preamble) --- diff --git a/docs/uci_defaults.txt b/docs/uci_defaults.txt index 3255550..2684025 100644 --- a/docs/uci_defaults.txt +++ b/docs/uci_defaults.txt @@ -3,16 +3,21 @@ UCI defaults ============ -== Integrating custom settings through UCI defaults +== UCI Defaults -LEDE allows you to add custom settings by adding scripts into the 'files/etc/uci-defaults/' directory, which -will then be run after flashing. When keeping settings, this should mean the scripts are run *after* the upgrade -process flashed the image and appended the saved settings to the JFFS partition (which will be mounted as -'/overlay'). The path is identical for the buildroot and the image generator. Scripts should not be executable. -To ensure your scripts are not interfering with any other scripts, make sure they get executed last by giving them -a high prefix (e.g. 'zzzz_customisations'). A basic script could look like this: +_LEDE_ relies on link:/docs/uci.html[UCI], the 'Unified Configuration Interface', to configure its core services. +UCI Defaults provides a way to preconfigure your images, using UCI. ---- +=== Integrating custom settings + +You can preload custom settings by adding batch scripts containing UCI commands into the 'files/etc/uci-defaults/' +directory. The path is identical for the buildroot and the image generator. The scripts will be run *after* the +flashing process - in case of upgrading, that also includes appending the existing configuration to the JFFS2 +partition (mounted as '/overlay').Scripts should not be executable. To ensure your scripts are not interfering +with any other scripts, make sure they get executed last by giving them a high prefix (e.g. 'zzzz_customisations'). +A basic script could look like this: + +---- $ cat zzzz_customisations #!/bin/sh @@ -22,21 +27,18 @@ uci -q batch <<-EOT set network.@host[0].ip='192.168.2.100' set network.@host[0].mac='a1:b2:c3:d4:e5:f6' EOT ---- +---- Once the script has run successfully and exited cleanly (exit status 0), it will be removed from '/etc/uci-defaults/'. You can still consult the original in '/rom/etc/uci-defaults/' if needed. +=== Ensuring scripts don't overwrite custom settings: implementing checks -== Ensuring scripts don't overwrite custom settings: implementing checks - -Scripts in '/etc/uci-defaults' will get executed at every first boot (ie after a clean install or an upgrade), -possibly overwriting already existing values. If this behaviour is undesired, we recommend you implement +Scripts in '/etc/uci-defaults' will get executed at every first boot (i.e. after a clean install or an upgrade), +possibly overwriting already existing values. If this behaviour is undesired, we recommend you implement a test at the top of your script - e.g. probe for a custom setting your script would normally configure: ---- -[ "$(uci -q get system.@system[0].zonename)" = "America/New York" ] && exit 0 ---- + [ "$(uci -q get system.@system[0].zonename)" = "America/New York" ] && exit 0 -This will ensure, when the key has the correct value set, that the script exits cleanly and gets removed from +This will make sure, when the key has the correct value set, that the script exits cleanly and gets removed from '/etc/uci-defaults/' as explained above.