X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=contrib%2Fpackage%2Fmeshwizard%2Ffiles%2Fusr%2Fbin%2Fmeshwizard%2Fhelpers%2Fsetup_network.sh;h=3ad977e265f21b7ac0e729488ef8a1fa965c7a2d;hb=a3fc4859dd0d3e9e9fa87ca249b815a4710ed7bd;hp=f0ed0e7f881c78783e2940fae553e0d9867d0136;hpb=d55f7135de9b7cd4345305e70cc30d143f9e37e6;p=oweals%2Fluci.git 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 f0ed0e7f8..3ad977e26 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,8 +24,14 @@ 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 if [ "$ipv6_config" = "auto-ipv6-dhcpv6" ]; then ip6addr="$($dir/helpers/gen_auto-ipv6-dhcpv6-ip.sh $netrenamed)" @@ -68,12 +74,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 - local network - local mask + 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 network=${dhcprange%%/*} mask=${dhcprange##*/} # Divide network size by adding 1 to the netmask @@ -94,21 +101,42 @@ 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 - uci_commitverbose "Setup interface for ${netrenamed}ahdhcp" network + # Setup alias for $net 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}" + set network.${netrenamed}ahdhcp.proto=static + set network.${netrenamed}ahdhcp.ipaddr="$STARTADHOC" + set network.${netrenamed}ahdhcp.netmask="$NETMASKADHOC" + EOF + uci_commitverbose "Setup interface for ${netrenamed}ahdhcp" network + fi fi