Rev 154 | 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 25000000 --limitflush"ARGS="-K -Dujsoftware.com -S homeserver.ujsoftware.com --syslog --sslcertck"#====================================================================#====================================================================# 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 ] ; thenecho "Cannot find Fetchmail executable!"exit 0fi# Check the .fetchmailrc file exists - fetchmail doesn't run# in daemon mode without it.if [ ! -f $FRC ] ; thenecho "Cannot find the runtime control file!"exit 0fi#====================================================================prog=$"Fetchmail"RETVAL=0start() {if [ -f $LOCK_FILE ]; thenecho "Fetchmail is already running!"exit 0elseecho -n $"Starting $prog: "$FETCHMAIL -f $FRC --daemon $TIME $ARGS >/dev/null 2>&1fiRETVAL=$?[ $RETVAL -eq 0 ] && successecho[ $RETVAL -eq 0 ] && touch $LOCK_FILEreturn $RETVAL}stop() {echo -n $"Shutting down $prog: "if [ -f /var/run/fetchmail.pid ]; thenkill `head -1 /var/run/fetchmail.pid`RETVAL=$?[ $RETVAL -eq 0 ] && successrm -f $LOCK_FILEechoreturn $RETVALfiecho "already down"return 0}# See how we were called.case "$1" instart)start;;stop)stop;;restart)stopstart;;condrestart)if [ -f $LOCK_FILE ]; thenstopstartRETVAL=$?fi;;status)status fetchmailRETVAL=$?;;*)echo $"Usage: $0 {start|stop|restart|condrestart|status}"RETVAL=1esacexit $RETVAL