[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: trouble getting fetchmail to start SOLVED



On Fri, Jan 05, 2001 at 10:46:29PM -0800, Ross Boylan wrote:

Thanks for all the ideas.  I solved the problem, though I'm still not
sure why it was a problem.

When the /init.d/fetchmail script runs from the system start up
environment, it is unable to find /root/.fetchmailrc (or it is
unwilling to).  It complains that no systems were specified.  So, as
one of you suggested, I told it explicitly where to get the
configuration.

This is peculiar, because playing with other scripts shows the script
was being run as root.  The fetchmail docs say it looks in
~/.fetchmailrc.  So perhaps the process is not completely root?  Or
fetchmail does some checks to see if it is running without a tty?

By the way, is there any reliable way to capture all the messages
which go to the console on system startup? dmesg and the various files
in /var/log do not get everything that shows on the screen--for
example, fetchmail's complaint when it couldn't find a system.

At any rate, here's the script which works:

#! /bin/sh
# /etc/init.d/fetchmail
# Hacked by Ross Boylan from the exim script which was...
#
# Written by Miquel van Smoorenburg <miquels@drinkel.ow.org>.
# Modified for Debian GNU/Linux by Ian Murdock <imurdock@gnu.ai.mit.edu>.
# Modified for exim by Tim Cutts <timc@chiark.greenend.org.uk>

set -e


DAEMON=/usr/bin/fetchmail
ARGS="--fetchmailrc /root/.fetchmailrc"
DEBUGLOG=/usr/local/rootlog/fetch.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



Reply to: