UCI Defaults: fixed a few formatting and typographic errors, reworked the page a...
[web.git] / docs / uci_defaults.txt
1 ---
2 ---
3 UCI defaults
4 ============
5
6 == UCI Defaults
7
8 _LEDE_ relies on link:/docs/uci.html[UCI], the 'Unified Configuration Interface', to configure its core services.
9 UCI Defaults provides a way to preconfigure your images, using UCI.
10
11 === Integrating custom settings
12
13 You can preload custom settings by adding batch scripts containing UCI commands into the 'files/etc/uci-defaults/'
14 directory. The path is identical for the buildroot and the image generator. The scripts will be run *after* the
15 flashing process - in case of upgrading, that also includes appending the existing configuration to the JFFS2
16 partition (mounted as '/overlay').Scripts should not be executable. To ensure your scripts are not interfering
17 with any other scripts, make sure they get executed last by giving them a high prefix (e.g. 'zzzz_customisations').
18 A basic script could look like this:
19
20 ----
21 $ cat zzzz_customisations
22 #!/bin/sh
23
24 uci -q batch <<-EOT
25 add dhcp host
26 set dchp.@host[0].name='bellerophon'
27 set network.@host[0].ip='192.168.2.100'
28 set network.@host[0].mac='a1:b2:c3:d4:e5:f6'
29 EOT
30 ----
31
32 Once the script has run successfully and exited cleanly (exit status 0), it will be removed from '/etc/uci-defaults/'.
33 You can still consult the original in '/rom/etc/uci-defaults/' if needed.
34
35 === Ensuring scripts don't overwrite custom settings: implementing checks
36
37 Scripts in '/etc/uci-defaults' will get executed at every first boot (i.e. after a clean install or an upgrade),
38 possibly overwriting already existing values. If this behaviour is undesired, we recommend you implement
39 a test at the top of your script - e.g. probe for a custom setting your script would normally configure:
40
41 [ "$(uci -q get system.@system[0].zonename)" = "America/New York" ] && exit 0
42
43 This will make sure, when the key has the correct value set, that the script exits cleanly and gets removed from
44 '/etc/uci-defaults/' as explained above.