luci-0.11: merge r9571 - r9622
[project/luci.git] / contrib / package / meshwizard / files / usr / bin / meshwizard / helpers / supports_vap.sh
1 #!/bin/sh
2 # checks if a given device can be used for a VAP interface (1 adhoc + 1 ap)
3 dev="$1"
4 type="$2"
5
6
7 if [ -z "$dev" -o -z "$type" ]; then
8 exit 1
9 fi
10
11 if [ "$type" = "atheros" ]; then
12 exit 0
13 elif [ "$type" = "mac80211" ]; then
14 # not hostapd[-mini], no VAP
15 if [ ! -x /usr/sbin/hostapd ]; then
16 echo "WARNING: hostapd[-mini] is required to be able to use VAP with mac80211."
17 exit 1
18 fi
19 # get driver in use
20 netindex="$(echo $dev |sed 's/[a-zA-z]*//')"
21 if [ -d /sys/class/net/wlan${netindex}/device/driver/module ]; then
22 driver="$(basename $(ls -l /sys/class/net/wlan${netindex}/device/driver/module | sed -ne 's/.* -> //p'))"
23 if [ "$driver" = "ath9k" -o "$driver" = "ath5k" ]; then
24 exit 0
25 else
26 exit 1
27 fi
28 else
29 exit 1
30 fi
31 else
32 exit 1
33 fi
34
35