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
12 export dir="/usr/bin/meshwizard"
16 # Check which packages we have installed
18 opkg list_installed |grep luci-mod-admin > /dev/null && export has_luci=TRUE
19 export has_luci_splash=FALSE
20 opkg list_installed |grep luci-app-splash > /dev/null && export has_luci_splash=TRUE
22 # Rename wifi interfaces
23 echo "+ Renaming wifi-devices in /etc/config/meshwizard"
24 $dir/helpers/rename-wifi.sh
27 export community=$(uci -q get meshwizard.community.name)
28 [ -z "$community" ] && community=$(uci -q get freifunk.community.name)
29 [ -z "$community" ] && echo "Error: Community is not set in /etc/config/freifunk, aborting now." && exit 1
31 # Check whether we want to cleanup uci config before setting new options or not
32 cleanup=$(uci -q get meshwizard.general.cleanup)
34 [ "$cleanup" == 1 ] && export cleanup=1
36 # Get a list of networks we need to setup
37 networks=$(uci show meshwizard.netconfig | grep -v "netconfig=" | sed -e 's/meshwizard.netconfig\.\(.*\)\_.*/\1/' |sort|uniq)
40 [ -z "$networks" ] && echo "Error: No networks to setup could be found in /etc/config/meshwizard, aborting now." && exit 1
42 echo " Community=$community
45 # Read default values (first from /etc/config/freifunk, then from /etc/config/profile_$community
46 # then /etc/config/meshwizard
47 # last will overwrite first
49 $dir/helpers/read_defaults.sh $community > /tmp/meshwizard.tmp
52 done < /tmp/meshwizard.tmp
54 # Firstboot/initial config
55 echo "+ Initial config"
56 $dir/helpers/initial_config.sh
59 $dir/helpers/setup_dnsmasq.sh
60 $dir/helpers/setup_system.sh
61 $dir/helpers/setup_freifunk.sh
63 # Configure found networks
64 for net in $networks; do
66 netrenamed="${net/radio/wireless}"
69 $dir/helpers/setup_network.sh $net
70 $dir/helpers/setup_wifi.sh $net
71 $dir/helpers/setup_olsrd.sh $net
73 net_dhcp=$(uci -q get meshwizard.netconfig.${net}_dhcp)
74 if [ "$net_dhcp" == 1 ]; then
75 $dir/helpers/setup_dhcp.sh $net
78 $dir/helpers/setup_splash.sh $net
79 $dir/helpers/setup_firewall.sh $net
82 ##### Reboot the router (because simply restarting services gave errors)