#! /bin/sh
#		Written by Miquel van Smoorenburg <miquels@cistron.nl>.
#		Modified for Debian
#		by Ian Murdock <imurdock@gnu.ai.mit.edu>.
#
# Version:	@(#)skeleton  1.9  26-Feb-2001  miquels@cistron.nl
# /etc/init.d/policyd-weight: v1 2006/11/08 Jan Wagner <waja@cyconet.org>

### BEGIN INIT INFO
# Provides: policyd-weight
# Required-Start: $local_fs $network $remote_fs $syslog
# Required-Stop: $local_fs $network $remote_fs $syslog
# Default-Start:  2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start and stop the policyd-weight daemon
# Description: a Perl policy daemon for the Postfix MTA
### END INIT INFO

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/policyd-weight
NAME=policyd-weight
PIDFILE=/var/run/$NAME.pid
DESC=policyd-weight

test -x $DAEMON || exit 0

# Include policyd-weight defaults if available
if [ -f /etc/default/policyd-weight ] ; then
	. /etc/default/policyd-weight
fi

set -e

case "$1" in
  start)
	echo -n "Starting $DESC: "
		$DAEMON $DAEMON_OPTS start
	echo "$NAME."
	;;
  stop)
	echo -n "Stopping $DESC (incl. cache): "
		$DAEMON -k && start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE && rm -rf $PIDFILE
	echo "$NAME."
	;;
  dstop)
	echo -n "Stopping $DESC (without cache): "
		$DAEMON $DAEMON_OPTS stop
	echo "$NAME."
	;;
  reload)
	echo "Reloading $DESC configuration files."
		$DAEMON $DAEMON_OPTS reload
	;;
  restart|force-reload)
	echo -n "Restarting $DESC (incl. cache): "
		$DAEMON -k && $DAEMON $DAEMON_OPTS restart
	echo "$NAME."
	;;
  drestart)
	echo -n "Restarting $DESC (without cache): "
		$DAEMON $DAEMON_OPTS restart
	echo "$NAME."
	;;
  *)
	N=/etc/init.d/$NAME
	echo "Usage: $N {start|stop|dstop|restart|drestart|reload|force-reload}" >&2
	exit 1
	;;
esac

exit 0
