]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blame - src/initscripts/init.d/hostapd
Change Hostapd restart not leave master mode.
[people/teissler/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"
b9694349 8eval $(/usr/local/bin/readhash /var/ipfire/wlanap/settings)
54359730 9
54359730
CS
10case "${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)
7e9a31f2
AF
64 boot_mesg "Stopping hostapd..."
65 killproc /usr/bin/hostapd
66 evaluate_retval
67
54359730 68 sleep 1
7e9a31f2
AF
69
70 boot_mesg "Starting hostapd... "
71 if [ "$(/usr/sbin/iwconfig $INTERFACE | /bin/grep "Mode:Master")" == "" ]; then
72 boot_mesg "Error! Card is not master"
73 echo_failure;
74 exit 1;
75 else
76 /usr/sbin/iwconfig $INTERFACE channel $CHANNEL
77 /usr/sbin/iwconfig $INTERFACE txpower $TXPOWER
78 /usr/bin/hostapd -P /var/run/hostapd /etc/hostapd.conf </dev/tty12 >/dev/tty12 2>&1 &
79 evaluate_retval
80 fi
81
54359730
CS
82 ;;
83
84 status)
85 statusproc /usr/bin/hostapd
86 ;;
87
88 *)
89 echo "Usage: ${0} {start|stop|restart|status}"
90 exit 1
91 ;;
92esac