include $(TOPDIR)/rules.mk
PKG_NAME:=meshwizard
-PKG_RELEASE:=0.0.14
+PKG_RELEASE:=0.1.0
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
[ "$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"
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
[ -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
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%%/*}
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
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
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
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
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
-
--- /dev/null
+#!/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
. /lib/functions.sh
echo "
-/* Meshwizard 0.0.9 */
+/* Meshwizard 0.1.0 */
"
# config
# 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)