#!/bin/sh

# PROVIDE: mdnsd
# REQUIRE: DAEMON
# KEYWORD: shutdown

. /etc/rc.subr

name="mdnsd"
rcvar=mdnsd_enable
command="/usr/sbin/${name}"
start_precmd="mdnsd_precmd"
pidfile="/var/run/mDNSResponder.pid"

mdnsd_precmd() 
{
	if grep -q mdns "/etc/nsswitch.conf"; then
		return
	else
		if [ -w "/etc/nsswitch.conf" ]; then
			sed -i '' 's|^\(hosts.*\)files dns|\1files mdns dns|g' /etc/nsswitch.conf
		else
			echo ' /etc/nsswitch.conf is not writable, update failed.'
			return
		fi
	fi
}


load_rc_config $name
run_rc_command $*
