source: debwrt/trunk/debian/package/hostapd/debian/hostapd.init @ 189

Last change on this file since 189 was 189, checked in by stappers, 8 years ago

Start hostapd before networking

The host acces point daemon should be started before networking.

Reported-by: e.d.grootjans in ticket #79

File size: 1.9 KB
Line 
1#!/bin/sh
2
3### BEGIN INIT INFO
4# Provides:             hostapd
5# Required-Start:
6# Required-Stop:
7# Should-Start:         $local_fs
8# Should-Stop:          $local_fs
9# Default-Start:        S
10# Default-Stop:         0 6
11# X-Start-Before:       $network
12# X-Stop-After:         $network
13# Short-Description:    Advanced IEEE 802.11 management daemon
14# Description:          Userspace IEEE 802.11 AP and IEEE 802.1X/WPA/WPA2/EAP
15#                       Authenticator
16### END INIT INFO
17
18PATH=/sbin:/bin:/usr/sbin:/usr/bin
19DAEMON=/usr/sbin/hostapd
20NAME=hostapd
21DESC="advanced IEEE 802.11 management"
22PIDFILE=/var/run/hostapd.pid
23
24test -x $DAEMON || exit 0
25
26if [ -s /etc/default/hostapd ] ; then
27        . /etc/default/hostapd
28fi
29
30if [ -z "$DAEMON_CONF" ]; then
31        DAEMON_CONF=/etc/hostapd/hostapd-wpa.conf
32fi
33
34DAEMON_OPTS="-B -P $PIDFILE $DAEMON_OPTS $DAEMON_CONF"
35
36. /lib/lsb/init-functions
37
38check() {
39        # exit if the kernel version is not 2.6
40        KVER=$(uname -r)
41        KMAJ=${KVER%${KVER#*.*[^.]}}
42        KMAJ=${KMAJ%.}
43        if [ "$KMAJ" != "2.6" ]; then
44                echo
45                log_warning_msg "needs kernel 2.6 - no configuration possible";
46                log_end_msg 0
47                exit 0
48        fi
49
50        if ! ( cat /proc/net/dev | grep wlan0: >/dev/null 2>&1 ); then
51                echo; log_warning_msg "b43 wlan0 interface not found - no configuration possible"
52                log_action_end_msg 0;
53                exit 0;
54        fi
55}
56
57case "$1" in
58  start)
59        log_daemon_msg "Starting $DESC"
60        log_progress_msg "$NAME"
61        check
62        if [ "$RUN_DAEMON" != "yes" ]; then
63                log_progress_msg "disabled via /etc/default/hostapd"
64                log_end_msg 0
65                exit 0
66        fi
67        start-stop-daemon --start --oknodo --quiet \
68                --exec $DAEMON --pidfile $PIDFILE -- $DAEMON_OPTS > /dev/null
69        log_end_msg "$?"
70        ;;
71  stop)
72        log_daemon_msg "Stopping $DESC"
73        log_progress_msg "$NAME"
74        check
75        start-stop-daemon --stop --oknodo --quiet \
76                --exec $DAEMON --pidfile $PIDFILE
77        log_end_msg "$?"
78        ;;
79  *)
80        N=/etc/init.d/$NAME
81        echo "Usage: $N {start|stop}" >&2
82        exit 1
83        ;;
84esac
85
86exit 0
Note: See TracBrowser for help on using the repository browser.