atom feed14 messages in com.redhat.valhalla-listconfirm script is correct for setting...
FromSent OnAttachments
pheonix1tJul 27, 2003 11:44 am 
William HooperJul 27, 2003 12:33 pm 
pheonix1tJul 27, 2003 12:43 pm 
William HooperJul 27, 2003 1:14 pm 
James HoJul 27, 2003 7:10 pm 
Mike KercherJul 27, 2003 8:47 pm 
James HoJul 27, 2003 8:57 pm 
Oleg GoldshmidtJul 27, 2003 9:17 pm 
Keith MastinJul 28, 2003 6:25 am 
James HoJul 28, 2003 6:47 pm 
James HoJul 30, 2003 7:15 pm 
dave...@intellisense.com.hkJul 30, 2003 7:39 pm 
James HoJul 30, 2003 7:57 pm 
Keith MastinJul 31, 2003 6:45 am 
Subject:confirm script is correct for setting fetchmail on *rc scripts
From:pheonix1t (pheo@houston.rr.com)
Date:Jul 27, 2003 11:44:00 am
List:com.redhat.valhalla-list

hello,

I was requested to setup fetchmail to start automatically from bootup for certain users...after doing some research I found these scripts that suggest how to set this up. I just wanted to confirm with other list members that one of both of these scripts are correct before I put this into production.

I've attached the 2 scripts as text files.

Thanks!

Oskar

currently I have fetchmail being run at login from ~/.bash_profile. this is fine for myself at login, however, I would like to have fetchmail run as a daemon at boot time so it can poll for multiple users. Where should I have fetchmail loaded from to do this?

This is exactly what I do.

Fetchmail needs to run as root so you need a .fetchmailrc in /root like this:

set daemon 600 poll pop.xxx.xxx protocol pop3 username gs@gmx.co.uk to gs@scgf.gmx.co.uk password xxxxxxx poll pop.xxxxx.xxxxx protocol pop3 username scgf01 to gs@scgf.gmx.co.uk password xxxxxxx poll pop.xxxxxx.xxxxxx protocol pop3 username scgf02 to gs@scgf.gmx.co.uk password xxxxxxx

As you can see, I poll three mailboxes. The daemon 600 ensures that fetchmail runs as a daemon and polls the mailboxes at intervals of 10 minutes. I have a cable connection to the internet so this works well.

All you need to do is start fetchmail during bootup:

#! /bin/sh # /etc/init.d/fetchmail # Hacked by Ross Boylan from the exim script which was... # # Written by Miquel van Smoorenburg <miqu@drinkel.ow.org>. # Modified for Debian GNU/Linux by Ian Murdock <imur@gnu.ai.mit.edu>. # Modified for exim by Tim Cutts <ti@chiark.greenend.org.uk> # To start fetchmail as a system service, copy this file to # /etc/init.d/fetchmail and run "update-rc.d fetchmail # defaults". A fetchmailrc file containg hosts and # passwords for all local users should be placed in /root # and should contain a line of the form "set daemon <nnn>". # # To remove the service, delete /etc/init.d/fetchmail and run # "update-rc.d fetchmail remove".

set -e

DAEMON=/usr/bin/fetchmail ARGS="--fetchmailrc /root/.fetchmailrc" DEBUGLOG=/var/log/fetchmail.log NAME=fetchmail

echo `whoami` `date` >> $DEBUGLOG # This was not my only test of uid. I created a shell script and # ran it from start-stop-deamon. The script printed whoami as root.

test -x $DAEMON || exit 0

case "$1" in start) echo -n "Starting fetchmail: " start-stop-daemon --start -v --exec $DAEMON -- $ARGS >> $DEBUGLOG # Note the use of -- before args to the program echo "Done." ;; stop) echo -n "Stopping fetchmail: " start-stop-daemon --stop --oknodo --exec $DAEMON echo "Done." ;; restart|reload|force-reload) echo "Restarting fetchmail: " start-stop-daemon --stop --oknodo --exec $DAEMON start-stop-daemon --start -v --exec $DAEMON -- $ARGS >> $DEBUGLOG echo "Done." ;; *) echo "Usage: /etc/init.d/$NAME {start|stop|restart}" exit 1 ;; esac

exit 0

I also have a .forward file in my home directory which sorts mail for other users:

# Exim filter <<== do not edit or remove this line!

if error_message then finish endif logfile $home/eximfilter.log

if $h_To: contains "sco@gmx.co.uk" then deliver scott

elif $h_To: contains "sah1" then deliver scott

endif

'scott; is obviously a user on my system. Not sure why I have this file in *my* home directory, but it works so I just leave it there. I assume it works because in my .fetchmailrc I am telling fetchmail to send all mail initially to me as gsmh, therefore mail becomes my property before exim takes over to filter it.

All credit to those who originally supplied me with this info.

Hope this helps.

-- Phillip Deackes Using Progeny Debian Linux

The usual way to start stuff is to have a script that starts the program in /etc/init.d/ and then have a link to that in the relevant runlevel directory. Have a look in /etc/init.d and /etc/rc.d/rc5.d/ and you should see what I mean. A script/link in rc5.d that starts with 'S' will start when you enter run level 5 - ie graphical mode.

A script, suitable for use in /etc/init.d is below. It allows fetchmail to be started for any number of user accounts. Just create the fetcmail script file in /usr/local/etc (owned by the user and mode 0600) named like fetchmail.user-name. The script will start up a fetcmail process as each of the users as represented by a fetchmail script file.

#!/bin/bash # # fetchmail This shell script takes care of starting and stopping # fetchmail for user accounts. For each acccount that will use # fetchmail there needs to be a file in /usr/local/etc like # fetchmail.user-name. Make the files owned by the user and # mode 0600. # # chkconfig: 2345 81 29 # description: Fetchmail is a tool for retrieving the mail from remote # servers via POP3 or IMAP for users and inserting that # mail into the local mail system. # processname: fetchmail

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

# Source networking configuration. . /etc/sysconfig/network

# Check that networking is up. [ ${NETWORKING} = "no" ] && exit 0

binary=/usr/local/bin/fetchmail [ -f $binary ] || exit 0 # # Simple function to get the PID of an arbitrary process # pidof() { ps -efw|grep $1|grep -v grep|tr -s ' '|cut -d ' ' -f 2; }

RETVAL=0 prog="fetchmail" start() { # Start Daemon # Loop through the individual fetchmail rc files

for f in /usr/local/etc/fetchmail.*; do user=`echo $f | sed -e "s/.*fetchmail\.\(.*\)/\1/"` echo -n $"Starting $prog for $user: " pid=`pidof $f` if [ $pid ]; then echo else su $user -c "$binary -f $f" RETVAL=$? if [ $RETVAL -eq 0 ]; then echo_success touch /var/lock/subsys/$prog else echo_failure fi echo fi done return $RETVAL }

stop() { # Stop daemons. for f in /usr/local/etc/fetchmail.*; do user=`echo $f | sed -e "s/.*fetchmail\.\(.*\)/\1/"` echo -n $"Shutting down $prog for $user: " pid=`pidof $f` if [ $pid ]; then kill $pid echo_success else echo fi echo done RETVAL=0 [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog return $RETVAL }

# See how we were called. case "$1" in start) start ;; stop) stop ;; restart|reload) stop start RETVAL=$? ;; *) echo $"Usage: $0 {start|stop|restart}" exit 1 esac

exit $RETVAL