summaryrefslogtreecommitdiff
path: root/package/base-files/src
diff options
context:
space:
mode:
authorWaldemar Brodkorb <wbx@openadk.org>2010-02-13 13:58:07 +0100
committerWaldemar Brodkorb <wbx@openadk.org>2010-02-13 13:58:07 +0100
commit011eae436ef9c42ffeae570d10964ab1265c081d (patch)
treec04e93dcf1c61874ea7fcf36dcc1ee605ff3ce14 /package/base-files/src
parentf513a8a7eb9fd3ec28bfcb773ace28d49b61c0e7 (diff)
add support for wireless access point with p54usb stick
Diffstat (limited to 'package/base-files/src')
-rwxr-xr-xpackage/base-files/src/etc/network/if-post-down.d/03-wireless15
-rwxr-xr-xpackage/base-files/src/etc/network/if-pre-up.d/04-wireless86
2 files changed, 101 insertions, 0 deletions
diff --git a/package/base-files/src/etc/network/if-post-down.d/03-wireless b/package/base-files/src/etc/network/if-post-down.d/03-wireless
new file mode 100755
index 000000000..66e92639b
--- /dev/null
+++ b/package/base-files/src/etc/network/if-post-down.d/03-wireless
@@ -0,0 +1,15 @@
+#!/bin/sh
+set -e
+
+[ "${IFACE%%[0-9]*}" = "wlan" ] || exit 0
+
+case "$IF_WIRELESS_MODE" in
+ ap)
+ logger -t hostap "Killing hostapd"
+ pkill hostapd
+ ;;
+ *)
+ exit 0
+ ;;
+esac
+exit 0
diff --git a/package/base-files/src/etc/network/if-pre-up.d/04-wireless b/package/base-files/src/etc/network/if-pre-up.d/04-wireless
new file mode 100755
index 000000000..54864ba78
--- /dev/null
+++ b/package/base-files/src/etc/network/if-pre-up.d/04-wireless
@@ -0,0 +1,86 @@
+#!/bin/sh
+#set -x
+set -e
+
+[ -x /usr/sbin/iw ] || exit 0
+
+[ "${IFACE%%[0-9]*}" = "wlan" ] || exit 0
+
+[ "$IF_WIRELESS_SSID" ] || exit 1
+[ "$IF_WIRELESS_CHANNEL" ] || exit 1
+[ "$IF_WIRELESS_HWMODE" ] || IF_WIRELESS_HWMODE=g
+
+wpa=0
+wpa1=0
+wpa2=0
+
+case "$IF_WIRELESS_SECURITY" in
+ none)
+ sec=1
+ ;;
+ wep)
+ sec=2
+ ;;
+ wpa)
+ sec=1
+ wpa1=1
+ ;;
+ wpa2)
+ sec=1
+ wpa2=1
+ ;;
+ wpa+wpa2)
+ sec=1
+ wpa=1
+ ;;
+ *)
+ sec=1
+ ;;
+esac
+
+case "$IF_WIRELESS_MODE" in
+ ap)
+ [ -x /usr/sbin/hostapd ] || {
+ logger -t hostap "No hostapd program found"
+ exit 1
+ }
+ logger -t hostap "Creating hostapd configuration"
+ cat /etc/hostapd.conf > /tmp/hostapd.conf
+ chmod 600 /tmp/hostapd.conf
+ echo "interface=${IFACE}" >> /tmp/hostapd.conf
+ echo "ssid=$IF_WIRELESS_SSID" >> /tmp/hostapd.conf
+ echo "channel=$IF_WIRELESS_CHANNEL" >> /tmp/hostapd.conf
+ echo "hw_mode=$IF_WIRELESS_HWMODE" >> /tmp/hostapd.conf
+ echo "auth_algs=$sec" >> /tmp/hostapd.conf
+ [ $wpa1 -eq 1 ] && {
+ logger -t hostap "using WPA for security"
+ echo "wpa=1" >> /tmp/hostapd.conf
+ echo "wpa_key_mgmt=WPA-PSK" >> /tmp/hostapd.conf
+ echo "wpa_pairwise=TKIP" >> /tmp/hostapd.conf
+ echo "wpa_passphrase=$IF_WIRELESS_PASSPHRASE" >> /tmp/hostapd.conf
+ }
+ [ $wpa2 -eq 1 ] && {
+ logger -t hostap "using WPA2 for security"
+ echo "wpa=2" >> /tmp/hostapd.conf
+ echo "wpa_key_mgmt=WPA-PSK" >> /tmp/hostapd.conf
+ echo "rsn_pairwise=CCMP" >> /tmp/hostapd.conf
+ echo "wpa_passphrase=$IF_WIRELESS_PASSPHRASE" >> /tmp/hostapd.conf
+ }
+ [ $wpa -eq 1 ] && {
+ logger -t hostap "using WPA and WPA2 for security"
+ echo "wpa=3" >> /tmp/hostapd.conf
+ echo "wpa_key_mgmt=WPA-PSK" >> /tmp/hostapd.conf
+ echo "wpa_pairwise=TKIP" >> /tmp/hostapd.conf
+ echo "rsn_pairwise=CCMP" >> /tmp/hostapd.conf
+ echo "wpa_passphrase=$IF_WIRELESS_PASSPHRASE" >> /tmp/hostapd.conf
+ }
+ logger -t hostap "Starting hostapd"
+ hostapd -B /tmp/hostapd.conf
+ ;;
+ *)
+ echo "Unknown operation mode $IF_WIRELESS_MODE given!"
+ exit 1
+ ;;
+esac
+
+exit 0