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

Re: fetchmail daemon



> А вот как правильно в скрипте передать параметры в fetchmail -
> непонятно, там же выполняется команда start-stop-daemon со своим набором
> опций. А как ей сказать, что определенная опция относится к fetchmail?

man start-stop-daemon:

Any arguments given after -- on the  command
line are passed unmodified to the program being started.

А в Debian-пакете используется вот такой скриптик:

#!/bin/sh
#
# Fetchmail/fetchmail-ssl init script
# $Id: fetchmail.init,v 1.11 2001/04/11 05:58:22 hmh Exp $
#
# A fetchmailrc file containg hosts and passwords for all 
# local users should be placed in /etc/fetchmailrc
# and should contain a line of the form "set daemon <nnn>".
#
# Remember to make the /etc/fetchmailrc mode 600 to avoid
# disclosing the users' passwords
#
# This script will NOT start or stop fetchmail if the 
# /etc/fetchmailrc file does not exist.
#

set -e

DAEMON=/usr/bin/fetchmail
test -f $DAEMON || exit 0

# Defaults
CONFFILE=/etc/fetchmailrc
OPTIONS="--daemon 300 --syslog --nobounce"

# Reads config file (will override defaults above)
[ -r /etc/default/fetchmail ] && . /etc/default/fetchmail

OPTIONS="${OPTIONS} -f ${CONFFILE}"

# Tries to find a better place for the UIDL 
# cache than root's homedir
#
# change this to your heart's content.

if [ -d /var/mail ] ; then
	OPTIONS="${OPTIONS} -i /var/mail/.fetchmail-UIDL-cache"
else 
	[ -d /var/spool/mail ] && OPTIONS="${OPTIONS} -i
/var/spool/mail/.fetchmail-UIDL-cache"
fi

testconfig () {
	[ -r ${CONFFILE} ] || {
		echo "system-wide fetchmail not configured."
		exit 0
	}
}

START="--start --quiet --exec ${DAEMON} --user root -- ${OPTIONS}"

case "$1" in
  start)
        echo -n "Starting mail retrieval agent: "
	testconfig
        if start-stop-daemon ${START} >/dev/null 2>&1 ; then
		echo "fetchmail."
        else
		if start-stop-daemon --test ${START} >/dev/null 2>&1 ; then
		   echo "(failed!)"
		   exit 1
		else
		   echo "fetchmail already running."
		fi
	fi
        ;;
  stop)
        echo -n "Stopping mail retrieval agent: "
	testconfig
        if fetchmail --quit >/dev/null 2>&1 ; then
		echo "fetchmail."
	else
		echo "system-wide fetchmail not running."
	fi
        ;;
  force-reload|restart)
        echo -n "Restarting mail retrieval agent: "
	testconfig
        fetchmail --quit >/dev/null 2>&1 || true
        if start-stop-daemon ${START} >/dev/null 2>&1 ; then
        	echo "fetchmail."
	else
		echo "fetchmail did not start."
	fi
        ;;
  awaken)
  	echo -n "Awakening mail retrieval agent: "
	testconfig
	[ -r /var/run/fetchmail.pid ] && fetchmail >/dev/null 2>&1 && echo
"fetchmail." && exit 0
	echo "system-wide fetchmail not running."
	exit 1
	;;
  *)
        echo "Usage: /etc/init.d/fetchmail
{start|stop|restart|force-reload|awaken}"
        exit 1
        ;;
esac

exit 0

-- 
Andrey V. Kiselev
Scientific Research Center for Ecological Safety Russian Academy of Sciences
Office phone:  7-812-230-78-34  ICQ UIN 26871517
Registered Linux user number 169907



Reply to: