contrib/meshwizard: fix LAN with OLSR and DHCP
authorManuel Munz <munz@comuno.net>
Tue, 7 Jul 2015 10:22:39 +0000 (12:22 +0200)
committerManuel Munz <munz@comuno.net>
Tue, 7 Jul 2015 10:22:39 +0000 (12:22 +0200)
contrib/package/meshwizard/Makefile
contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_dhcp.sh
contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_firewall.sh
contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_network.sh
contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_splash.sh
contrib/package/meshwizard/files/usr/bin/meshwizard/wizard.sh

index 6959c544cfb98130715017821e954b8801e6bc0d..b4baab7fa4749347a1c6409d72ea8591f1493146 100644 (file)
@@ -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)
 
index 707178d2765672f63f19e710b576840bdfa59ff1..8cce8319a6e9f63a78123d2f3baf5984414c6330 100755 (executable)
@@ -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
index 52659457d17d5f23b29c23db05a34ae4f04db929..154b2b691331a0b342d61d5f7136fed66cb421b9 100755 (executable)
@@ -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
 }
index d8aa8a095fbea243bf052e7f5bfc25f5e0664fd1..7035e7fb4b3f64cdf5976dec263da0abf8524043 100755 (executable)
@@ -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
index 7cac3d6979d676d4eb1b53bf2ef604e7cad0b3ff..3c3e6a32e221b8f16d436f7327538d16a7e5e9e6 100755 (executable)
@@ -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
index b666313e460e2a538eed8d8a10f3adfcf07c8953..372148997c1d511d1e0152db2c16836556a4b740 100755 (executable)
@@ -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