Add NL80211 driver config to wlanap.cgi
[people/pmueller/ipfire-2.x.git] / src / initscripts / init.d / hostapd
CommitLineData
07603508
CS
1#!/bin/sh
2. /etc/sysconfig/rc
3. ${rc_functions}
4
54359730
CS
5CHANNEL="05"
6TXPOWER="auto"
7INTERFACE="blue0"
79ef49bd
AF
8MACMODE="0"
9DRIVER="MADWIFI"
10
b9694349 11eval $(/usr/local/bin/readhash /var/ipfire/wlanap/settings)
54359730 12
54359730 13case "${1}" in
8aa49c15 14 start)
54359730 15 mkdir -p /var/run/hostapd
54359730 16
79ef49bd
AF
17 if [ "$DRIVER" == "MADWIFI" ]; then
18 if [ "$(/usr/sbin/iwconfig $INTERFACE | /bin/grep "Mode:Master")" == "" ]; then
19 boot_mesg "Setting MADWIFI wlan $INTERFACE to Master mode... "
20 # Set Atheros Cards to master mode
21 /usr/bin/wlanconfig $INTERFACE destroy > /dev/null
22 /usr/bin/wlanconfig $INTERFACE create wlandev wifi0 wlanmode ap > /dev/null
23 fi
8aa49c15 24 fi
54359730 25
79ef49bd
AF
26 boot_mesg "Starting hostapd... "
27 /usr/sbin/iwconfig $INTERFACE channel $CHANNEL
28 /usr/sbin/iwconfig $INTERFACE txpower $TXPOWER
29 /usr/bin/hostapd -P /var/run/hostapd /etc/hostapd.conf </dev/tty12 >/dev/tty12 2>&1 &
30
31 if [ $DRIVER == "MADWIFI" ]; then
32
33 iwpriv $INTERFACE maccmd 3
34 if [ $MACMODE != 0 ]; then
35 FILE="/var/ipfire/wlanap/macfile"
36 exec < $FILE
37 while read LINE
38 do
39 iwpriv $INTERFACE addmac $LINE
40 done
54359730 41
79ef49bd
AF
42 iwpriv $INTERFACE maccmd $MACMODE
43 fi
44 # Disable background scann
45 iwpriv $INTERFACE bgscan 0
46 # Set beacon interval to 500
47 iwpriv $INTERFACE bintval 500
a494df6d 48 fi
8aa49c15 49
54359730 50 if [ "$(/usr/sbin/iwconfig $INTERFACE | /bin/grep "Mode:Master")" == "" ]; then
8aa49c15
CS
51 boot_mesg "Error! Can't set wlan master mode"
52 echo_failure;
79ef49bd 53 exit 0;
54359730 54 else
8aa49c15
CS
55 # enable wlan module of collectd
56 sed -i -e "s|#LoadPlugin wireless|LoadPlugin wireless|g" /etc/collectd.conf
79ef49bd 57 echo_ok
54359730 58 fi
8aa49c15 59 ;;
54359730 60
8aa49c15 61 stop)
54359730
CS
62 boot_mesg "Stopping hostapd..."
63
8aa49c15
CS
64 killproc /usr/bin/hostapd
65 evaluate_retval
66 ;;
54359730 67
8aa49c15
CS
68 restart)
69 ${0} stop
70 sleep 1
71 ${0} start
72 ;;
54359730 73
8aa49c15
CS
74 status)
75 statusproc /usr/bin/hostapd
76 ;;
54359730 77
8aa49c15
CS
78 *)
79 echo "Usage: ${0} {start|stop|restart|status}"
80 exit 1
81 ;;
54359730 82esac