Merge pull request #1818 from dibdot/lxc_fix
[project/luci.git] / contrib / package / meshwizard / files / usr / bin / meshwizard / helpers / read_defaults.sh
1 #!/bin/sh
2 # These functions read the settings we need for configuration of the router
3
4 read_defaults() {
5         # read default values from the 3 relevant config files and export them
6         # into the environment. Later loaded configs overwrite earlier ones. The
7         # The ordering here is from most generic to most specific:
8         # freifunk (most generic defaults)
9         # profile_* (community defaults)
10         # nodes custom config from meshwizard config file
11
12         local community="$1"
13
14         config_cb() {
15         local type="$1"
16         local name="$2"
17         local allowed_section_types="widget"
18         local allowed_section_names="
19                 system
20                 wifi_device
21                 wifi_iface
22                 interface
23                 alias
24                 dhcp
25                 olsr_interface
26                 olsr_interfacedefaults
27                 profile
28                 zone_freifunk
29                 include
30                 luci_splash
31                 ipv6
32                 luci_main
33                 contact
34                 community
35                 wan
36                 lan
37                 general
38                 ipv6
39                 qos
40         "
41
42         if [ "$type" = "widget" ]; then
43                 widgets=$(add_to_list "$widgets" "$name")
44         fi
45
46         if ([ -n "$name" ] && is_in_list "$allowed_section_names" $name) \
47                 || is_in_list "$allowed_section_types" $type ; then
48                 option_cb() {
49                 local option="$1"
50                 local value="$2"
51                 export "${CONFIG_SECTION}_${option}"="$value"
52                 }
53         else
54                 option_cb() { return; }
55         fi
56         }
57         config_load freifunk
58         config_load profile_${community}
59         config_load meshwizard
60         export widgets="$widgets"
61 }