#!/sbin/runscript
# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-dns/pdns/files/pdns,v 1.8 2006/08/15 19:35:52 swegener Exp $

opts="${opts} reload monitor dump"

# Default instance
PDNS_INSTANCE="default"
PDNS_CONFIG=""

# Multiple instances support
if [[ ${SVCNAME:0:5} = pdns[.-] && -n ${SVCNAME:5} ]]
then
	PDNS_INSTANCE="${SVCNAME:5}"
	PDNS_CONFIG="--config-name=${PDNS_INSTANCE}"
fi

depend() {
	need net
}

start() {
	ebegin "Starting PowerDNS (${PDNS_INSTANCE})"
	/usr/sbin/pdns_server ${PDNS_CONFIG} --daemon=yes --guardian=yes
	eend $?
}

stop() {
	ebegin "Stopping PowerDNS (${PDNS_INSTANCE})"
	/usr/bin/pdns_control ${PDNS_CONFIG} quit &>/dev/null
	eend $?
}

reload() {
	ebegin "Reloading PowerDNS (${PDNS_INSTANCE})"
	/usr/bin/pdns_control ${PDNS_CONFIG} cycle &>/dev/null
	eend $?
}

dump() {
       ebegin "Dumping PowerDNS (${PDNS_INSTANCE}) variables"
       /usr/bin/pdns_control ${PDNS_CONFIG} list
       eend $?
}

monitor() {
       ebegin "Starting PowerDNS (${PDNS_INSTANCE}) in monitor mode"
       /usr/sbin/pdns_server ${PDNS_CONFIG} --daemon=no --guardian=no --control-console=yes --loglevel=9
       eend $?
}
