]>
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 | |
11623101 | 22 | msg_network_down "Host APd" |
956463fe | 23 | exit 1 |
24 | fi | |
25 | else | |
26 | exit 0 | |
27 | fi | |
28 | ||
11623101 ER |
29 | start() { |
30 | # Check if the service is already running? | |
31 | if [ -f /var/lock/subsys/hostapd ]; then | |
32 | msg_already_running "Host APd" | |
33 | return | |
34 | fi | |
35 | ||
36 | msg_starting "Host APd" | |
37 | daemon /sbin/hostapd /etc/hostap/hostapd.conf -B | |
38 | RETVAL=$? | |
39 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/hostapd | |
40 | } | |
41 | ||
42 | stop() { | |
43 | if [ ! -f /var/lock/subsys/hostapd ]; then | |
44 | msg_not_running "Host APd" | |
45 | return | |
46 | fi | |
47 | ||
48 | # Stop daemon | |
49 | msg_stopping "Host APd" | |
50 | killproc hostapd | |
51 | rm -f /var/lock/subsys/hostapd >/dev/null 2>&1 | |
52 | } | |
53 | ||
54 | condrestart() { | |
55 | if [ ! -f /var/lock/subsys/hostapd ]; then | |
56 | msg_not_running "Host APd" | |
57 | RETVAL=$1 | |
58 | return | |
59 | fi | |
60 | ||
61 | stop | |
62 | start | |
63 | } | |
64 | ||
956463fe | 65 | RETVAL=0 |
66 | # See how we were called. | |
67 | case "$1" in | |
971ea60e | 68 | start) |
11623101 | 69 | start |
956463fe | 70 | ;; |
71 | stop) | |
11623101 | 72 | stop |
956463fe | 73 | ;; |
11623101 ER |
74 | restart) |
75 | stop | |
76 | start | |
77 | ;; | |
78 | try-restart) | |
79 | condrestart 0 | |
80 | ;; | |
81 | force-reload) | |
82 | condrestart 7 | |
956463fe | 83 | ;; |
84 | status) | |
85 | status hostapd | |
86 | exit $? | |
87 | ;; | |
88 | *) | |
11623101 | 89 | msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}" |
956463fe | 90 | exit 3 |
91 | esac | |
92 | ||
93 | exit $RETVAL |