Code sync
[external/avahi.git] / debian / avahi-daemon.init_bak
1 #!/bin/sh
2 ### BEGIN INIT INFO
3 # Provides:          avahi
4 # Required-Start:    $remote_fs dbus
5 # Required-Stop:     $remote_fs dbus
6 # Should-Start:      $syslog
7 # Should-Stop:       $syslog
8 # Default-Start:     2 3 4 5
9 # Default-Stop:      0 1 6
10 # Short-Description: Avahi mDNS/DNS-SD Daemon
11 # Description:       Zeroconf daemon for configuring your network 
12 #                    automatically
13 ### END INIT INFO
14
15 PATH=/sbin:/bin:/usr/sbin:/usr/bin
16 DESC="Avahi mDNS/DNS-SD Daemon"
17 NAME="avahi-daemon"
18 DAEMON="/usr/sbin/$NAME"
19 SCRIPTNAME=/etc/init.d/$NAME
20
21 # Gracefully exit if the package has been removed.
22 test -x $DAEMON || exit 0
23
24 . /lib/lsb/init-functions
25
26 # Include avahi-daemon defaults if available.
27 test -f /etc/default/avahi-daemon && . /etc/default/avahi-daemon
28
29 DISABLE_TAG="/var/run/avahi-daemon/disabled-for-unicast-local"
30
31 #
32 #       Function that starts the daemon/service.
33 #
34 d_start() {
35     $DAEMON -c && return 0
36
37     if [ -e $DISABLE_TAG -a "$AVAHI_DAEMON_DETECT_LOCAL" != "0" ]; then
38         # Disabled because of the existance of an unicast .local domain
39         log_warning_msg "avahi-daemon disabled because there is a unicast .local domain"
40         exit 0;
41     fi;
42
43     $DAEMON -D
44 }
45
46 #
47 #       Function that stops the daemon/service.
48 #
49 d_stop() {
50     if $DAEMON -c ; then
51        $DAEMON -k
52     fi
53 }
54
55 #
56 #       Function that reload the config file for the daemon/service.
57 #
58 d_reload() {
59     $DAEMON -c && $DAEMON -r
60 }
61
62 #
63 #       Function that check the status of the daemon/service.
64 #
65 d_status() {
66     $DAEMON -c && echo "$DESC is running" || echo "$DESC is not running"
67 }
68
69 case "$1" in
70     start)
71         log_daemon_msg "Starting $DESC" "$NAME"
72         d_start
73         log_end_msg $?
74         ;;
75     stop)
76         log_daemon_msg "Stopping $DESC" "$NAME"
77         d_stop
78         log_end_msg $?
79         ;;
80     reload|force-reload)
81         log_daemon_msg "Reloading services for $DESC" "$NAME"
82         d_reload
83         log_end_msg $?
84         ;;
85     restart)
86         log_daemon_msg "Restarting $DESC" "$NAME"
87         d_stop
88         d_start
89         log_end_msg $?
90         ;;
91     status)
92         d_status
93         ;;
94     *)
95         echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|reload}" >&2
96         exit 1
97         ;;
98 esac
99
100 exit 0