Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| docs:guide-developer:uci-defaults [2021/02/09 22:47] – update vgaetera | docs:guide-developer:uci-defaults [2023/10/14 09:08] (current) – [UCI defaults] vgaetera | ||
|---|---|---|---|
| Line 7: | Line 7: | ||
| To set some system defaults the first time the device boots, create a script in the directory ''/ | To set some system defaults the first time the device boots, create a script in the directory ''/ | ||
| - | All scripts in that folder | + | All scripts in that directory |
| * If they exit with code 0 they are deleted afterwards. | * If they exit with code 0 they are deleted afterwards. | ||
| * Scripts that exit with non-zero exit code are not deleted and will be re-executed at the next boot until they also successfully exit. | * Scripts that exit with non-zero exit code are not deleted and will be re-executed at the next boot until they also successfully exit. | ||
| Line 17: | Line 17: | ||
| ===== Integrating custom settings ===== | ===== Integrating custom settings ===== | ||
| See also: | See also: | ||
| - | [[docs: | + | [[docs: |
| - | [[docs: | + | [[docs: |
| Easiest way to include uci-defaults scripts in your firmware may be as custom files. | Easiest way to include uci-defaults scripts in your firmware may be as custom files. | ||
| Line 25: | Line 25: | ||
| 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 ''/ | 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 ''/ | ||
| Scripts should not be executable. | 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. //xx_customizations//). | + | 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. //xx_custom//). |
| A basic script could look like this: | A basic script could look like this: | ||
| <code bash> | <code bash> | ||
| - | cat << | + | cat << |
| - | uci -q batch << | + | uci -q batch << |
| set network.lan.ipaddr=' | set network.lan.ipaddr=' | ||
| - | commit network | ||
| set wireless.@wifi-device[0].disabled=' | set wireless.@wifi-device[0].disabled=' | ||
| set wireless.@wifi-iface[0].ssid=' | set wireless.@wifi-iface[0].ssid=' | ||
| - | commit wireless | ||
| add dhcp host | add dhcp host | ||
| set dhcp.@host[-1].name=' | set dhcp.@host[-1].name=' | ||
| set dhcp.@host[-1].ip=' | set dhcp.@host[-1].ip=' | ||
| set dhcp.@host[-1].mac=' | set dhcp.@host[-1].mac=' | ||
| - | commit dhcp | + | rename firewall.@zone[0]=' |
| + | rename firewall.@zone[1]=' | ||
| + | rename firewall.@forwarding[0]=' | ||
| + | EOI | ||
| EOF | EOF | ||
| - | EOF_cat | ||
| </ | </ | ||
| - | This is a simple example to set up the LAN IP address, SSID, enable Wi-Fi, configure a static DHCP lease. | + | This is a simple example to set up the LAN IP address, SSID, enable Wi-Fi, configure a static DHCP lease, rename firewall zone and forwarding sections. |
| Once the script has run successfully and exited cleanly (exit status 0), it will be removed from ''/ | Once the script has run successfully and exited cleanly (exit status 0), it will be removed from ''/ | ||
| You can still consult the original in ''/ | You can still consult the original in ''/ | ||
| Line 59: | Line 59: | ||
| This will make sure, 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 ''/ | ||
| - | ===== Example scripts | + | ===== Examples |
| + | * [[docs: | ||
| + | * [[https:// | ||
| + | * [[https:// | ||
| + | * [[https:// | ||
| + | * [[https:// | ||
| - | The following '' | ||
| - | |||
| - | * the '' | ||
| - | * the [[https:// | ||
| - | * the [[https:// | ||