2 # This script will take settings from /etc/config/meshwizard, /etc/config/freifunk and /etc/config/profile_<selected in freifunk>
3 # and setup the router to participate in wireless mesh networks
8 export dir="/usr/bin/meshwizard"
12 # Rename wifi interfaces
13 echo "++++ Renaming wifi-devices in /etc/config/meshwizard"
14 $dir/helpers/rename-wifi.sh
16 # Firstboot/initial config
17 echo "++++ Initial config"
18 $dir/helpers/initial_config.sh
21 export community=$(uci get freifunk.community.name)
22 [ -z "$community" ] && echo "Error: Community is not set in /etc/config/freifunk, aborting now." && exit 1
24 # Check whether we want to cleanup uci config before setting new options or not
25 cleanup=$(uci -q get meshwizard.general.cleanup)
27 [ "$cleanup" == 1 ] && export cleanup=1
29 # Get a list of networks we need to setup
30 networks=$(uci show meshwizard.netconfig | grep -v "netconfig=" | sed -e 's/meshwizard.netconfig\.\(.*\)\_.*/\1/' |sort|uniq)
33 [ -z "$networks" ] && echo "Error: No networks to setup could be found in /etc/config/meshwizard, aborting now." && exit 1
35 echo "+++ wizard 0.0.1 +++
39 # Read default values (first from /etc/config/freifunk, then from /etc/config/profile_$community,
40 # last will overwrite first
43 $dir/helpers/read_defaults.sh $community > /tmp/meshwizard.tmp
46 done < /tmp/meshwizard.tmp
49 echo "++++ dnsmasq config"
50 $dir/helpers/setup_dnsmasq.sh
52 # Configure found networks
53 for net in $networks; do
55 netrenamed="${net/radio/wireless}"
58 echo "++++ Configure interface $net"
61 echo "$(msg_start $config)"
62 $dir/helpers/setup_network.sh $net
65 echo "$(msg_start $config)"
66 $dir/helpers/setup_wifi.sh $net
69 echo "$(msg_start $config)"
70 $dir/helpers/setup_olsrd.sh $net
72 net_dhcp=$(uci -q get meshwizard.netconfig.${net}_dhcp)
73 if [ "$net_dhcp" == 1 ]; then
75 echo "$(msg_start $config)"
76 $dir/helpers/setup_dhcp.sh $net
80 echo "$(msg_start $config)"
81 $dir/helpers/setup_splash.sh $net
84 echo "$(msg_start $config)"
85 $dir/helpers/setup_firewall.sh $net
87 echo " Configuration of $net finished."
90 ##### Restart services
91 services="network olsrd dnsmasq luci_splash"
92 echo " Restarting services:"
93 for s in $services; do
94 /etc/init.d/$s restart >/dev/null 2>&1