summaryrefslogtreecommitdiffhomepage
path: root/contrib/package/meshwizard/files/usr/bin
diff options
context:
space:
mode:
authorManuel Munz <freifunk@somakoma.de>2013-01-12 19:30:45 +0000
committerManuel Munz <freifunk@somakoma.de>2013-01-12 19:30:45 +0000
commita951a5991d46d069cd2440ac837e63f26368515b (patch)
tree31d0257f2ba722735f862ab0fc139f41af59111a /contrib/package/meshwizard/files/usr/bin
parentbaba6d3dee6c80ba48b404cfc7610bd274242189 (diff)
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
Diffstat (limited to 'contrib/package/meshwizard/files/usr/bin')
-rwxr-xr-xcontrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_wifi.sh12
-rwxr-xr-xcontrib/package/meshwizard/files/usr/bin/meshwizard/helpers/supports_vap.sh35
2 files changed, 37 insertions, 10 deletions
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 001754c12f..9d1bce3e6c 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 0000000000..045ea976e0
--- /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
+
+