]> git.meshlink.io Git - catta/blob - initscript/fedora/avahi-daemon.in
5a8f43005888c597ae5fe446a5de7c0855dd4edf
[catta] / initscript / fedora / avahi-daemon.in
1 #!/bin/sh
2 #
3 # avahi-daemon: Starts the Avahi mDNS/DNS-SD Stack
4 #
5 # chkconfig:   345 24 02
6 # description: This is a daemon which runs on client machines to \
7 #              perform Zeroconf service discovery on a \
8 #              network. avahi-daemon must be running on systems that \
9 #              use Avahi for service discovery. Avahi-daemon should \
10 #              not be running otherwise.
11 # processname: avahi-daemon
12 # pidfile:     @localstatedir@/run/avahi-daemon/pid
13
14 ### BEGIN INIT INFO
15 # Required-Start:    messagebus
16 # Required-Stop:     messagebus
17 # Should-Start:      $syslog $network $local_fs
18 # Should-Stop:       $syslog $local_fs
19 # Default-Start:     3 4 5
20 # Default-Stop:      0 1 2 6
21 # Short-Description: Starts the Avahi Daemon
22 # Description:       This is a daemon which runs on client machines to
23 #                    perform Zeroconf service discovery on a
24 #                    network. avahi-daemon must be running on systems
25 #                    that use Avahi for service discovery.
26 #                    Avahi-daemon should not be running otherwise.
27 ### END INIT INFO
28
29 AVAHI_BIN=@sbindir@/avahi-daemon
30 AVAHI_OPTS="-D"
31
32 if [ "$1" = 'status' ]; then
33     test -x $AVAHI_BIN || exit 4
34 else
35     test -x $AVAHI_BIN || exit 5
36 fi
37
38 # Source function library.
39 . /etc/init.d/functions
40 . /etc/sysconfig/network
41
42 LOCKFILE=@localstatedir@/lock/subsys/avahi-daemon
43 PIDFILE=@localstatedir@/run/avahi-daemon/pid
44 RETVAL=0
45
46 base=${0##*/}
47
48 start() {
49     # Check that networking is configured.
50     [ ${NETWORKING} = "no" ] && exit 1
51
52         echo -n $"Starting Avahi daemon... "
53         if [ -s /etc/localtime ]; then
54             cp -fp /etc/localtime /etc/avahi/etc >/dev/null 2>&1
55         fi;
56         daemon --pidfile=${PIDFILE} $AVAHI_BIN $AVAHI_OPTS
57         RETVAL=$?
58         echo
59         [ $RETVAL -eq 0 ] && touch ${LOCKFILE}
60         return $RETVAL
61 }
62
63 stop() {
64         echo -n $"Shutting down Avahi daemon: "
65         killproc -p ${PIDFILE} $AVAHI_BIN
66         RETVAL=$?
67         [ $RETVAL -eq 0 ] && rm -f ${LOCKFILE} ${PIDFILE}
68         echo
69         return $RETVAL
70 }
71
72 reload() {
73         echo -n $"Reloading Avahi daemon... "
74         killproc -p ${PIDFILE} $AVAHI_BIN -HUP
75         RETVAL=$?
76         echo
77         return $RETVAL
78 }
79
80 restart() {
81         stop
82         start
83 }
84
85 RETVAL=0
86
87 # See how we were called.
88 case "$1" in
89   start)
90         start
91         ;;
92   stop)
93         stop
94         ;;
95   status)
96         status -p ${PIDFILE} $AVAHI_BIN
97         RETVAL=$?
98         ;;
99   restart)
100         restart
101         ;;
102   reload)
103         reload
104         ;;
105   condrestart)
106         if [ -f $LOCKFILE ]; then
107                 restart
108         fi
109         ;;
110   *)
111         echo $"Usage: $0 {start|stop|status|restart|condrestart}"
112         exit 2
113         ;;
114 esac
115
116 exit $RETVAL