X-Git-Url: http://git.archive.openwrt.org/?a=blobdiff_plain;f=contrib%2Fpackage%2Fmeshwizard%2Ffiles%2Fusr%2Fbin%2Fmeshwizard%2Fwizard.sh;h=f6b227dceb3e32c0353219f267c3451730162424;hb=6574b8147c8067c6f2df124557f58bd10b18aaae;hp=547f44afd10862f7a3b65cae254853e8a3ecf130;hpb=a9b87ff8e539af3a2e90d04af25f666631c1a94d;p=project%2Fluci.git diff --git a/contrib/package/meshwizard/files/usr/bin/meshwizard/wizard.sh b/contrib/package/meshwizard/files/usr/bin/meshwizard/wizard.sh index 547f44afd..f6b227dce 100755 --- a/contrib/package/meshwizard/files/usr/bin/meshwizard/wizard.sh +++ b/contrib/package/meshwizard/files/usr/bin/meshwizard/wizard.sh @@ -1,98 +1,119 @@ #!/bin/sh -# This script will take settings from /etc/config/meshwizard, /etc/config/freifunk and /etc/config/profile_ -# and setup the router to participate in wireless mesh networks -. /etc/functions.sh +# This collection of scripts will take settings from /etc/config/meshwizard, /etc/config/freifunk +# and /etc/config/profile_ and setup the router to participate in wireless mesh networks + +# Copyright 2011 Manuel Munz + +# Licensed under the Apache License, Version 2.0 (the "License") +# 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.0.8 */ +" # config export dir="/usr/bin/meshwizard" . $dir/functions.sh -debug=1 +[ -f /proc/net/ipv6_route ] && export has_ipv6=1 -# Rename wifi interfaces - echo "++++ Renaming wifi-devices in /etc/config/meshwizard" - $dir/helpers/rename-wifi.sh +# Check which packages we have installed +export has_luci=FALSE +opkg list_installed |grep luci-mod-admin > /dev/null && export has_luci=TRUE +export has_luci_splash=FALSE +opkg list_installed |grep luci-app-splash > /dev/null && export has_luci_splash=TRUE -# Firstboot/initial config - echo "++++ Initial config" - $dir/helpers/initial_config.sh +# 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 + +# Rename wifi interfaces +$dir/helpers/rename-wifi.sh # Get community -export community=$(uci 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 - -# Check whether we want to cleanup uci config before setting new options or not -cleanup=$(uci -q get meshwizard.general.cleanup) - -[ "$cleanup" == 1 ] && export cleanup=1 +export community="$community" +echo $community # 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 -echo "+++ wizard 0.0.1 +++ -Community=$community -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 - $dir/helpers/read_defaults.sh $community > /tmp/meshwizard.tmp while read line; do export "${line//\"/}" done < /tmp/meshwizard.tmp -# dnsmasq - echo "++++ dnsmasq config" - $dir/helpers/setup_dnsmasq.sh +# Do config +$dir/helpers/initial_config.sh +$dir/helpers/setup_dnsmasq.sh +$dir/helpers/setup_system.sh +$dir/helpers/setup_olsrd.sh +$dir/helpers/setup_firewall.sh +$dir/helpers/setup_ssh.sh + +if [ "$wan_proto" == "static" ] && [ -n "$wan_ip4addr" ] && [ -n "$wan_netmask" ]; then + $dir/helpers/setup_wan_static.sh +fi + +if [ "$wan_proto" == "dhcp" ]; then + $dir/helpers/setup_wan_dhcp.sh +fi + +if [ "$lan_proto" == "static" ] && [ -n "$lan_ip4addr" ] && [ -n "$lan_netmask" ]; then + $dir/helpers/setup_lan_static.sh +fi + +if [ "$profile_ipv6" == 1 ] && [ "$has_ipv6" = 1 ]; then + $dir/helpers/setup_lan_ipv6.sh + # Setup auto-ipv6 + if [ -n "$(echo "$profile_ipv6_config" |grep auto-ipv6)" ]; then + $dir/helpers/setup_auto-ipv6.sh + fi +fi + +# Setup policyrouting if internet sharing is disabled and wan is not used for olsrd +# Always disable it first to make sure its disabled when the user decied to share his internet +uci set freifunk-policyrouting.pr.enable=0 +if [ ! "$general_sharenet" == 1 ] && [ ! "$(uci -q get meshwizard.netconfig.wan_proto)" == "olsr" ]; then + $dir/helpers/setup_policyrouting.sh +fi # Configure found networks for net in $networks; do - + # radioX devices need to be renamed netrenamed="${net/radio/wireless}" export netrenamed - - echo "++++ Configure interface $net" - - config="network" - echo "$(msg_start $config)" $dir/helpers/setup_network.sh $net - - config="wireless" - echo "$(msg_start $config)" - $dir/helpers/setup_wifi.sh $net - - config="OLSRd" - echo "$(msg_start $config)" - $dir/helpers/setup_olsrd.sh $net + if [ ! "$net" == "wan" ] && [ ! "$net" == "lan" ]; then + $dir/helpers/setup_wifi.sh $net + fi + $dir/helpers/setup_olsrd_interface.sh $net net_dhcp=$(uci -q get meshwizard.netconfig.${net}_dhcp) if [ "$net_dhcp" == 1 ]; then - config="DHCP" - echo "$(msg_start $config)" $dir/helpers/setup_dhcp.sh $net fi - config="luci_splash" - echo "$(msg_start $config)" $dir/helpers/setup_splash.sh $net + $dir/helpers/setup_firewall_interface.sh $net - config="firewall" - echo "$(msg_start $config)" - $dir/helpers/setup_firewall.sh $net - - echo " Configuration of $net finished." + if [ -n "$(echo "$profile_ipv6_config" |grep auto-ipv6)" ]; then + $dir/helpers/setup_auto-ipv6-interface.sh $net + fi done -##### Restart services -#services="network olsrd dnsmasq luci_splash" -#echo " Restarting services:" -#for s in $services; do -# /etc/init.d/$s restart >/dev/null 2>&1 -# echo " * $s" -#done +##### Reboot the router (because simply restarting services gave errors) + +echo "+ The wizard has finished and the router will reboot now." reboot