]> git.ipfire.org Git - ipfire-2.x.git/blob - src/initscripts/init.d/hostapd
dhcpd has also restarted at hostapd start
[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 /usr/bin/wlanconfig $INTERFACE destroy > /dev/null
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
30 /usr/sbin/iwconfig $INTERFACE txpower $TXPOWER
31 /usr/bin/hostapd -P /var/run/hostapd /etc/hostapd.conf </dev/tty12 >/dev/tty12 2>&1 &
32 evaluate_retval
33 fi
34
35 # Bring blue up (but not at boot)
36 if [ "$(basename $0)" == "hostapd" ]; then
37 /etc/rc.d/init.d/networking/blue start
38 /etc/rc.d/init.d/dhcp restart
39 fi
40 ;;
41
42 stop)
43 boot_mesg "Stopping hostapd..."
44
45 # Set Atheros Card to managed mode
46 /usr/bin/wlanconfig $INTERFACE destroy > /dev/null
47 /usr/bin/wlanconfig $INTERFACE create wlandev wifi0 wlanmode sta > /dev/null
48
49 # Set other cards to managed mode
50 #/usr/sbin/iwconfig blue0 mode Managed
51
52 killproc /usr/bin/hostapd
53 evaluate_retval
54 ;;
55
56 restart)
57 ${0} stop
58 sleep 1
59 ${0} start
60 ;;
61
62 status)
63 statusproc /usr/bin/hostapd
64 ;;
65
66 *)
67 echo "Usage: ${0} {start|stop|restart|status}"
68 exit 1
69 ;;
70 esac