#!/bin/bash
#
#	/etc/rc.d/rc.pdnsd
#
# Starts the Proxy DNS Daemon
#
# description: Proxy DNS Daemon
# processname: pdnsd
# config: /etc/pdnsd.conf
# distribution: Slackware
# author: Nikola Kotur <kotnik@ns-linux.org>
#
# Additional info:
# 1) put these lines in the /etc/rc.d/rc.M:
#	if [ -x /etc/rc.d/rc.pdnsd ]; then
#		/etc/rc.d/rc.pdnsd start
#	fi
#
# 2) put these lines in the /etc/rc.d/rc.6 and /etc/rc.d/rc.K:
#	if [ -x /etc/rc.d/rc.pdnsd ]; then
#		/etc/rc.d/rc.pdnsd stop
#	fi


test -x @prefix@/sbin/pdnsd || exit 0
[ -f @sysconfdir@/pdnsd.conf ] || exit 1

RETVAL=0

start() {
	echo -n "Starting pdnsd... "
	RETVAL=$?
 	@prefix@/sbin/pdnsd -d
	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/pdnsd
	echo ' OK'
}

stop() {
	echo -n "Shutting down pdnsd... "
	killall pdnsd
	RETVAL=$?
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/pdnsd
	echo ' OK'
}

restart() {
	stop
	start
}

condrestart() {
	[ -e /var/lock/subsys/pdnsd ] && restart
	return 0
}

case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  reload|restart)
	restart
  	;;
  condrestart)
	condrestart
  	;;
  *)
	echo $"Usage: $0 {start|stop|restart|condrestart|reload}"
	RETVAL=1
esac

exit $RETVAL
