]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - src/initscripts/init.d/hostapd
Change Hostapd restart not leave master mode.
[people/teissler/ipfire-2.x.git] / src / initscripts / init.d / hostapd
1 #!/bin/sh
2 . /etc/sysconfig/rc
3 . ${rc_functions}
4
5 CHANNEL="05"
6 TXPOWER="auto"
7 INTERFACE="blue0"
8 eval $(/usr/local/bin/readhash /var/ipfire/wlanap/settings)
9
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
17 # Set Atheros Cards to master mode
18 if [ -d /proc/net/madwifi/ath0/ ]; then
19 /usr/bin/wlanconfig ath0 destroy > /dev/null
20 fi
21 /usr/bin/wlanconfig $INTERFACE destroy > /dev/null
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
33 /usr/sbin/iwconfig $INTERFACE txpower $TXPOWER
34 /usr/bin/hostapd -P /var/run/hostapd /etc/hostapd.conf </dev/tty12 >/dev/tty12 2>&1 &
35 evaluate_retval
36 fi
37
38 # Bring blue up (but not at boot)
39 if [ "$(basename $0)" == "hostapd" ]; then
40
41 /etc/rc.d/init.d/networking/${INTERFACE//[0-9]/} start
42
43 if [ -f /var/ipfire/dhcp/enable_${INTERFACE//[0-9]/} ]; then
44 /etc/rc.d/init.d/dhcp restart
45 fi
46 fi
47 ;;
48
49 stop)
50 boot_mesg "Stopping hostapd..."
51
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
55
56 # Set other cards to managed mode
57 #/usr/sbin/iwconfig blue0 mode Managed
58
59 killproc /usr/bin/hostapd
60 evaluate_retval
61 ;;
62
63 restart)
64 boot_mesg "Stopping hostapd..."
65 killproc /usr/bin/hostapd
66 evaluate_retval
67
68 sleep 1
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
82 ;;
83
84 status)
85 statusproc /usr/bin/hostapd
86 ;;
87
88 *)
89 echo "Usage: ${0} {start|stop|restart|status}"
90 exit 1
91 ;;
92 esac