#!/bin/sh # # chkconfig: 345 91 35 # description: Starts and stops the fetchmail daemon used to retrieve mail \ # via various protocols (such as POP3 and IMAP4). # # config: /etc/fetchmailrc # ### BEGIN INIT INFO # Provides: fetchmail # Required-Start: $network # Required-Stop: $network # Default-Start: 3 4 5 # Short-Description: The fetchmail mail retrieving daemon # Description: Starts and stops the fetchmail daemon used to retrieve mail # via various protocols (such as POP3 and IMAP4). ### END INIT INFO # Source function library. . /etc/rc.d/init.d/functions # Source networking configuration. . /etc/sysconfig/network # Source fetchmail configuration. . /etc/sysconfig/fetchmail # Check that networking is up. [ ${NETWORKING} = "no" ] && exit 0 # Check that fetchmailrc exists. [ -s /etc/fetchmailrc ] || exit 0 RETVAL=0 # See how we were called. case "$1" in start) if [ ! -f /var/lock/subsys/fetchmail ]; then echo -n "Starting Fetchmail services: " daemon fetchmail -d ${FETCHMAIL_POLL:-180} -f /etc/fetchmailrc RETVAL=$? echo [ $RETVAL -eq 0 ] && touch /var/lock/subsys/fetchmail else RETVAL=1 fi ;; stop) if [ -f /var/lock/subsys/fetchmail ]; then # killproc fetchmail action "Shutting Fetchmail services: " /usr/bin/fetchmail --quit rm -f /var/lock/subsys/fetchmail >/dev/null 2>&1 RETVAL=$? else RETVAL=1 fi ;; restart) $0 stop $0 start RETVAL=$? ;; condrestart) if [ -f /var/lock/subsys/fetchmail ]; then $0 stop $0 start fi ;; reload) if [ -f /var/lock/subsys/fetchmail ]; then echo -n "Reloading fetchmailrc file: " killproc fetchmail -HUP RETVAL=$? echo else RETVAL=1 fi ;; status) status fetchmail RETVAL=$? ;; *) echo "Usage: $0 {start|stop|restart|reload|condrestart|status}" exit 1 esac exit $RETVAL