summaryrefslogtreecommitdiff
path: root/network/hostapd/rc.hostapd
blob: c034284b8aeeb3e4b77a90844f06a204ee56eee8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/sh

# Start/stop/restart the hostapd (IEEE 802.11 Wireless AP) server:

hostapd_start() {
  if test -r /var/run/hostapd.pid && ps $(cat /var/run/hostapd.pid) >& /dev/null; then
    echo "HOSTAPD already running!"
  else
    CMD="/usr/sbin/hostapd -B -P /var/run/hostapd.pid /etc/hostapd/hostapd.conf"
    echo "Starting HOSTAPD:  $CMD"
    $CMD
  fi
}

hostapd_stop() {
  if [ -r /var/run/hostapd.pid ]; then
    echo -n "Stopping HOSTAPD ..."
    kill -INT $(cat /var/run/hostapd.pid)
    echo " done."
  fi
}

hostapd_restart() {
  hostapd_stop
  sleep 3
  hostapd_start
}

case "$1" in
'start')
  hostapd_start
  ;;
'stop')
  hostapd_stop
  ;;
'restart')
  hostapd_restart
  ;;
*)
  echo "usage $0 start|stop|restart"
esac