#!/bin/sh
#
# Cobalt fetchamil script to start and stop the daemon responsible
# for multidrop. Be aware that this will kill other fetchmail processes
# that are running on the box so don't do start 'em - allright?
#
# chkconfig: 2345 81 21
# description: Begins fetchmail for multidrop mail.
#
# Copyright (C) 2000 Cobalt Networks.

# Source function library.
. /etc/rc.d/init.d/functions

FETCHMAIL=/usr/bin/fetchmail
CONF="/etc/fetchmail/multidrop:localdomain"

case "$1" in
    start)
	echo -n "Starting fetchmail daemon: "
	daemon $FETCHMAIL -f $CONF
	echo
	touch /var/lock/subsys/fetchmail
        ;;

    stop)
        echo -n "Shutting fetchmail daemon"
	$FETCHMAIL -q
	if [ $? = 0 ] ; then
	        echo -n "OK"
	else
		echo -n "FAIL"
	fi

        echo ""
        ;;

    restart)
	$0 stop
	$0 start
	;;

    status)
	;;

    *)
        echo "Usage: fetchmail {start|stop|restart|status}"
        exit 1
esac

exit 0
