]>
Commit | Line | Data |
---|---|---|
07603508 CS |
1 | #!/bin/sh |
2 | . /etc/sysconfig/rc | |
3 | . ${rc_functions} | |
4 | ||
54359730 CS |
5 | CHANNEL="05" |
6 | TXPOWER="auto" | |
7 | INTERFACE="blue0" | |
b9694349 | 8 | eval $(/usr/local/bin/readhash /var/ipfire/wlanap/settings) |
54359730 | 9 | |
54359730 CS |
10 | case "${1}" in |
11 | start) | |
12 | boot_mesg "Starting hostapd... " | |
13 | mkdir -p /var/run/hostapd | |
14 | # enable wlan module of collectd | |
15 | sed -i -e "s|#LoadPlugin wireless|LoadPlugin wireless|g" /etc/collectd.conf | |
16 | ||
643fb017 | 17 | # Set Atheros Cards to master mode |
43adf098 CS |
18 | if [ -d /proc/net/madwifi/ath0/ ]; then |
19 | /usr/bin/wlanconfig ath0 destroy > /dev/null | |
20 | fi | |
643fb017 | 21 | /usr/bin/wlanconfig $INTERFACE destroy > /dev/null |
54359730 CS |
22 | /usr/bin/wlanconfig $INTERFACE create wlandev wifi0 wlanmode ap > /dev/null |
23 | ||
24 | # Set other cards to master mode | |
25 | #/usr/sbin/iwconfig blue0 mode master | |
26 | ||
27 | if [ "$(/usr/sbin/iwconfig $INTERFACE | /bin/grep "Mode:Master")" == "" ]; then | |
28 | boot_mesg "Error! Can't set wlan master mode" | |
29 | echo_failure; | |
30 | exit 1; | |
31 | else | |
32 | /usr/sbin/iwconfig $INTERFACE channel $CHANNEL | |
b9694349 | 33 | /usr/sbin/iwconfig $INTERFACE txpower $TXPOWER |
54359730 CS |
34 | /usr/bin/hostapd -P /var/run/hostapd /etc/hostapd.conf </dev/tty12 >/dev/tty12 2>&1 & |
35 | evaluate_retval | |
36 | fi | |
643fb017 AF |
37 | |
38 | # Bring blue up (but not at boot) | |
39 | if [ "$(basename $0)" == "hostapd" ]; then | |
c2cd9391 | 40 | |
9fce0ca5 | 41 | /etc/rc.d/init.d/networking/${INTERFACE//[0-9]/} start |
c2cd9391 | 42 | |
10ada56e | 43 | if [ -f /var/ipfire/dhcp/enable_${INTERFACE//[0-9]/} ]; then |
c2cd9391 CS |
44 | /etc/rc.d/init.d/dhcp restart |
45 | fi | |
643fb017 | 46 | fi |
c2cd9391 | 47 | ;; |
54359730 CS |
48 | |
49 | stop) | |
50 | boot_mesg "Stopping hostapd..." | |
51 | ||
643fb017 AF |
52 | # Set Atheros Card to managed mode |
53 | /usr/bin/wlanconfig $INTERFACE destroy > /dev/null | |
54 | /usr/bin/wlanconfig $INTERFACE create wlandev wifi0 wlanmode sta > /dev/null | |
54359730 | 55 | |
643fb017 | 56 | # Set other cards to managed mode |
54359730 CS |
57 | #/usr/sbin/iwconfig blue0 mode Managed |
58 | ||
59 | killproc /usr/bin/hostapd | |
60 | evaluate_retval | |
61 | ;; | |
62 | ||
63 | restart) | |
64 | ${0} stop | |
65 | sleep 1 | |
66 | ${0} start | |
67 | ;; | |
68 | ||
69 | status) | |
70 | statusproc /usr/bin/hostapd | |
71 | ;; | |
72 | ||
73 | *) | |
74 | echo "Usage: ${0} {start|stop|restart|status}" | |
75 | exit 1 | |
76 | ;; | |
77 | esac |