contrib/meshwizard: fix LAN with OLSR and DHCP
This commit is contained in:
parent
9d85b7ee2e
commit
6d788d82f1
6 changed files with 42 additions and 14 deletions
|
@ -4,7 +4,7 @@
|
||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=meshwizard
|
PKG_NAME:=meshwizard
|
||||||
PKG_RELEASE:=0.3.0
|
PKG_RELEASE:=0.3.1
|
||||||
|
|
||||||
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
|
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
|
||||||
|
|
||||||
|
|
|
@ -23,15 +23,19 @@ config_foreach handle_dnsmasq dhcp
|
||||||
if [ "$supports_vap" = 1 -a "$vap" = 1 ]; then
|
if [ "$supports_vap" = 1 -a "$vap" = 1 ]; then
|
||||||
uci batch <<- EOF
|
uci batch <<- EOF
|
||||||
set dhcp.${netrenamed}dhcp="dhcp"
|
set dhcp.${netrenamed}dhcp="dhcp"
|
||||||
|
set dhcp.${netrenamed}dhcp.ignore="0"
|
||||||
set dhcp.${netrenamed}dhcp.interface="${netrenamed}dhcp"
|
set dhcp.${netrenamed}dhcp.interface="${netrenamed}dhcp"
|
||||||
EOF
|
EOF
|
||||||
set_defaults "dhcp_" dhcp.${netrenamed}dhcp
|
set_defaults "dhcp_" dhcp.${netrenamed}dhcp
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ahdhcp_when_vap="$(uci get profile_$community.profile.adhoc_dhcp_when_vap)"
|
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
|
uci batch <<- EOF
|
||||||
set dhcp.${netrenamed}ahdhcp="dhcp"
|
set dhcp.${netrenamed}ahdhcp="dhcp"
|
||||||
|
set dhcp.${netrenamed}ahdhcp.ignore="0"
|
||||||
set dhcp.${netrenamed}ahdhcp.interface="${netrenamed}ahdhcp"
|
set dhcp.${netrenamed}ahdhcp.interface="${netrenamed}ahdhcp"
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
. $dir/functions.sh
|
. $dir/functions.sh
|
||||||
|
|
||||||
wan_is_olsr=$(uci -q get meshwizard.netconfig.wan_config)
|
wan_is_olsr=$(uci -q get meshwizard.netconfig.wan_config)
|
||||||
lan_is_olsr=$(uci -q get meshwizard.netconfig.lan_config)
|
|
||||||
|
|
||||||
config_load firewall
|
config_load firewall
|
||||||
|
|
||||||
|
@ -34,7 +33,7 @@ handle_fwzone() {
|
||||||
fi
|
fi
|
||||||
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
|
uci set firewall.$1.network=' ' && uci_commitverbose "LAN is used for olsr, removed the lan interface from zone lan" firewall
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,13 @@ uci batch << EOF
|
||||||
set network.$netrenamed.netmask="$netmask"
|
set network.$netrenamed.netmask="$netmask"
|
||||||
EOF
|
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
|
# Setup IPv6 for the interface
|
||||||
local ip6addr
|
local ip6addr
|
||||||
if [ "$ipv6_enabled" = 1 ]; then
|
if [ "$ipv6_enabled" = 1 ]; then
|
||||||
|
@ -116,9 +123,16 @@ if [ "$net_dhcp" == 1 ]; then
|
||||||
|
|
||||||
|
|
||||||
# Setup alias for $net adhoc interface
|
# Setup alias for $net adhoc interface
|
||||||
if [ "$supports_vap" = 0 ] || [ "$vap" = 0 ] || [ "$supports_vap" = 1 -a "$vap" = 1 -a "$ahdhcp_when_vap" = 1 ]; then
|
if [ "$supports_vap" = 0 ] || \
|
||||||
# vaps are either not supported or enabled or they are supported and enabled
|
[ "$vap" = 0 ] || \
|
||||||
# but we also want to use DHCP on the adhoc interface
|
[ "$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
|
uci batch <<- EOF
|
||||||
set network.${netrenamed}ahdhcp=interface
|
set network.${netrenamed}ahdhcp=interface
|
||||||
set network.${netrenamed}ahdhcp.ifname="@${netrenamed}"
|
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.ipaddr="$STARTADHOC"
|
||||||
set network.${netrenamed}ahdhcp.netmask="$NETMASKADHOC"
|
set network.${netrenamed}ahdhcp.netmask="$NETMASKADHOC"
|
||||||
EOF
|
EOF
|
||||||
fi
|
|
||||||
uci_commitverbose "Setup interface for ${netrenamed}ahdhcp" network
|
uci_commitverbose "Setup interface for ${netrenamed}ahdhcp" network
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
|
@ -25,7 +25,7 @@ splash_net_add() {
|
||||||
EOF
|
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() {
|
handle_splash() {
|
||||||
config_get network "$1" network
|
config_get network "$1" network
|
||||||
if [ "$network" == "${netrenamed}dhcp" ]; then
|
if [ "$network" == "${netrenamed}dhcp" ]; then
|
||||||
|
@ -43,7 +43,9 @@ if [ "$(uci -q get meshwizard.netconfig.$net\_dhcp)" == 1 ] && [ -n "$dhcprange"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ahdhcp_when_vap="$(uci get profile_$community.profile.adhoc_dhcp_when_vap)"
|
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_dhcp" = 1 ]; then
|
||||||
splash_net_add ${netrenamed}ahdhcp
|
splash_net_add ${netrenamed}ahdhcp
|
||||||
uci_commitverbose "Setup dhcpsplash for ${netrenamed}ahdhcp" luci_splash
|
uci_commitverbose "Setup dhcpsplash for ${netrenamed}ahdhcp" luci_splash
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
echo "
|
echo "
|
||||||
/* Meshwizard 0.3.0 */
|
/* Meshwizard 0.3.1 */
|
||||||
"
|
"
|
||||||
|
|
||||||
# config
|
# config
|
||||||
|
@ -34,6 +34,8 @@ cleanup=$(uci -q get meshwizard.general.cleanup)
|
||||||
# Rename wifi interfaces
|
# Rename wifi interfaces
|
||||||
$dir/helpers/rename-wifi.sh
|
$dir/helpers/rename-wifi.sh
|
||||||
|
|
||||||
|
export lan_is_olsr="$(uci -q get meshwizard.netconfig.lan_config)"
|
||||||
|
|
||||||
# Get community
|
# Get community
|
||||||
community="$(uci -q get meshwizard.community.name || uci -q 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
|
[ -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
|
$dir/helpers/setup_olsrd_interface.sh $net
|
||||||
|
|
||||||
net_dhcp=$(uci -q get meshwizard.netconfig.${net}_dhcp)
|
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
|
if [ "$net_dhcp" == 1 ]; then
|
||||||
$dir/helpers/setup_dhcp.sh $net
|
$dir/helpers/setup_dhcp.sh $net
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue