finally move buildroot-ng to trunk
[openwrt/staging/dedeckeh.git] / docs / config.txt
1 == Structure of the configuration files ==
2
3 The config files are divided into sections and options/values.
4
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
7 it was written under.
8
9 Syntax:
10
11 config <type> [<name>] # Section
12 option <name> <value> # Option
13
14
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.
18
19
20
21 == Parsing configuration files in custom scripts ==
22
23 To be able to load configuration files, you need to include the common
24 functions with:
25
26 . /etc/functions.sh
27
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).
31
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):
35
36 config_cb() {
37 local type="$1"
38 local name="$2"
39 # commands to be run for every section
40 }
41
42 option_cb() {
43 # commands to be run for every option
44 }
45
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
48 individually.
49
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
55 processed.
56
57 You can access already processed options with the config_get command
58 Syntax:
59
60 config_get <section> <option> # prints the value of the option
61 config_get <variable> <section> <option> # stores the value inside the variable
62
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.
65
66 Additionally you can also modify or add options to sections by using the
67 config_set command.
68
69 Syntax:
70
71 config_set <section> <option> <value>
72