contrib/meshwizard: Move the check if VAPs are supported in a seperate script so we can reuse it later by luci-app-meshwizard, also check if hostapd[-mini] is installed when using mac80211

This commit is contained in:
Manuel Munz 2013-01-12 19:30:45 +00:00
parent baba6d3dee
commit a951a5991d
3 changed files with 38 additions and 11 deletions

View file

@ -4,7 +4,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=meshwizard
PKG_RELEASE:=0.0.8-2
PKG_RELEASE:=0.0.8-3
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)

View file

@ -80,17 +80,9 @@ uci_commitverbose "Setup wifi interface for $netrenamed" wireless
## VAP
ip4addr="$(uci get meshwizard.netconfig.$net\_ip4addr)"
# check if this hardware supports VAPs
supports_vap="0"
if [ "$type" = "atheros" ]; then
supports_vap="1"
elif [ "$type" = "mac80211" ]; then
# get driver in use
netindex="$(echo $net |sed 's/[a-zA-z]*//')"
driver="$(basename $(ls -l /sys/class/net/wlan${netindex}/device/driver/module | sed -ne 's/.* -> //p'))"
if [ "$driver" = "ath9k" -o "$driver" = "ath5k" ]; then
supports_vap="1"
fi
fi
$dir/helpers/supports_vap.sh $net $type && supports_vap=1
if [ "$supports_vap" == "1" -a "$vap" == 1 ]; then
uci batch <<- EOF

View file

@ -0,0 +1,35 @@
#!/bin/sh
# checks if a given device can be used for a VAP interface (1 adhoc + 1 ap)
dev="$1"
type="$2"
if [ -z "$dev" -o -z "$type" ]; then
exit 1
fi
if [ "$type" = "atheros" ]; then
exit 0
elif [ "$type" = "mac80211" ]; then
# not hostapd[-mini], no VAP
if [ ! -x /usr/sbin/hostapd ]; then
echo "WARNING: hostapd[-mini] is required to be able to use VAP with mac80211."
exit 1
fi
# get driver in use
netindex="$(echo $dev |sed 's/[a-zA-z]*//')"
if [ -d /sys/class/net/wlan${netindex}/device/driver/module ]; then
driver="$(basename $(ls -l /sys/class/net/wlan${netindex}/device/driver/module | sed -ne 's/.* -> //p'))"
if [ "$driver" = "ath9k" -o "$driver" = "ath5k" ]; then
exit 0
else
exit 1
fi
else
exit 1
fi
else
exit 1
fi