#!/sbin/openrc-run

description="mDNS server"

depend()
{
        need 9pinit net
	after firewall
}

start()
{
        [ -d /sys/bus/vmbus ] && exit 0

        ebegin "Starting mDNS server"

	[ -n "${PIDFILE}" ] || PIDFILE=/var/run/mdnstool.pid

	hostname -F /etc/hostname
	export HOSTNAME=$(hostname -s).local.

	start-stop-daemon --start --quiet \
		--background \
		--exec /sbin/mdnstool \
		--make-pidfile --pidfile ${PIDFILE} \
		-- -if eth0 -hostname ${HOSTNAME}

	eend $? "Failed to start mDNS server"
}

stop()
{
        [ -d /sys/bus/vmbus ] && exit 0

        ebegin "Stopping mDNS server"

	[ -n "${PIDFILE}" ] || PIDFILE=/var/run/mdnstool.pid

	start-stop-daemon --stop --quiet --pidfile ${PIDFILE}

	eend $? "Failed to stop mDNS server"
}
