blob: 8ba4e079406c5836f67a8c11b6dfbedfbce5e818 [file] [log] [blame]
Patrick Williamsb48b7b42016-08-17 15:04:38 -05001#!/bin/sh
2DAEMON=/usr/sbin/hostapd
3NAME=hostapd
4DESC="HOSTAP Daemon"
5ARGS="/etc/hostapd.conf -B"
6
7test -f $DAEMON || exit 0
8
9set -e
10
11# source function library
12. /etc/init.d/functions
13
14delay_stop() {
15 count=0
16 while [ $count -lt 9 ] ; do
17 if pidof $DAEMON >/dev/null; then
18 sleep 1
19 else
20 return 0
21 fi
22 count=`expr $count + 1`
23 done
24 echo "Failed to stop $DESC."
25 return 1
26}
27
28case "$1" in
29 start)
30 echo -n "Starting $DESC: "
31 start-stop-daemon -S -x $DAEMON -- $ARGS
32 echo "$NAME."
33 ;;
34 stop)
35 echo -n "Stopping $DESC: "
36 start-stop-daemon -K --oknodo -x $DAEMON
37 echo "$NAME."
38 ;;
39 restart)
40 $0 stop
41 delay_stop && $0 start
42 ;;
43 reload)
44 echo -n "Reloading $DESC: "
45 killall -HUP $(basename ${DAEMON})
46 echo "$NAME."
47 ;;
48 status)
49 status $DAEMON
50 exit $?
51 ;;
52 *)
53 echo "Usage: $0 {start|stop|restart|reload|status}"
54 exit 1
55 ;;
56esac
57
58exit 0