]>
Commit | Line | Data |
---|---|---|
956463fe | 1 | #!/bin/sh |
2 | # | |
3 | # hostapd This script is used to start and stop hostapd service | |
4 | # | |
5 | # chkconfig: 345 83 17 | |
6 | # | |
7 | # description: hostapd is a deamon to run wlan card based on prism2 | |
8 | # chip as Access Point. | |
9 | # | |
10 | # Author: Pawel Bernadowski "pbern" <kontakt@pbern.biz> | |
11 | ||
12 | ||
13 | # Source function library | |
14 | . /etc/rc.d/init.d/functions | |
15 | ||
16 | # Get network config | |
17 | . /etc/sysconfig/network | |
18 | ||
19 | # Check that networkin is up | |
20 | if is_yes "${NETWORKING}"; then | |
21 | if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then | |
22 | msg_network_down hostapd | |
23 | exit 1 | |
24 | fi | |
25 | else | |
26 | exit 0 | |
27 | fi | |
28 | ||
29 | RETVAL=0 | |
30 | # See how we were called. | |
31 | case "$1" in | |
971ea60e | 32 | start) |
956463fe | 33 | # Check if the service is already running? |
34 | if [ ! -f /var/lock/subsys/hostapd ]; then | |
971ea60e | 35 | msg_starting hostapd |
956463fe | 36 | daemon /sbin/hostapd /etc/hostap/hostapd.conf -B |
37 | RETVAL=$? | |
38 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/hostapd | |
39 | else | |
40 | msg_already_running hostapd | |
41 | fi | |
42 | ;; | |
43 | stop) | |
44 | if [ -f /var/lock/subsys/hostapd ]; then | |
45 | # Stop daemon | |
46 | msg_stopping hostapd | |
47 | killproc hostapd | |
48 | rm -f /var/lock/subsys/hostapd >/dev/null 2>&1 | |
49 | else | |
50 | msg_not_running hostapd | |
51 | fi | |
52 | ;; | |
53 | restart|force-reload) | |
54 | $0 stop | |
55 | $0 start | |
56 | exit $? | |
57 | ;; | |
58 | status) | |
59 | status hostapd | |
60 | exit $? | |
61 | ;; | |
62 | *) | |
63 | msg_usage "$0 {start|stop|restart|force-reload|status}" | |
64 | exit 3 | |
65 | esac | |
66 | ||
67 | exit $RETVAL |