Add new meshwizard (WIP)
[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
6 . /etc/functions.sh
7 . $dir/functions.sh
8
9 ### System config
10
11 config_load system
12
13 # Rename system config
14 handle_system() {
15         if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then
16                 section_rename system $1 system
17         fi
18 }
19 config_foreach handle_system system
20
21 if [ -n "$(uci -q get meshwizard.system)" ]; then
22         echo "    + Setup system"
23         uci show meshwizard.system | sed 's/^meshwizard/uci set system/g' | while read line; do
24                 eval $line
25                 echo "    $line"
26         done
27         uci -q delete meshwizard.system
28 fi
29
30 if [ -n "$(uci -q get meshwizard.community)" ]; then
31         echo "    + Setup community"
32         uci show meshwizard.community | sed 's/^meshwizard/freifunk/g' | while read line; do
33                 eval uci set $line
34                 echo "    $line"
35         done
36         uci -q delete meshwizard.community
37 fi
38
39 if [ -n "$(uci -q get meshwizard.contact)" ]; then
40         echo "    + Setup contact"
41         uci show meshwizard.contact | sed 's/^meshwizard/freifunk/g' | while read line; do
42                 eval uci set $line
43                 echo "    $line"
44         done
45         uci -q delete meshwizard.contact
46 fi
47
48 if [ -n "$(uci -q get meshwizard.luci_main)" ]; then
49         echo "    + Setup luci"
50         uci show meshwizard.luci_main |sed -e 's/^meshwizard/luci/g' -e 's/luci_main/main/' | while read line; do 
51                 eval uci set $line
52                 echo "    $line"
53         done
54         uci -q delete meshwizard.luci_main
55 fi
56
57 uci commit
58
59