X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=initscript%2Fdebian%2Favahi-dnsconfd.in;h=ac3480451faf435f73d4b79c05d65a809f2d43af;hb=d173d6630d3bf1ff17c874cdc105ff6016df5377;hp=649d72f2b1fbd40c638f1ec244caa2ad1b321070;hpb=5bf66ba8d479bbe613da1b9557b8aad2c448b536;p=catta diff --git a/initscript/debian/avahi-dnsconfd.in b/initscript/debian/avahi-dnsconfd.in index 649d72f..ac34804 100755 --- a/initscript/debian/avahi-dnsconfd.in +++ b/initscript/debian/avahi-dnsconfd.in @@ -75,6 +75,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,14 +93,27 @@ PATH=/sbin:/bin:/usr/sbin:/usr/bin DESC="Avahi Unicast DNS Configuration Daemon" NAME="avahi-dnsconfd" 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-dnsconfd says so. +AVAHI_DNSCONFD_START=1 +test -f /etc/default/avahi-dnsconfd && . /etc/default/avahi-dnsconfd + +if [ "$AVAHI_DNSCONFD_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 + if [ -s /etc/localtime ]; then if [ ! -d /etc/avahi/etc ]; then mkdir -p @sysconfdir@/avahi/etc >/dev/null 2>&1 @@ -105,16 +128,29 @@ d_start() { # Function that stops the daemon/service. # d_stop() { - $DAEMON -k || /bin/true + $DAEMON -c + [ $? != 0 ] && exit 0 + + $DAEMON -k } # # Function that reload the config file for the daemon/service. # d_refresh() { + $DAEMON -c + [ $? != 0 ] && exit 0 + $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" +} case "$1" in start) @@ -134,11 +170,14 @@ case "$1" in ;; reload|restart|force-reload) log_begin_msg "Restarting $DESC: $NAME" - d_stop + $DAEMON -c && d_stop d_start log_end_msg $? ;; - *) + status) + d_status + ;; + *) echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|reload}" >&2 exit 1 ;;