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