1 == Structure of the configuration files ==
3 The config files are divided into sections and options/values.
5 Every section has a type, but does not necessarily have a name.
6 Every option has a name and a value and is assigned to the section
11 config <type> [<name>] # Section
12 option <name> <value> # Option
15 Every parameter needs to be a single string and is formatted exactly
16 like a parameter for a shell function. The same rules for Quoting and
17 special characters also apply, as it is parsed by the shell.
21 == Parsing configuration files in custom scripts ==
23 To be able to load configuration files, you need to include the common
28 Then you can use config_load <name> to load config files. The function
29 first checks for <name> as absolute filename and falls back to loading
30 it from /etc/config (which is the most common way of using it).
32 If you want to use special callbacks for sections and/or options, you
33 need to define the following shell functions before running config_load
34 (after including /etc/functions.sh):
39 # commands to be run for every section
43 # commands to be run for every option
46 You can also alter option_cb from config_cb based on the section type.
47 This allows you to process every single config section based on its type
50 config_cb is run every time a new section starts (before options are being
51 processed). You can access the last section through the CONFIG_SECTION
52 variable. Also an extra call to config_cb (without a new section) is generated
53 after config_load is done.
54 That allows you to process sections both before and after all options were
57 You can access already processed options with the config_get command
60 config_get <section> <option> # prints the value of the option
61 config_get <variable> <section> <option> # stores the value inside the variable
63 In busybox ash the three-option config_get is faster, because it does not
64 result in an extra fork, so it is the preferred way.
66 Additionally you can also modify or add options to sections by using the
71 config_set <section> <option> <value>