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