view masqmail.init @ 32:6293062092d1

Added tag 0.2.21-7 for changeset 792d5a6b7c7b
author meillo@marmaro.de
date Mon, 08 Feb 2010 14:17:25 +0100
parents a9bc767c6541
children 8638dc3d7bcd
line wrap: on
line source

#!/bin/sh
### BEGIN INIT INFO
# Provides:          masqmail
# Required-Start:    $remote_fs
# Required-Stop:     $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Starts and stops the masqmail daemon
# Description:       The masqmail daemon listens on for incoming SMTP
#                    connections and processes its mail queue in regular
#                    intervals. Regular fetching of mail is possible too.
### END INIT INFO
# /etc/init.d/masqmail
#
# 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 <tjrc1@mole.bio.cam.ac.uk>
# Modified for masqmail by Gregor Hoffleit <flight@debian.org>
# Modified for masqmail by Oliver Kurth <oku@masqmail.cx>

set -e

# If you disable this file, masqmail can be run from /etc/inetd.conf
#exit 0

# defaults, do not edit here but in
# /etc/default/masqmail
INIT_SMTP_DAEMON=true
INIT_QUEUE_DAEMON=true
INIT_FETCH_DAEMON=false
QUEUE_DAEMON_IVAL=-q10m
FETCH_DAEMON_IVAL=-go5m

RUN_DIR=/var/run/masqmail

[ -r /etc/default/masqmail ] && . /etc/default/masqmail

PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/masqmail
NAME=masqmail
DESC="MTA (masqmail)"

test -x $DAEMON || exit 0

if [ ! -f /etc/masqmail/masqmail.conf ] ; then
    echo "you have to configure masqmail first."
    exit 0
fi

# Create /var/run/masqmail if /var/run/ is a tmpfs.
if [ ! -d $RUN_DIR ] ; then
    mkdir -p $RUN_DIR
fi

if [ x"$INIT_SMTP_DAEMON" = x"true" ] || [ x"$INIT_QUEUE_DAEMON" = x"true" ] ; then
    DAEMON_ARGS=
    if [ x"$INIT_SMTP_DAEMON" = x"true" ] ; then
	DAEMON_ARGS=-bd
    fi

    if [ x"$INIT_QUEUE_DAEMON" = x"true" ] ; then
	DAEMON_ARGS="$DAEMON_ARGS $QUEUE_DAEMON_IVAL"
    fi
    INIT_DAEMON=true
else
    INIT_DAEMON=false
fi

case "$1" in
  start)
    echo -n "Starting $DESC: "
    if [ x"$INIT_DAEMON" = x"true" ] ; then
	update-inetd --disable smtp
	start-stop-daemon --start --startas $DAEMON \
	    --pidfile $RUN_DIR/masqmail.pid -- $DAEMON_ARGS
	echo -n " listen/queue"
    fi
    if [ x"$INIT_FETCH_DAEMON" = x"true" ] ; then
	start-stop-daemon --start --startas $DAEMON \
	    --pidfile $RUN_DIR/masqmail-get.pid -- $FETCH_DAEMON_IVAL
	echo -n " fetch"
    fi
    echo "."
    ;;
  stop)
    echo -n "Stopping $DESC: "
    if [ -f $RUN_DIR/masqmail.pid ] ; then
	start-stop-daemon --stop --oknodo --retry 1 --name $NAME --pidfile $RUN_DIR/masqmail.pid
	update-inetd --enable smtp
	echo -n " listen/queue"
    fi
    if [ -f $RUN_DIR/masqmail-get.pid ] ; then
	start-stop-daemon --stop --oknodo --retry 1 --name $NAME --pidfile $RUN_DIR/masqmail-get.pid
	echo -n " fetch"
    fi
    echo "."
      ;;
  restart)
    $0 stop
    $0 start
    ;;
  reload|force-reload)
    echo -n "Reloading $DESC configuration files: "
    if [ -f $RUN_DIR/masqmail.pid ] ; then
	start-stop-daemon --stop --signal 1 --pidfile $RUN_DIR/masqmail.pid
	echo -n " listen/queue"
    fi
    if [ -f $RUN_DIR/masqmail-get.pid ] ; then
	start-stop-daemon --stop --signal 1 --pidfile $RUN_DIR/masqmail-get.pid
	echo -n " fetch"
    fi
    echo "."
    ;;
  *)
    echo "Usage: /etc/init.d/$NAME {start|stop|restart|reload|force-reload}" >&2
    exit 1
    ;;
esac

exit 0