Add widget config from community profile to meshwizard
[project/luci.git] / contrib / package / meshwizard / files / usr / bin / meshwizard / helpers / read_defaults.sh
1 #!/bin/sh
2 # This reads the settings we need to have to configure everything
3 # Argument $1: community
4
5 . /lib/functions.sh
6 community="$1"
7
8 # reads variables from uci files, parameter $1 is the section
9 get_var() {
10 uci -q show $1 | cut -d "." -f 2-100 |grep "\." | sed -e 's/^\([A-Za-z0-9_]*\)\./\1_/g' -e 's/=\(.*\)$/="\1"/g'
11 }
12
13 handle_widgets() {
14 widgets="$1 $widgets"
15 }
16 config_load freifunk
17 config_foreach handle_widgets widget
18 config_load profile_$community
19 config_foreach handle_widgets widget
20 echo "widgets=$widgets"
21
22 # read default values from /etc/config/freifunk
23 for v in system wifi_device wifi_iface interface alias dhcp olsr_interface olsr_interfacedefaults zone_freifunk include $widgets; do
24 get_var freifunk.$v
25 done
26
27 # now read all values from the selected community profile, will override some values from the defaults before
28 for v in system wifi_device wifi_iface interface alias dhcp olsr_interface olsr_interfacedefaults profile zone_freifunk include luci_splash ipv6 $widgets; do
29 get_var profile_$community.$v
30 done
31
32 # read values from meshwizard
33 for v in system luci_main contact community wan lan general ipv6; do
34 get_var meshwizard.$v
35 done