#!/bin/sh
#
# Startup script for fetchmail
#
# chkconfig: 2345 99 01
# description: A software package for fetching mail from remote servers.
# processname: fetchmail
# pidfile: /var/run/fetchmail/fetchmail.pid
# config: /etc/fetchmail

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

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
#[ ${NETWORKING} = "no" ] && exit 0

USER="fetchmail"
PIDFILE="/var/run/fetchmail/fetchmail.pid"
RETVAL=0

args="-f /etc/fetchmail --syslog --pidfile=$PIDFILE"
prog="fetchmail"

# See how we were called.
case "$1" in
  start)
	echo -n $"Starting $prog: "
    daemon --user="$USER" --pidfile="$PIDFILE" $prog $args
	echo
	RETVAL=$?
	;;
  stop)
	echo -n $"Stopping $prog: "
	killproc $prog
	echo
	/bin/rm -f $pidfile
	RETVAL=$?
	;;
  status)
	;;
  restart|reload)
	$0 stop
	$0 start
	RETVAL=$?
	;;
  *)
	echo "Usage: $prog {start|stop|restart|reload|status}"
	exit 1
esac

exit $RETVAL
