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:config-scripting [2021/07/24 05:39] – [Configuration in scripts] someothertime | docs:guide-developer:config-scripting [2024/06/01 08:50] (current) – code bash highlighting stokito | ||
|---|---|---|---|
| Line 10: | Line 10: | ||
| To be able to load UCI configuration files, you need to include the common functions with: | To be able to load UCI configuration files, you need to include the common functions with: | ||
| - | < | + | < |
| . / | . / | ||
| </ | </ | ||
| Line 16: | Line 16: | ||
| (If your startup script starts with: | (If your startup script starts with: | ||
| - | < | + | < |
| #!/bin/sh / | #!/bin/sh / | ||
| </ | </ | ||
| Line 43: | Line 43: | ||
| - Name, the section name, e.g. '' | - Name, the section name, e.g. '' | ||
| - | < | + | < |
| config_cb() { | config_cb() { | ||
| local type=" | local type=" | ||
| Line 62: | Line 62: | ||
| - Value, the option value, e.g. '' | - Value, the option value, e.g. '' | ||
| - | < | + | < |
| option_cb() { | option_cb() { | ||
| local name=" | local name=" | ||
| Line 83: | Line 83: | ||
| - Value, the list value, e.g. '' | - Value, the list value, e.g. '' | ||
| - | < | + | < |
| list_cb() { | list_cb() { | ||
| local name=" | local name=" | ||
| Line 106: | Line 106: | ||
| in ''/ | in ''/ | ||
| - | < | + | < |
| handle_interface() { | handle_interface() { | ||
| local config=" | local config=" | ||
| Line 117: | Line 117: | ||
| </ | </ | ||
| - | It is possible | + | Note that '' |
| Within the per-section callback, the '' | Within the per-section callback, the '' | ||
| Line 130: | Line 130: | ||
| - Default (optional), value to return instead if option is unset | - Default (optional), value to return instead if option is unset | ||
| - | < | + | < |
| - | ... | + | #... |
| # read the value of " | # read the value of " | ||
| # $config contains the ID of the current section | # $config contains the ID of the current section | ||
| Line 137: | Line 137: | ||
| config_get iface " | config_get iface " | ||
| echo " | echo " | ||
| - | ... | + | #... |
| </ | </ | ||
| Line 148: | Line 148: | ||
| - Value to assign | - Value to assign | ||
| - | < | + | < |
| ... | ... | ||
| # set the value of " | # set the value of " | ||
| Line 167: | Line 167: | ||
| The example below reads " | The example below reads " | ||
| - | < | + | < |
| ... | ... | ||
| local proto | local proto | ||
| Line 210: | Line 210: | ||
| - Additional arguments (optional), all following arguments are passed to the callback procedure as-is | - Additional arguments (optional), all following arguments are passed to the callback procedure as-is | ||
| - | < | + | < |
| # handle list items in a callback | # handle list items in a callback | ||
| # $config contains the ID of the section | # $config contains the ID of the section | ||
| Line 247: | Line 247: | ||
| For instance, consider this script: | For instance, consider this script: | ||
| - | < | + | < |
| config_cb() { | config_cb() { | ||
| local type=" | local type=" | ||
| Line 319: | Line 319: | ||
| That is, the type should come first, then selectors (with a special case for '' | That is, the type should come first, then selectors (with a special case for '' | ||
| - | < | + | < |
| parse_filter() { | parse_filter() { | ||
| local section=" | local section=" | ||