6e65612b1e2e2ef2aba8636212e006253a100df7
[platform/upstream/mdnsresponder.git] / mDNSResponder-1096.40.7 / mDNSPosix / mdnsd.sh
1 #!/bin/sh
2 # Emacs settings: -*- tab-width: 4 -*-
3 #
4 # Copyright (c) 2002-2006 Apple Computer, Inc. All rights reserved.
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9
10 #     http://www.apache.org/licenses/LICENSE-2.0
11
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 #
18 # Linux /etc/init.d script to start/stop the mdnsd daemon.
19 #
20 # The following lines are used by the *BSD rcorder system to decide
21 # the order it's going to run the rc.d scripts at startup time.
22 # PROVIDE: mdnsd
23 # REQUIRE: NETWORKING
24
25 if [ -r /usr/sbin/mdnsd ]; then
26     DAEMON=/usr/sbin/mdnsd
27 else
28     DAEMON=/usr/local/sbin/mdnsd
29 fi
30
31 test -r $DAEMON || exit 0
32
33 # Some systems have start-stop-daemon, some don't. 
34 if [ -r /sbin/start-stop-daemon ]; then
35         START="start-stop-daemon --start --quiet --exec"
36         # Suse Linux doesn't work with symbolic signal names, but we really don't need
37         # to specify "-s TERM" since SIGTERM (15) is the default stop signal anway
38         # STOP="start-stop-daemon --stop -s TERM --quiet --oknodo --exec"
39         STOP="start-stop-daemon --stop --quiet --oknodo --retry 2 --exec"
40 else
41         killmdnsd() {
42                 kill -TERM `cat /var/run/mdnsd.pid`
43                 sleep 1
44         }
45         START=
46         STOP=killmdnsd
47 fi
48
49 case "$1" in
50     start)
51         echo -n "Starting Apple Darwin Multicast DNS / DNS Service Discovery daemon:"
52         echo -n " mdnsd"
53         $START $DAEMON
54         echo "."
55         ;;
56     stop)
57         echo -n "Stopping Apple Darwin Multicast DNS / DNS Service Discovery daemon:"
58         echo -n " mdnsd" ; $STOP $DAEMON
59         echo "."
60         ;;
61     reload|restart|force-reload)
62                 echo -n "Restarting Apple Darwin Multicast DNS / DNS Service Discovery daemon:"
63                 $STOP $DAEMON
64                 $START $DAEMON
65                 echo -n " mdnsd"
66         ;;
67     *)
68         echo "Usage: /etc/init.d/mDNS {start|stop|reload|restart}"
69         exit 1
70         ;;
71 esac
72
73 exit 0