#!/bin/sh # WOODY COMES with better scripts. Use them instead. # # To start fetchmail as a system service, copy this file to # /etc/init.d/fetchmail and run "update-rc.d fetchmail # defaults 30". 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 ". # # To remove the service, delete /etc/init.d/fetchmail and run # "update-rc.d fetchmail remove". DAEMON=/usr/bin/fetchmail # # Patch to make sure to start in sysvinit # # Without following, fetchmail trys to read /.fetchmail instead of # /root/fetchmail if started in sysvinit script. ($PWD=$HOME=/) #FETCHMAILRC=/root/.fetchmailrc FETCHMAILRC=/etc/fetchmailrc set -e test -f $DAEMON || exit 0 case "$1" in start) echo -n "Starting mail retrieval agent: " if start-stop-daemon --start --exec $DAEMON -- -f $FETCHMAILRC; then echo "fetchmail." else echo "fetchmail fail to start, maybe already running."; fi ;; stop) echo -n "Stopping mail retrieval agent: " start-stop-daemon --stop --quiet --exec $DAEMON echo "fetchmail." ;; force-reload|restart) echo -n "Restarting mail retrieval agent: " start-stop-daemon --stop --quiet --exec $DAEMON if start-stop-daemon --start --exec $DAEMON -- -f $FETCHMAILRC; then echo "fetchmail." else echo "fetchmail fail to start, maybe already running."; fi echo "fetchmail." ;; *) echo "Usage: /etc/init.d/fetchmail {start|stop|restart}" exit 1 ;; esac exit 0