]> git.meshlink.io Git - catta/blob - initscript/fedora/avahi-daemon.in
merge fedora initscript changes, closes rhbz #246875
[catta] / initscript / fedora / avahi-daemon.in
1 #! /bin/sh
2 #
3 # avahi-daemon:       Starts the Avahi Daemon
4 #
5 # chkconfig: 345 97 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 # config: 
12
13 OTHER_AVAHI_OPTS=""
14
15 # Source function library.
16 . /etc/init.d/functions
17 . /etc/sysconfig/network
18
19
20 AVAHI_BIN=@sbindir@/avahi-daemon
21
22 if [ $1 == 'status' ]; then
23     test -x $AVAHI_BIN || exit 4
24 else 
25     test -x $AVAHI_BIN || exit 5
26 fi
27
28 LOCKFILE=/var/lock/subsys/avahi-daemon
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         $AVAHI_BIN -D
41         RETVAL=$?
42         if [ $RETVAL = 0 ]; then
43                 touch $LOCKFILE
44                 success $"$base startup"
45         else
46                 failure $"$base startup"
47         fi
48         echo
49         return $RETVAL
50 }
51
52 stop() {
53         echo -n $"Shutting down Avahi daemon: "
54         $AVAHI_BIN -k
55         RETVAL=$?
56         [ $RETVAL = 0 ] && success $"$base shutdown" || failure $"$base shutdown"
57         rm -f $LOCKFILE
58         echo
59         return $RETVAL
60 }
61
62 reload() {
63         echo -n $"Reloading Avahi daemon... "
64         $AVAHI_BIN -r
65         RETVAL=$?
66         [ $RETVAL = 0 ] && success $"$base reload" || failure $"$base reload"
67         echo
68         return $RETVAL
69 }
70
71 restart() {
72         stop
73         start
74 }
75
76 RETVAL=0
77
78 # See how we were called.
79 case "$1" in
80   start)
81         start
82         ;;
83   stop)
84         stop
85         ;;
86   status)
87         $AVAHI_BIN -c
88         RETVAL=$?
89         [ $RETVAL = 0 ] && echo $"Avahi daemon is running" || echo $"Avahi daemon is not running"
90         ;;
91   restart)
92         restart
93         ;;
94   reload)
95         reload 
96         ;;
97   condrestart)
98         if [ -f $LOCKFILE ]; then
99                 restart
100         fi
101         ;;
102   *)
103         echo $"Usage: $0 {start|stop|status|restart|condrestart}"
104         exit 2
105 esac
106
107 exit $RETVAL
108