#!/bin/sh
#
# $FreeBSD: ports/dns/maradns/files/maradns.in,v 1.3 2010/02/08 15:08:44 miwi Exp $
#

# PROVIDE: maradns
# REQUIRE: SERVERS
# BEFORE: DAEMON
# KEYWORD: shutdown
#

. /etc/rc.subr

: ${maradns_enable="NO"}
: ${maradns_conf="/usr/local/etc/mararc"}


# Nastly hack to allow the MaraDNS bind to the proper variable IP address
mara_pre() {
  IP=`ifconfig ${internalif} | awk '/inet/ { print $2 }'`
  sed -i .orig 's/^\(ipv4_bind_addresses[\ \t=]*"\).*$/\1'${IP}',127.0.0.1"/g' ${maradns_conf}
}

name="maradns"
rcvar=`set_rcvar`
command="/usr/local/bin/duende"
command_args="/usr/local/sbin/maradns -f ${maradns_conf}"
pidfile="/var/run/${name}.pid"
start_precmd=mara_pre
load_rc_config $name

run_rc_command "$1"

