contrib/meshwizard: Fix setting of values which contain spaces & cleanups
This commit is contained in:
parent
35137845dd
commit
2fa0fa1815
6 changed files with 31 additions and 40 deletions
|
@ -24,9 +24,12 @@ uci_commitverbose() {
|
||||||
}
|
}
|
||||||
|
|
||||||
set_defaults() {
|
set_defaults() {
|
||||||
for def in $(env |grep "^$1"); do
|
for def in $(env |grep "^$1" | sed 's/ /_/g'); do
|
||||||
option=${def/$1/}
|
option="${def/$1/}"
|
||||||
uci set $2.$option
|
a="$(echo $option |cut -d '=' -f1)"
|
||||||
|
b="$(echo $option |cut -d '=' -f2)"
|
||||||
|
b="${b//_/ }"
|
||||||
|
uci set $2.$a="$b"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,42 +18,23 @@ handle_system() {
|
||||||
}
|
}
|
||||||
config_foreach handle_system system
|
config_foreach handle_system system
|
||||||
|
|
||||||
if [ -n "$(uci -q get meshwizard.system)" ]; then
|
|
||||||
echo " + Setup system"
|
|
||||||
uci show meshwizard.system | sed 's/^meshwizard/uci set system/g' | while read line; do
|
|
||||||
eval $line
|
|
||||||
echo " $line"
|
|
||||||
done
|
|
||||||
uci -q delete meshwizard.system
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$(uci -q get meshwizard.community)" ]; then
|
if [ -n "$(uci -q get meshwizard.community)" ]; then
|
||||||
echo " + Setup community"
|
echo " + Setup community"
|
||||||
uci show meshwizard.community | sed 's/^meshwizard/freifunk/g' | while read line; do
|
set_defaults "community_" freifunk.community
|
||||||
eval uci set $line
|
|
||||||
echo " $line"
|
|
||||||
done
|
|
||||||
uci -q delete meshwizard.community
|
uci -q delete meshwizard.community
|
||||||
|
uci_commitverbose freifunk
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$(uci -q get meshwizard.contact)" ]; then
|
if [ -n "$(uci -q get meshwizard.contact)" ]; then
|
||||||
echo " + Setup contact"
|
echo " + Setup contact"
|
||||||
uci show meshwizard.contact | sed 's/^meshwizard/freifunk/g' | while read line; do
|
set_defaults "contact_" freifunk.contact
|
||||||
eval uci set $line
|
uci -q delete meshwizard.contact && uci_commitverbose freifunk
|
||||||
echo " $line"
|
|
||||||
done
|
|
||||||
uci -q delete meshwizard.contact
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$has_luci" == TRUE ]; then
|
if [ "$has_luci" == TRUE ]; then
|
||||||
if [ -n "$(uci -q get meshwizard.luci_main)" ]; then
|
|
||||||
echo " + Setup luci"
|
echo " + Setup luci"
|
||||||
uci show meshwizard.luci_main |sed -e 's/^meshwizard/luci/g' -e 's/luci_main/main/' | while read line; do
|
set_defaults "luci_main_" luci.main
|
||||||
eval uci set $line
|
uci -q delete meshwizard.luci_main && uci_commitverbose luci
|
||||||
echo " $line"
|
|
||||||
done
|
|
||||||
uci -q delete meshwizard.luci_main
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
uci commit
|
uci commit
|
||||||
|
|
|
@ -18,3 +18,8 @@ done
|
||||||
for v in system wifi_device wifi_iface interface alias dhcp olsr_interface olsr_interfacedefaults profile zone_freifunk include; do
|
for v in system wifi_device wifi_iface interface alias dhcp olsr_interface olsr_interfacedefaults profile zone_freifunk include; do
|
||||||
get_var profile_$community.$v
|
get_var profile_$community.$v
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# read values from meshwizard
|
||||||
|
for v in system luci_main contact community; do
|
||||||
|
get_var meshwizard.$v
|
||||||
|
done
|
||||||
|
|
|
@ -4,11 +4,10 @@
|
||||||
. $dir/functions.sh
|
. $dir/functions.sh
|
||||||
|
|
||||||
# Set community homepage
|
# Set community homepage
|
||||||
hp=$(uci -q get profile_$community.profile.homepage)
|
|
||||||
|
|
||||||
if [ -n "$hp" ]; then
|
if [ -n "$profile_homepage" ]; then
|
||||||
uci set freifunk.community.homepage="$hp"
|
uci set freifunk.community.homepage="$profile_homepage"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
uci_commitverbose "/etc/init.d/freifunk config" freifunk
|
uci_commitverbose freifunk
|
||||||
|
|
||||||
|
|
|
@ -9,4 +9,5 @@ if [ -n "$(env | grep '^system_')" ]; then
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
uci -q delete meshwizard.system && uci commit meshwizard
|
||||||
uci_commitverbose "System config" system
|
uci_commitverbose "System config" system
|
||||||
|
|
|
@ -23,12 +23,9 @@ opkg list_installed |grep luci-app-splash > /dev/null && export has_luci_splash=
|
||||||
echo "+ Renaming wifi-devices in /etc/config/meshwizard"
|
echo "+ Renaming wifi-devices in /etc/config/meshwizard"
|
||||||
$dir/helpers/rename-wifi.sh
|
$dir/helpers/rename-wifi.sh
|
||||||
|
|
||||||
# Firstboot/initial config
|
|
||||||
echo "+ Initial config"
|
|
||||||
$dir/helpers/initial_config.sh
|
|
||||||
|
|
||||||
# Get community
|
# Get community
|
||||||
export community=$(uci get freifunk.community.name)
|
export community=$(uci -q get meshwizard.community.name)
|
||||||
|
[ -z "$community" ] && community=$(uci -q get freifunk.community.name)
|
||||||
[ -z "$community" ] && echo "Error: Community is not set in /etc/config/freifunk, aborting now." && exit 1
|
[ -z "$community" ] && echo "Error: Community is not set in /etc/config/freifunk, aborting now." && exit 1
|
||||||
|
|
||||||
# Check whether we want to cleanup uci config before setting new options or not
|
# Check whether we want to cleanup uci config before setting new options or not
|
||||||
|
@ -45,15 +42,20 @@ export networks
|
||||||
echo " Community=$community
|
echo " Community=$community
|
||||||
Network(s)=$networks"
|
Network(s)=$networks"
|
||||||
|
|
||||||
# Read default values (first from /etc/config/freifunk, then from /etc/config/profile_$community,
|
# Read default values (first from /etc/config/freifunk, then from /etc/config/profile_$community
|
||||||
|
# then /etc/config/meshwizard
|
||||||
# last will overwrite first
|
# last will overwrite first
|
||||||
|
|
||||||
|
|
||||||
$dir/helpers/read_defaults.sh $community > /tmp/meshwizard.tmp
|
$dir/helpers/read_defaults.sh $community > /tmp/meshwizard.tmp
|
||||||
while read line; do
|
while read line; do
|
||||||
export "${line//\"/}"
|
export "${line//\"/}"
|
||||||
done < /tmp/meshwizard.tmp
|
done < /tmp/meshwizard.tmp
|
||||||
|
|
||||||
|
# Firstboot/initial config
|
||||||
|
echo "+ Initial config"
|
||||||
|
$dir/helpers/initial_config.sh
|
||||||
|
|
||||||
|
|
||||||
$dir/helpers/setup_dnsmasq.sh
|
$dir/helpers/setup_dnsmasq.sh
|
||||||
$dir/helpers/setup_system.sh
|
$dir/helpers/setup_system.sh
|
||||||
$dir/helpers/setup_freifunk.sh
|
$dir/helpers/setup_freifunk.sh
|
||||||
|
|
Loading…
Reference in a new issue