From: Manuel Munz Date: Sat, 12 Jan 2013 19:30:45 +0000 (+0000) Subject: contrib/meshwizard: Move the check if VAPs are supported in a seperate script so... X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fluci.git;a=commitdiff_plain;h=a951a5991d46d069cd2440ac837e63f26368515b 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 --- diff --git a/contrib/package/meshwizard/Makefile b/contrib/package/meshwizard/Makefile index a88113af6..3aaddec25 100644 --- a/contrib/package/meshwizard/Makefile +++ b/contrib/package/meshwizard/Makefile @@ -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) diff --git a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_wifi.sh b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_wifi.sh index 001754c12..9d1bce3e6 100755 --- a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_wifi.sh +++ b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_wifi.sh @@ -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 diff --git a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/supports_vap.sh b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/supports_vap.sh new file mode 100755 index 000000000..045ea976e --- /dev/null +++ b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/supports_vap.sh @@ -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 + +