]> git.meshlink.io Git - catta/blobdiff - initscript/debian/avahi-daemon.in
get rid of a lot of old svn cruft
[catta] / initscript / debian / avahi-daemon.in
index e942785a7e611d36f68c276aadef8e685a0100b5..97fa1579398a8a285340412cbfefbcdce81f9537 100755 (executable)
@@ -1,7 +1,5 @@
 #!/bin/sh
 
-# $Id$
-
 # This file is part of avahi.
 #
 # avahi is free software; you can redistribute it and/or modify it
@@ -75,6 +73,16 @@ else
        return $1
     }
     
+    log_warning_msg () {
+       if log_use_fancy_output; then
+           YELLOW=`$TPUT setaf 3`
+           NORMAL=`$TPUT op`
+           echo "$YELLOW*$NORMAL $@"
+       else
+           echo "$@"
+       fi
+    }
+
 fi
 
 #set -e
@@ -83,16 +91,27 @@ PATH=/sbin:/bin:/usr/sbin:/usr/bin
 DESC="Avahi mDNS/DNS-SD Daemon"
 NAME="avahi-daemon"
 DAEMON="@sbindir@/$NAME"
+SCRIPTNAME=/etc/init.d/$NAME
 
 # Gracefully exit if the package has been removed.
 test -x $DAEMON || exit 0
 
+# don't start if /etc/default/avahi-daemon says so.
+AVAHI_DAEMON_START=1
+test -f /etc/default/avahi-daemon && . /etc/default/avahi-daemon
+
+if [ "$AVAHI_DAEMON_START" != "1" -a "$1" != "stop" ]; then
+    log_warning_msg "Not starting $DESC $NAME, disabled via /etc/default/$NAME"
+    exit 0
+fi
+
 #
 #       Function that starts the daemon/service.
 #
 d_start() {
-    $DAEMON -c
-    [ $? = 0 ] && exit 0
+    modprobe capability >/dev/null 2>&1 || true
+
+    $DAEMON -c && return 0
 
     if [ -s /etc/localtime ]; then
        if [ ! -d /etc/avahi/etc ]; then
@@ -108,28 +127,21 @@ d_start() {
 #       Function that stops the daemon/service.
 #
 d_stop() {
-    $DAEMON -c
-    [ $? != 0 ] && exit 0
-
-    $DAEMON -k
+    $DAEMON -c && $DAEMON -k
 }
 
 #
 #       Function that reload the config file for the daemon/service.
 #
 d_reload() {
-    $DAEMON -c
-    [ $? != 0 ] && exit 0
-
-    $DAEMON -r
+    $DAEMON -c && $DAEMON -r
 }
 
 #
 #       Function that check the status of the daemon/service.
 #
 d_status() {
-    $DAEMON -c
-    [ $? = 0 ]  && echo "$DESC is running" || echo "$DESC is not running"
+    $DAEMON -c && echo "$DESC is running" || echo "$DESC is not running"
 }
 
 case "$1" in
@@ -150,7 +162,7 @@ case "$1" in
         ;;
     restart|force-reload)
         log_begin_msg "Restarting $DESC: $NAME"
-        d_stop
+        $DAEMON -c && d_stop
         d_start
         log_end_msg $?
         ;;