]> git.meshlink.io Git - catta/blob - initscript/Debian/15avahi.in
Add patches from Sebastien Estienne
[catta] / initscript / Debian / 15avahi.in
1 #! /bin/sh
2 #
3 # avahi     avahi daemon
4 #                               Daemon for ZeroConf
5 #
6 # Authors:      <sebastien.estienne@gmail.com>
7 #
8
9 . /lib/lsb/init-functions
10
11 set -e
12
13 PATH=/sbin:/bin:/usr/sbin:/usr/bin
14 DESC="Avahi ZeroConf daemon"
15 NAME="avahi"
16 DAEMON=/usr/bin/$NAME
17 PIDDIR=/var/run/$NAME
18 PIDFILE=$PIDDIR/$NAME.pid
19 DAEMONUSER=@AVAHI_USER@
20 DAEMONGRP=@AVAHI_GROUP@
21
22
23
24 # Gracefully exit if the package has been removed.
25 test -x $DAEMON || exit 0
26
27 #
28 #       Function that starts the daemon/service.
29 #
30 d_start() {
31   if [ ! -d $PIDDIR ]; then
32     mkdir -p $PIDDIR
33   fi
34   chown -R $DAEMONUSER:$DAEMONGRP $PIDDIR
35
36         start-stop-daemon --start \
37             --background --chuid $DAEMONUSER \
38             -m --pidfile $PIDFILE \
39             --exec $DAEMON -- $DAEMON_OPTS
40
41 }
42
43 #
44 #       Function that stops the daemon/service.
45 #
46 d_stop() {
47         start-stop-daemon --stop --oknodo --quiet --pidfile $PIDFILE \
48                 --exec $DAEMON
49
50 }
51
52
53 case "$1" in
54   start)
55         log_begin_msg "Starting $DESC: $NAME"
56         d_start
57         log_end_msg $?
58         ;;
59   stop)
60         log_begin_msg "Stopping $DESC: $NAME"
61         d_stop
62         log_end_msg $?
63         ;;
64   restart|force-reload)
65         log_begin_msg "Restarting $DESC: $NAME"
66         d_stop
67         sleep 1
68         d_start
69         log_end_msg $?
70         ;;
71   *)
72         echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
73         exit 1
74         ;;
75 esac
76
77 exit 0