# @(#) $Id: fetchmail2.RedHat.txt,v 1.2 2005/11/21 21:13:11 web2 Exp $ #!/bin/sh # Copyright (c) 2004 Christian Barmala http://www.barmala.de/ # License GNU Public License http://opensource.org/licenses/gpl-license.php # chkconfig: - 81 29 # fig: - 57 43 # fig: 23 06 39 # description: fetchmail collects mail from various mailboxes # /sbin/chkconfig --add fetchmail # or # cd /etc/init.d/rc2.d # ln -s ../fetchmail S06fetchmail # ln -s ../fetchmail K39fetchmail # Und wer im Runlevel 3 (grafischer Login) arbeitet noch zusätzlich: # cd /etc/init.d/rc3.d # ln -s ../fetchmail S06fetchmail # ln -s ../fetchmail K39fetchmail # PATH=/bin:/usr/bin:/sbin:/usr/sbin FETCHMAIL_BIN=/usr/bin/fetchmail test -x $FETCHMAIL_BIN || exit 5 # set fetchmail users FETCHMAIL_USERS='User1 User2 User3' start() { if [ $FETCHMAIL_USERS = "" ]; then echo -n "Starting fetchmail-daemon" $FETCHMAIL_BIN -f /root/.fetchmailrc -d 300 echo "." else for USER in $FETCHMAIL_USERS; do echo -n "Starting fetchmail-daemon for $USER" /usr/bin/sudo -u $USER -H $FETCHMAIL_BIN -d 500 echo "." done fi } stop() { if [ $FETCHMAIL_USERS = "" ]; then echo -n "Shutting down fetchmail-daemon" $FETCHMAIL_BIN --quit echo "." else for USER in $FETCHMAIL_USERS; do echo -n "Shutting down fetchmail-daemon for $USER" /usr/bin/sudo -u $USER -H $FETCHMAIL_BIN --quit echo "." done fi } case "$1" in start) start ;; stop) stop ;; status) ps -ax | fgrep fetchmail | fgrep -v grep | fgrep -v service | fgrep -v $0 ;; restart) stop start ;; *) echo "Usage: $0 {start | stop | restart | status}" >&2 exit 1 ;; esac exit 0