#! /bin/sh
#
# This file was automatically customized by debmake on Thu, 19 Nov 1998 19:13:50 +0200
#
# Written by Miquel van Smoorenburg <miquels@drinkel.ow.org>.
# Modified for Debian GNU/Linux by Ian Murdock <imurdock@gnu.ai.mit.edu>.
# Modified for Debian by Christoph Lameter <clameter@debian.org>

PATH=/bin:/usr/bin:/sbin:/usr/sbin
DAEMON=/usr/bin/tcpserver
# The following value is extracted by debstd to figure out how to generate
# the postinst script. Edit the field to change the way the script is
# registered through update-rc.d (see the manpage for update-rc.d!)
FLAGS="defaults 50"
HOSTNAME="$(hostname --fqdn)"

test -f $DAEMON || exit 0
[ "x$HOSTNAME" == "x" ] && exit 0

case "$1" in
  start)
    echo -n "Starting vchkpw pop daemon: qmail-pop3"
    ulimit -v 2048
    sh -c "start-stop-daemon --start --quiet --user root \
    	--exec $DAEMON -- \
	-H -R 0 pop-3 \
	/usr/sbin/qmail-popup "$HOSTNAME" /usr/sbin/vchkpw \
	/usr/sbin/qmail-pop3d Maildir &"
    echo "."
    ;;
  stop)
    echo -n "Stopping vchkpw pop daemon: qmail-pop3"
    if [ "$(start-stop-daemon --name tcpserver --user root \
		--test --stop --quiet)" ] ; then
	start-stop-daemon --stop --quiet --oknodo --user root --exec $DAEMON
	echo "."
    else
	echo " not running."
    fi
    ;;
  restart|force-reload)
    $0 stop
    $0 start
    ;;
  reload)
    ;;
  *)
    echo "Usage: /etc/init.d/vchkpw {start|stop|restart}"
    exit 1
    ;;
esac

exit 0
