#!/bin/bash # # Script to run the Fetchmail client software at boot time. # (http://www.catb.org/~esr/fetchmail/) # # This script is aimed at those who wish to run Fetchmail # at boot time. The script is based on the init scripts for # Red Hat/Fedora Core, and has been tested on Fedora Core 3. # # Check http://www.gaztronics.net/ for the # most up-to-date version of this script. # # This script is realeased under the terms of the GPL. # You can source a copy at: # http://www.fsf.org/copyleft/copyleft.html # # Please feel free to modify the script to suite your own needs. # I always welcome email feedback with suggestions for improvements. # Please do not email for general support. I do not have time to answer # personal help requests. # Author: Gary Myers MIIE MBCS # email: http://www.gaztronics.net/webform/ # Revision 1.1 - 4th April 2005 #==================================================================== # Run level information # # chkconfig: 2345 99 90 # description: Fetchmail mail retrieval program # processname: 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. # (If this file is in any other location, change the path, and # remember fetchmail is running as 'root' so the file will need # root:root permissions.) # FRC=/root/.fetchmailrc # Path to the lock file. # LOCK_FILE=/var/lock/subsys/fetchmail # Set this time for daemon operations (in Seconds). # Default for this config is 1 hour. # # 30 mins = 1800 # 2 hours = 7200 # 24 hours = 86400 # TIME=3600 #==================================================================== #==================================================================== # Paths and variables and system checks. # Source function library (It's a Red Hat thing!) . /etc/rc.d/init.d/functions # Check that networking is up. # [ ${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 >/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