diff options
9 files changed, 89 insertions, 62 deletions
diff --git a/contrib/package/meshwizard/Makefile b/contrib/package/meshwizard/Makefile index f1fe434a72..45d5f21623 100644 --- a/contrib/package/meshwizard/Makefile +++ b/contrib/package/meshwizard/Makefile @@ -4,7 +4,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=meshwizard -PKG_RELEASE:=0.0.14 +PKG_RELEASE:=0.1.0 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) diff --git a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_dhcp.sh b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_dhcp.sh index a6f16b32e0..707178d276 100755 --- a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_dhcp.sh +++ b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_dhcp.sh @@ -20,7 +20,7 @@ config_foreach handle_dnsmasq dhcp [ "$net" == "lan" ] && uci -q delete dhcp.lan -if [ "$vap" == 1 ]; then +if [ "$supports_vap" = 1 -a "$vap" = 1 ]; then uci batch <<- EOF set dhcp.${netrenamed}dhcp="dhcp" set dhcp.${netrenamed}dhcp.interface="${netrenamed}dhcp" @@ -28,11 +28,13 @@ if [ "$vap" == 1 ]; then set_defaults "dhcp_" dhcp.${netrenamed}dhcp fi -uci batch << EOF - set dhcp.${netrenamed}ahdhcp="dhcp" - set dhcp.${netrenamed}ahdhcp.interface="${netrenamed}ahdhcp" -EOF - +ahdhcp_when_vap="$(uci get profile_$community.profile.adhoc_dhcp_when_vap)" +if [ "$supports_vap" = 0 ] || [ "$supports_vap" = 1 -a "$vap" = 1 -a "$ahdhcp_when_vap" = 1 ]; then + uci batch <<- EOF + set dhcp.${netrenamed}ahdhcp="dhcp" + set dhcp.${netrenamed}ahdhcp.interface="${netrenamed}ahdhcp" + EOF +fi set_defaults "dhcp_" dhcp.${netrenamed}ahdhcp uci_commitverbose "Setup DHCP for $netrenamed" dhcp diff --git a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_firewall_interface.sh b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_firewall_interface.sh index 893aed4524..8ca5d3b77b 100755 --- a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_firewall_interface.sh +++ b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_firewall_interface.sh @@ -45,10 +45,6 @@ network=$(echo $network) # Removes leading and trailing whitespaces [ -n "$netrenamed" ] && [ -z "$(echo $network | grep $netrenamed)" ] && network="$network $netrenamed" -# check if this hardware supports VAPs -supports_vap="0" -$dir/helpers/supports_vap.sh $net $type && supports_vap=1 - if [ "$supports_vap" == "1" -a "$vap" == 1 ]; then [ -n "$netrenamed" ] && [ "$network" == "${network/${netrenamed}dhcp/}" ] && network="$network ${netrenamed}dhcp" fi diff --git a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_network.sh b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_network.sh index f0ed0e7f88..d8aa8a095f 100755 --- a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_network.sh +++ b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_network.sh @@ -68,10 +68,13 @@ if [ "$net_dhcp" == 1 ]; then uci set meshwizard.netconfig.${net}_dhcprange="$dhcprange" fi - # If we use VAP then cut the dhcp range in two halves - # one for the adhoc, one for the managed VAP interface + # If we use VAP and also offer dhcp on the adhoc interface then cut the dhcp + # range in two halves. one for the adhoc, one for the managed VAP interface + ahdhcp_when_vap="$(uci get profile_$community.profile.adhoc_dhcp_when_vap)" - if [ "$vap" == 1 ]; then + if [ "$supports_vap" = 1 -a "$vap" = 1 -a "$ahdhcp_when_vap" = 1 ]; then + # VAPs are enabled for this interface, supported and we want to + # also use DHCP on the adhoc interface local network local mask network=${dhcprange%%/*} @@ -94,21 +97,35 @@ if [ "$net_dhcp" == 1 ]; then set network.${netrenamed}dhcp.netmask="$NETMASKVAP" EOF uci_commitverbose "Setup interface for ${netrenamed}dhcp" network - else eval $(sh $dir/helpers/ipcalc-cidr.sh $dhcprange 1 0) STARTADHOC=$START NETMASKADHOC=$NETMASK fi + if [ "$supports_vap" = 1 -a "$vap" = 1 -a "$ahdhcp_when_vap" != 1 ]; then + # vaps are enabled and supported and we do not use DHCP on adhoc + # Add dhcp interface + uci batch <<- EOF + set network.${netrenamed}dhcp=interface + set network.${netrenamed}dhcp.proto=static + set network.${netrenamed}dhcp.ipaddr="$STARTADHOC" + set network.${netrenamed}dhcp.netmask="$NETMASKADHOC" + EOF + uci_commitverbose "Setup interface for ${netrenamed}dhcp" network + fi - # Setup alias for $net adhoc interface - uci batch <<- EOF - set network.${netrenamed}ahdhcp=interface - set network.${netrenamed}ahdhcp.ifname="@${netrenamed}" - set network.${netrenamed}ahdhcp.proto=static - set network.${netrenamed}ahdhcp.ipaddr="$STARTADHOC" - set network.${netrenamed}ahdhcp.netmask="$NETMASKADHOC" - EOF + # Setup alias for $net adhoc interface + if [ "$supports_vap" = 0 ] || [ "$vap" = 0 ] || [ "$supports_vap" = 1 -a "$vap" = 1 -a "$ahdhcp_when_vap" = 1 ]; then + # vaps are either not supported or enabled or they are supported and enabled + # but we also want to use DHCP on the adhoc interface + uci batch <<- EOF + set network.${netrenamed}ahdhcp=interface + set network.${netrenamed}ahdhcp.ifname="@${netrenamed}" + set network.${netrenamed}ahdhcp.proto=static + set network.${netrenamed}ahdhcp.ipaddr="$STARTADHOC" + set network.${netrenamed}ahdhcp.netmask="$NETMASKADHOC" + EOF + fi uci_commitverbose "Setup interface for ${netrenamed}ahdhcp" network fi diff --git a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_splash.sh b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_splash.sh index 722567e813..7cac3d6979 100755 --- a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_splash.sh +++ b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_splash.sh @@ -17,6 +17,14 @@ uci_commitverbose "Setup general splash settings" luci_splash dhcprange=$(uci -q get meshwizard.netconfig.$net\_dhcprange) +splash_net_add() { + uci batch <<- EOF + set luci_splash.$1="iface" + set luci_splash.$1.network="$1" + set luci_splash.$1.zone="freifunk" + EOF +} + if [ "$(uci -q get meshwizard.netconfig.$net\_dhcp)" == 1 ] && [ -n "$dhcprange" ]; then handle_splash() { config_get network "$1" network @@ -29,21 +37,16 @@ if [ "$(uci -q get meshwizard.netconfig.$net\_dhcp)" == 1 ] && [ -n "$dhcprange" config_load luci_splash config_foreach handle_splash iface - if [ "$vap" == 1 ]; then - uci batch <<- EOF - set luci_splash.${netrenamed}dhcp="iface" - set luci_splash.${netrenamed}dhcp.network="${netrenamed}dhcp" - set luci_splash.${netrenamed}dhcp.zone="freifunk" - EOF + if [ "$supports_vap" = 1 -a "$vap" = 1 ]; then + splash_net_add ${netrenamed}dhcp uci_commitverbose "Setup dhcpsplash for ${netrenamed}dhcp" luci_splash fi - uci batch <<- EOF - set luci_splash.${netrenamed}ahdhcp="iface" - set luci_splash.${netrenamed}ahdhcp.network="${netrenamed}ahdhcp" - set luci_splash.${netrenamed}ahdhcp.zone="freifunk" - EOF - uci_commitverbose "Setup dhcpsplash for ${netrenamed}ahdhcp" luci_splash + ahdhcp_when_vap="$(uci get profile_$community.profile.adhoc_dhcp_when_vap)" + if [ "$supports_vap" = 0 ] || [ "$supports_vap" = 1 -a "$vap" = 1 -a "$ahdhcp_when_vap" = 1 ]; then + splash_net_add ${netrenamed}ahdhcp + uci_commitverbose "Setup dhcpsplash for ${netrenamed}ahdhcp" luci_splash + fi /etc/init.d/luci_splash enable fi diff --git a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_wifi.sh b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_wifi.sh index c8d0587c5f..3d28e3956c 100755 --- a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_wifi.sh +++ b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_wifi.sh @@ -28,7 +28,6 @@ uci set wireless.${net}=wifi-device set_defaults "wifi_device_" wireless.${net} channel="$(uci -q get meshwizard.netconfig.$net\_channel)" -vap="$(uci -q get meshwizard.netconfig.$net\_vap)" if [ -z "$channel" -o "$channel" == "default" ]; then channel=$wifi_device_channel @@ -77,26 +76,3 @@ EOF uci_commitverbose "Setup wifi interface for $netrenamed" wireless -## VAP -ip4addr="$(uci get meshwizard.netconfig.$net\_ip4addr)" - -# check if this hardware supports VAPs -# the interface needs to be up before the check can happen - -/sbin/wifi - -supports_vap="0" -$dir/helpers/supports_vap.sh $net $type && supports_vap=1 - -if [ "$supports_vap" == "1" -a "$vap" == 1 ]; then - uci batch <<- EOF - set wireless.$net\_iface_dhcp="wifi-iface" - set wireless.$net\_iface_dhcp.device="$net" - set wireless.$net\_iface_dhcp.mode="ap" - set wireless.$net\_iface_dhcp.encryption="none" - set wireless.$net\_iface_dhcp.network="${netrenamed}dhcp" - set wireless.$net\_iface_dhcp.ssid="Freifunk-$ip4addr" - EOF - uci_commitverbose "Setup VAP interface for $netrenamed" wireless -fi - diff --git a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_wifi_vap.sh b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_wifi_vap.sh new file mode 100755 index 0000000000..df58ad76d3 --- /dev/null +++ b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_wifi_vap.sh @@ -0,0 +1,23 @@ +#!/bin/sh +# sets up a wifi interface for meshing +# Arguments: $1 = network interface + +net="$1" +. /lib/functions.sh +. $dir/functions.sh + +## Setup a VAP interface in AP Mode +ip4addr="$(uci get meshwizard.netconfig.$net\_ip4addr)" +vap="$(uci -q get meshwizard.netconfig.$net\_vap)" + +if [ "$supports_vap" == 1 -a "$vap" == 1 ]; then + uci batch <<- EOF + set wireless.$net\_iface_dhcp="wifi-iface" + set wireless.$net\_iface_dhcp.device="$net" + set wireless.$net\_iface_dhcp.mode="ap" + set wireless.$net\_iface_dhcp.encryption="none" + set wireless.$net\_iface_dhcp.network="${netrenamed}dhcp" + set wireless.$net\_iface_dhcp.ssid="Freifunk-$ip4addr" + EOF + uci_commitverbose "Setup VAP interface for $netrenamed" wireless +fi diff --git a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/supports_vap.sh b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/supports_vap.sh index 045ea976e0..0585ab5fe1 100755 --- a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/supports_vap.sh +++ b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/supports_vap.sh @@ -32,4 +32,3 @@ else exit 1 fi - diff --git a/contrib/package/meshwizard/files/usr/bin/meshwizard/wizard.sh b/contrib/package/meshwizard/files/usr/bin/meshwizard/wizard.sh index 47fc3ca172..0cdbc2e649 100755 --- a/contrib/package/meshwizard/files/usr/bin/meshwizard/wizard.sh +++ b/contrib/package/meshwizard/files/usr/bin/meshwizard/wizard.sh @@ -12,7 +12,7 @@ . /lib/functions.sh echo " -/* Meshwizard 0.0.9 */ +/* Meshwizard 0.1.0 */ " # config @@ -95,10 +95,21 @@ for net in $networks; do # radioX devices need to be renamed netrenamed="${net/radio/wireless}" export netrenamed - $dir/helpers/setup_network.sh $net + if [ ! "$net" == "wan" ] && [ ! "$net" == "lan" ]; then $dir/helpers/setup_wifi.sh $net + # check if this net supports vap + /sbin/wifi # wifi needs to be up for the check + export supports_vap="0" + type="$(uci -q get wireless.$net.type)" + [ -n "$type" ] && $dir/helpers/supports_vap.sh $net $type && export supports_vap=1 + if [ "$supports_vap" = 1 ]; then + $dir/helpers/setup_wifi_vap.sh $net + fi fi + + $dir/helpers/setup_network.sh $net + $dir/helpers/setup_olsrd_interface.sh $net net_dhcp=$(uci -q get meshwizard.netconfig.${net}_dhcp) |