Subversion Repositories configs

Rev

Rev 116 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

#!/bin/bash
#
# Script to run Fetchmail software at boot time.
#
# Last Updated: 21st October 2003
#
# This script is based upon the init scripts
# as used on Red Hat Linux.
#
# The script has been tested on RH 7.x, 8.0, and 9.0
#
# Author: Gary Myers  AMBCS
# mailto: gary@xxxxxxxxxxxxxx
#
# This script is realeased under the terms of the GPL.
# You can source a copy at:
# http://www.fsf.org/copyleft/copyleft.html
#====================================================================
# Change history:

#
# sometime 2004: Modified for my liking ;)
#

# 21st October 2003: Michael Thompson added `-f $FRC' to Start
# section to stop the boot process from complaining about no
# mailservers being specified.

# 3rd November 2003: Corrected Run level info line.

#====================================================================

#====================================================================
# Run level information
#
# chkconfig: 2345 99 90
# description: Fetchmail
#
# Run "/sbin/chkconfig --add fetchmail"  to add the Run levels;
# this *should* setup the symlinks!
#====================================================================


#====================================================================
# Set the path to the executable.
#
FETCHMAIL=/usr/bin/fetchmail

# Set the path to the runtime control file.
#
FRC=/etc/fetchmailrc

# Path to the lock file.
#
LOCK_FILE=/var/lock/subsys/fetchmail

# Set this time for daemon operations.
TIME=74
ARGS="-K -Dujsoftware.com -S homeserver.ujsoftware.com --limit 12000000 --limitflush"

#====================================================================

#====================================================================

# System checks:

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

# Check that networking is up.
# No point in trying to send or recieve otherwise!!
[ ${NETWORKING} ="yes" ] || exit 0

# Check we have the fetchmail program installed.
if [ ! -x $FETCHMAIL ] ; then
echo "Cannot find Fetchmail executable!"
exit 0
fi

# Check the .fetchmailrc file exists - fetchmail doesn't run
# in daemon mode without it.

if [ ! -f $FRC ] ; then
echo "Cannot find the runtime control file!"
exit 0
fi

#====================================================================

prog=$"Fetchmail"

RETVAL=0

start() {
if [ -f $LOCK_FILE ]; then
  echo "Fetchmail is already running!"
  exit 0

else

  echo -n $"Starting $prog: "
  $FETCHMAIL -f $FRC --daemon $TIME $ARGS >/dev/null 2>&1
fi

RETVAL=$?
[ $RETVAL -eq 0 ] && success
echo
[ $RETVAL -eq 0 ] && touch $LOCK_FILE
return $RETVAL
}

stop() {
echo -n $"Shutting down $prog: "
killproc fetchmail
RETVAL=$?
[ $RETVAL -eq 0 ]
rm -f $LOCK_FILE
echo
return $RETVAL
}

# See how we were called.
case "$1" in
   start)
start
;;
   stop)
stop
;;
   restart)
stop
start
;;
   condrestart)
if [ -f $LOCK_FILE ]; then
   stop
   start
   RETVAL=$?
fi
;;
   status)
status fetchmail
RETVAL=$?
;;
   *)
    echo $"Usage: $0 {start|stop|restart|condrestart|status}"
    RETVAL=1
esac

exit $RETVAL