]>
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 AF |
17 | # Set Atheros Cards to master mode |
18 | /usr/bin/wlanconfig $INTERFACE destroy > /dev/null | |
54359730 CS |
19 | /usr/bin/wlanconfig $INTERFACE create wlandev wifi0 wlanmode ap > /dev/null |
20 | ||
21 | # Set other cards to master mode | |
22 | #/usr/sbin/iwconfig blue0 mode master | |
23 | ||
24 | if [ "$(/usr/sbin/iwconfig $INTERFACE | /bin/grep "Mode:Master")" == "" ]; then | |
25 | boot_mesg "Error! Can't set wlan master mode" | |
26 | echo_failure; | |
27 | exit 1; | |
28 | else | |
29 | /usr/sbin/iwconfig $INTERFACE channel $CHANNEL | |
b9694349 | 30 | /usr/sbin/iwconfig $INTERFACE txpower $TXPOWER |
54359730 CS |
31 | /usr/bin/hostapd -P /var/run/hostapd /etc/hostapd.conf </dev/tty12 >/dev/tty12 2>&1 & |
32 | evaluate_retval | |
33 | fi | |
643fb017 AF |
34 | |
35 | # Bring blue up (but not at boot) | |
36 | if [ "$(basename $0)" == "hostapd" ]; then | |
c2cd9391 CS |
37 | |
38 | if [ "$(INTERFACE)" == "blue0" ]; then | |
39 | /etc/rc.d/init.d/networking/blue start | |
40 | elif [ "$(INTERFACE)" == "green0" ]; then | |
41 | /etc/rc.d/init.d/networking/green start | |
42 | fi | |
43 | ||
6d15ec66 | 44 | if [ -f /var/ipfire/dhcp/enable_blue || -f /var/ipfire/dhcp/enable_green ]; then |
c2cd9391 CS |
45 | /etc/rc.d/init.d/dhcp restart |
46 | fi | |
643fb017 | 47 | fi |
c2cd9391 | 48 | ;; |
54359730 CS |
49 | |
50 | stop) | |
51 | boot_mesg "Stopping hostapd..." | |
52 | ||
643fb017 AF |
53 | # Set Atheros Card to managed mode |
54 | /usr/bin/wlanconfig $INTERFACE destroy > /dev/null | |
55 | /usr/bin/wlanconfig $INTERFACE create wlandev wifi0 wlanmode sta > /dev/null | |
54359730 | 56 | |
643fb017 | 57 | # Set other cards to managed mode |
54359730 CS |
58 | #/usr/sbin/iwconfig blue0 mode Managed |
59 | ||
60 | killproc /usr/bin/hostapd | |
61 | evaluate_retval | |
62 | ;; | |
63 | ||
64 | restart) | |
65 | ${0} stop | |
66 | sleep 1 | |
67 | ${0} start | |
68 | ;; | |
69 | ||
70 | status) | |
71 | statusproc /usr/bin/hostapd | |
72 | ;; | |
73 | ||
74 | *) | |
75 | echo "Usage: ${0} {start|stop|restart|status}" | |
76 | exit 1 | |
77 | ;; | |
78 | esac |