add changes that were missing in the last commit
[project/luci.git] / contrib / package / meshwizard / files / usr / bin / meshwizard / wizard.sh
index 77c6cd95e90e4f977aed4546a58b2e23acc61c45..b666313e460e2a538eed8d8a10f3adfcf07c8953 100755 (executable)
@@ -9,15 +9,16 @@
 # You may not use this file except in compliance with the License.
 # You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
 
-. /lib/functions.sh
-
 echo "
-/* Meshwizard 0.2.0 */
+/* Meshwizard 0.3.0 */
 "
 
 # config
 export dir="/usr/bin/meshwizard"
+
+. /lib/functions.sh
 . $dir/functions.sh
+. $dir/helpers/read_defaults.sh
 [ -f /proc/net/ipv6_route ] && export has_ipv6=1
 
 # Check which packages we have installed
@@ -28,30 +29,26 @@ opkg list_installed |grep luci-app-splash > /dev/null && export has_luci_splash=
 
 # Check whether we want to cleanup/restore uci config before setting new options
 cleanup=$(uci -q get meshwizard.general.cleanup)
-[ "$cleanup" == 1 ] && $dir/helpers/restore_default_config.sh
+[ "$cleanup" == 1 ] && restore_factory_defaults
 
 # Rename wifi interfaces
 $dir/helpers/rename-wifi.sh
 
 # Get community
-community=$(uci -q get meshwizard.community.name || uci -q get freifunk.community.name)
+community="$(uci -q get meshwizard.community.name || uci -q get freifunk.community.name)"
 [ -z "$community" ] && echo "Error: Community is not set in /etc/config/freifunk, aborting now." && exit 1
 export community="$community"
-echo $community
+
+# we need a list of widgets later on. It will be populated in read_defaults.sh
+local widgets=""
 
 # Get a list of networks we need to setup
 networks=$(uci show meshwizard.netconfig | grep -v "netconfig=" | sed -e 's/meshwizard.netconfig\.\(.*\)\_.*/\1/' |sort|uniq)
 export networks
 [ -z "$networks" ] && echo "Error: No networks to setup could be found in /etc/config/meshwizard, aborting now." && exit 1
 
-# Read default values (first from /etc/config/freifunk, then from /etc/config/profile_$community
-# then /etc/config/meshwizard
-# last will overwrite first
-
-$dir/helpers/read_defaults.sh $community > /tmp/meshwizard.tmp
-while read line; do
-       export "${line//\"/}"
-done < /tmp/meshwizard.tmp
+# Read defaults and node config
+read_defaults $community
 
 # Do config
 $dir/helpers/initial_config.sh