view dns/avahi/avahi @ 1095:b9feb5557a0b

core/btrfs-progs: initial import, closes #1651
author David Demelier <markand@malikania.fr>
date Mon, 09 Sep 2019 21:10:00 +0200
parents 3dfef64b81c1
children 815d267adb72
line wrap: on
line source

#!/bin/busybox sh
#
# /etc/rc.d/avahi -- run control script for avahi
#
# Copyright (c) 2019 David Demelier <markand@malikania.fr>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#

if [ -f /etc/rc.conf ]; then
	. /etc/rc.conf
fi

: ${AVAHI_CMD:=/bin/avahi-daemon}
: ${AVAHI_ARGS:=-D}
: ${AVAHI_PID:=/var/run/avahi-daemon/pid}

avahi_start()
{
	if [ -s $AVAHI_PID ]; then
		echo "avahi is already running with pid: $(cat $AVAHI_PID)"
	else
		echo "Starting avahi: $AVAHI_CMD $AVAHI_ARGS"
		$AVAHI_CMD $AVAHI_ARGS
	fi
}

avahi_status()
{
	if [ -s $AVAHI_PID ]; then
		echo "avahi is running with pid: $(cat $AVAHI_PID)"
	else
		echo "avahi is not running"
	fi
}

avahi_stop()
{
	if [ -s $AVAHI_PID ]; then
		echo "Stopping avahi."
		kill -QUIT $(cat $AVAHI_PID)
		rm -f $AVAHI_PID
	fi
}

avahi_restart()
{
	avahi_stop
	sleep 3
	avahi_start
}

case $1 in
start)
	avahi_start
	;;
status)
	avahi_status
	;;
stop)
	avahi_stop
	;;
restart)
	avahi_restart
	;;
*)
	echo "usage: $(basename $0) restart|start|status|stop"
	;;
esac