meillo@0: #!/bin/sh meillo@0: ### BEGIN INIT INFO meillo@0: # Provides: masqmail meillo@0: # Required-Start: $remote_fs meillo@0: # Required-Stop: $remote_fs meillo@0: # Default-Start: 2 3 4 5 meillo@0: # Default-Stop: 0 1 6 meillo@10: # Short-Description: Starts and stops the masqmail daemon meillo@10: # Description: The masqmail daemon listens on for incoming SMTP meillo@10: # connections and processes its mail queue in regular meillo@10: # intervals. Regular fetching of mail is possible too. meillo@0: ### END INIT INFO meillo@0: # /etc/init.d/masqmail meillo@0: # meillo@0: # Written by Miquel van Smoorenburg . meillo@0: # Modified for Debian GNU/Linux by Ian Murdock . meillo@0: # Modified for exim by Tim Cutts meillo@0: # Modified for masqmail by Gregor Hoffleit meillo@0: # Modified for masqmail by Oliver Kurth meillo@0: meillo@0: set -e meillo@0: meillo@0: # If you disable this file, masqmail can be run from /etc/inetd.conf meillo@0: #exit 0 meillo@0: meillo@0: # defaults, do not edit here but in meillo@0: # /etc/default/masqmail meillo@0: INIT_SMTP_DAEMON=true meillo@0: INIT_QUEUE_DAEMON=true meillo@0: INIT_FETCH_DAEMON=false meillo@0: QUEUE_DAEMON_IVAL=-q10m meillo@0: FETCH_DAEMON_IVAL=-go5m meillo@0: meillo@0: RUN_DIR=/var/run/masqmail meillo@0: meillo@0: [ -r /etc/default/masqmail ] && . /etc/default/masqmail meillo@0: meillo@0: PATH=/sbin:/bin:/usr/sbin:/usr/bin meillo@0: DAEMON=/usr/sbin/masqmail meillo@0: NAME=masqmail meillo@0: DESC="MTA (masqmail)" meillo@0: meillo@0: test -x $DAEMON || exit 0 meillo@0: meillo@0: if [ ! -f /etc/masqmail/masqmail.conf ] ; then meillo@0: echo "you have to configure masqmail first." meillo@0: exit 0 meillo@0: fi meillo@0: meillo@0: # Create /var/run/masqmail if /var/run/ is a tmpfs. meillo@0: if [ ! -d $RUN_DIR ] ; then meillo@0: mkdir -p $RUN_DIR meillo@0: fi meillo@0: meillo@0: if [ x"$INIT_SMTP_DAEMON" = x"true" ] || [ x"$INIT_QUEUE_DAEMON" = x"true" ] ; then meillo@0: DAEMON_ARGS= meillo@0: if [ x"$INIT_SMTP_DAEMON" = x"true" ] ; then meillo@0: DAEMON_ARGS=-bd meillo@0: fi meillo@0: meillo@0: if [ x"$INIT_QUEUE_DAEMON" = x"true" ] ; then meillo@0: DAEMON_ARGS="$DAEMON_ARGS $QUEUE_DAEMON_IVAL" meillo@0: fi meillo@0: INIT_DAEMON=true meillo@0: else meillo@0: INIT_DAEMON=false meillo@0: fi meillo@0: meillo@0: case "$1" in meillo@0: start) meillo@0: echo -n "Starting $DESC: " meillo@0: if [ x"$INIT_DAEMON" = x"true" ] ; then meillo@0: update-inetd --disable smtp meillo@0: start-stop-daemon --start --startas $DAEMON \ meillo@0: --pidfile $RUN_DIR/masqmail.pid -- $DAEMON_ARGS meillo@0: echo -n " listen/queue" meillo@0: fi meillo@0: if [ x"$INIT_FETCH_DAEMON" = x"true" ] ; then meillo@0: start-stop-daemon --start --startas $DAEMON \ meillo@0: --pidfile $RUN_DIR/masqmail-get.pid -- $FETCH_DAEMON_IVAL meillo@0: echo -n " fetch" meillo@0: fi meillo@0: echo "." meillo@0: ;; meillo@0: stop) meillo@0: echo -n "Stopping $DESC: " meillo@0: if [ -f $RUN_DIR/masqmail.pid ] ; then meillo@0: start-stop-daemon --stop --oknodo --retry 1 --name $NAME --pidfile $RUN_DIR/masqmail.pid meillo@0: update-inetd --enable smtp meillo@0: echo -n " listen/queue" meillo@0: fi meillo@0: if [ -f $RUN_DIR/masqmail-get.pid ] ; then meillo@0: start-stop-daemon --stop --oknodo --retry 1 --name $NAME --pidfile $RUN_DIR/masqmail-get.pid meillo@0: echo -n " fetch" meillo@0: fi meillo@0: echo "." meillo@0: ;; meillo@0: restart) meillo@0: $0 stop meillo@0: $0 start meillo@0: ;; meillo@0: reload|force-reload) meillo@0: echo -n "Reloading $DESC configuration files: " meillo@0: if [ -f $RUN_DIR/masqmail.pid ] ; then meillo@0: start-stop-daemon --stop --signal 1 --pidfile $RUN_DIR/masqmail.pid meillo@0: echo -n " listen/queue" meillo@0: fi meillo@0: if [ -f $RUN_DIR/masqmail-get.pid ] ; then meillo@0: start-stop-daemon --stop --signal 1 --pidfile $RUN_DIR/masqmail-get.pid meillo@0: echo -n " fetch" meillo@0: fi meillo@0: echo "." meillo@0: ;; meillo@0: *) meillo@0: echo "Usage: /etc/init.d/$NAME {start|stop|restart|reload|force-reload}" >&2 meillo@0: exit 1 meillo@0: ;; meillo@0: esac meillo@0: meillo@0: exit 0