Merge pull request #1818 from dibdot/lxc_fix
[project/luci.git] / contrib / package / meshwizard / files / usr / bin / meshwizard / helpers / initial_config.sh
1 #!/bin/sh
2 # This is only run once (usually after flashing an image from the imagebuilder)
3 # It sets up the initial config for this node.
4
5 . /lib/functions.sh
6 . $dir/functions.sh
7
8 config_load system
9
10 # Rename system config
11 handle_system() {
12         if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then
13                 section_rename system $1 system
14         fi
15 }
16 config_foreach handle_system system
17
18 if [ -n "$(uci -q get meshwizard.community)" ]; then
19         set_defaults "community_" freifunk.community
20         uci -q delete meshwizard.community
21 fi
22
23 [ -n "$profile_homepage" ] && uci set freifunk.community.homepage="$profile_homepage"
24
25 [ -n "$profile_mapserver" ] && {
26         uci -q delete freifunk.community.mapserver
27         for m in $profile_mapserver; do
28                 uci add_list freifunk.community.mapserver="$m"
29         done
30 }
31
32 uci_commitverbose "Setup community" freifunk
33
34 if [ -n "$(uci -q get meshwizard.contact)" ]; then
35         set_defaults "contact_" freifunk.contact
36         uci -q delete meshwizard.contact && uci_commitverbose "Setup contact" freifunk
37 fi
38
39 if [ "$has_luci" == TRUE ]; then
40         set_defaults "luci_main_" luci.main
41         uci -q delete meshwizard.luci_main && uci_commitverbose "Setup luci" luci
42 fi