From 6d788d82f139ba10b08384fba42f25d13bd6f47a Mon Sep 17 00:00:00 2001 From: Manuel Munz Date: Tue, 7 Jul 2015 12:22:39 +0200 Subject: [PATCH] contrib/meshwizard: fix LAN with OLSR and DHCP --- contrib/package/meshwizard/Makefile | 2 +- .../usr/bin/meshwizard/helpers/setup_dhcp.sh | 6 ++++- .../bin/meshwizard/helpers/setup_firewall.sh | 3 +-- .../bin/meshwizard/helpers/setup_network.sh | 24 +++++++++++++++---- .../bin/meshwizard/helpers/setup_splash.sh | 10 ++++---- .../files/usr/bin/meshwizard/wizard.sh | 11 ++++++++- 6 files changed, 42 insertions(+), 14 deletions(-) diff --git a/contrib/package/meshwizard/Makefile b/contrib/package/meshwizard/Makefile index 6959c544c..b4baab7fa 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.3.0 +PKG_RELEASE:=0.3.1 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 707178d27..8cce8319a 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 @@ -23,15 +23,19 @@ config_foreach handle_dnsmasq dhcp if [ "$supports_vap" = 1 -a "$vap" = 1 ]; then uci batch <<- EOF set dhcp.${netrenamed}dhcp="dhcp" + set dhcp.${netrenamed}dhcp.ignore="0" set dhcp.${netrenamed}dhcp.interface="${netrenamed}dhcp" EOF set_defaults "dhcp_" dhcp.${netrenamed}dhcp fi 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 +if [ "$supports_vap" = 0 ] || \ + [ "$supports_vap" = 1 -a "$vap" = 1 -a "$ahdhcp_when_vap" = 1 ] || \ + [ "$lan_is_olsr" = "1" -a "$lan_dhcp" = 1 ]; then uci batch <<- EOF set dhcp.${netrenamed}ahdhcp="dhcp" + set dhcp.${netrenamed}ahdhcp.ignore="0" set dhcp.${netrenamed}ahdhcp.interface="${netrenamed}ahdhcp" EOF fi diff --git a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_firewall.sh b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_firewall.sh index 52659457d..154b2b691 100755 --- a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_firewall.sh +++ b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_firewall.sh @@ -7,7 +7,6 @@ . $dir/functions.sh wan_is_olsr=$(uci -q get meshwizard.netconfig.wan_config) -lan_is_olsr=$(uci -q get meshwizard.netconfig.lan_config) config_load firewall @@ -34,7 +33,7 @@ handle_fwzone() { fi fi - if [ "$name" == "lan" ] && [ "$lan_is_olsr" == 1 ]; then + if [ "$name" == "lan" ] && [ "$lan_is_olsr" == "1" ]; then uci set firewall.$1.network=' ' && uci_commitverbose "LAN is used for olsr, removed the lan interface from zone lan" firewall 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 d8aa8a095..7035e7fb4 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 @@ -1,6 +1,6 @@ # setup entry in /etc/config/network for a interface # Argument $1: network interface - + net="$1" . /lib/functions.sh . $dir/functions.sh @@ -24,6 +24,13 @@ uci batch << EOF set network.$netrenamed.netmask="$netmask" EOF +if [ "$netrenamed" = "lan" ]; then + # remove the bridge if the interface is used for olsr + # since this script is only run in this case, no need + # to check for lan_proto = "olsr" currently. + uci -q delete network.lan.type +fi + # Setup IPv6 for the interface local ip6addr if [ "$ipv6_enabled" = 1 ]; then @@ -116,9 +123,16 @@ if [ "$net_dhcp" == 1 ]; then # 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 + if [ "$supports_vap" = 0 ] || \ + [ "$vap" = 0 ] || \ + [ "$supports_vap" = 1 -a "$vap" = 1 -a "$ahdhcp_when_vap" = 1 ] || \ + [ "$lan_is_olsr" = "1" ]; then + # setup an alias interface for the main interface to use as a network for clients + # when one of the following conditions is met + # * vaps are not supported + # * or not enabled + # * or they are supported and enabled but we also want to use DHCP on the adhoc interface + # * or this is the lan interface and it is used for olsrd (and dhcp is enabled) uci batch <<- EOF set network.${netrenamed}ahdhcp=interface set network.${netrenamed}ahdhcp.ifname="@${netrenamed}" @@ -126,6 +140,6 @@ if [ "$net_dhcp" == 1 ]; then set network.${netrenamed}ahdhcp.ipaddr="$STARTADHOC" set network.${netrenamed}ahdhcp.netmask="$NETMASKADHOC" EOF + uci_commitverbose "Setup interface for ${netrenamed}ahdhcp" network 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 7cac3d697..3c3e6a32e 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 @@ -25,7 +25,7 @@ splash_net_add() { EOF } -if [ "$(uci -q get meshwizard.netconfig.$net\_dhcp)" == 1 ] && [ -n "$dhcprange" ]; then +if [ "$(uci -q get meshwizard.netconfig.$net\_dhcp)" = 1 ] && [ -n "$dhcprange" ]; then handle_splash() { config_get network "$1" network if [ "$network" == "${netrenamed}dhcp" ]; then @@ -38,13 +38,15 @@ if [ "$(uci -q get meshwizard.netconfig.$net\_dhcp)" == 1 ] && [ -n "$dhcprange" config_foreach handle_splash iface if [ "$supports_vap" = 1 -a "$vap" = 1 ]; then - splash_net_add ${netrenamed}dhcp + splash_net_add ${netrenamed}dhcp uci_commitverbose "Setup dhcpsplash for ${netrenamed}dhcp" luci_splash fi 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 + if [ "$supports_vap" = 0 ] || \ + [ "$supports_vap" = 1 -a "$vap" = 1 -a "$ahdhcp_when_vap" = 1 ] || \ + [ "$lan_dhcp" = 1 ]; then + splash_net_add ${netrenamed}ahdhcp uci_commitverbose "Setup dhcpsplash for ${netrenamed}ahdhcp" luci_splash fi /etc/init.d/luci_splash enable diff --git a/contrib/package/meshwizard/files/usr/bin/meshwizard/wizard.sh b/contrib/package/meshwizard/files/usr/bin/meshwizard/wizard.sh index b666313e4..372148997 100755 --- a/contrib/package/meshwizard/files/usr/bin/meshwizard/wizard.sh +++ b/contrib/package/meshwizard/files/usr/bin/meshwizard/wizard.sh @@ -10,7 +10,7 @@ # You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 echo " -/* Meshwizard 0.3.0 */ +/* Meshwizard 0.3.1 */ " # config @@ -34,6 +34,8 @@ cleanup=$(uci -q get meshwizard.general.cleanup) # Rename wifi interfaces $dir/helpers/rename-wifi.sh +export lan_is_olsr="$(uci -q get meshwizard.netconfig.lan_config)" + # Get community 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 @@ -114,6 +116,13 @@ for net in $networks; do $dir/helpers/setup_olsrd_interface.sh $net net_dhcp=$(uci -q get meshwizard.netconfig.${net}_dhcp) + export ${net}_dhcp=$net_dhcp + + if [ "$net" = "lan" ] && [ "$lan_is_olsr" = "1" ]; then + uci -q set dhcp.lan.ignore="1" + uci_commitverbose "Disable DHCP on LAN because it is an olsr interface." dhcp + fi + if [ "$net_dhcp" == 1 ]; then $dir/helpers/setup_dhcp.sh $net fi -- 2.25.1