debian/masqmail-debian

view masqmail.init @ 62:4ed3577e5044

Added tag 0.2.27-1 for changeset afae1a8e900f
author meillo@marmaro.de
date Mon, 19 Jul 2010 23:22:09 +0200
parents a9bc767c6541
children
line source
1 #!/bin/sh
2 ### BEGIN INIT INFO
3 # Provides: masqmail
4 # Required-Start: $remote_fs
5 # Required-Stop: $remote_fs
6 # Default-Start: 2 3 4 5
7 # Default-Stop: 0 1 6
8 # Short-Description: Starts and stops the masqmail daemon
9 # Description: The masqmail daemon listens on for incoming SMTP
10 # connections and processes its mail queue in regular
11 # intervals. Regular fetching of mail is possible too.
12 ### END INIT INFO
13 # /etc/init.d/masqmail
14 #
15 # Written by Miquel van Smoorenburg <miquels@drinkel.ow.org>.
16 # Modified for Debian GNU/Linux by Ian Murdock <imurdock@gnu.ai.mit.edu>.
17 # Modified for exim by Tim Cutts <tjrc1@mole.bio.cam.ac.uk>
18 # Modified for masqmail by Gregor Hoffleit <flight@debian.org>
19 # Modified for masqmail by Oliver Kurth <oku@masqmail.cx>
21 # standards version 3.9.0 recommends to be careful with `set -e' in
22 # init scripts. See 9.3.2 of the policy for reference.
23 # TODO: We should investigate into this.
24 set -e
26 # If you disable this file, masqmail can be run from /etc/inetd.conf
27 #exit 0
29 # defaults, do not edit here but in
30 # /etc/default/masqmail
31 INIT_SMTP_DAEMON=true
32 INIT_QUEUE_DAEMON=true
33 INIT_FETCH_DAEMON=false
34 QUEUE_DAEMON_IVAL=-q10m
35 FETCH_DAEMON_IVAL=-go5m
37 RUN_DIR=/var/run/masqmail
39 [ -r /etc/default/masqmail ] && . /etc/default/masqmail
41 PATH=/sbin:/bin:/usr/sbin:/usr/bin
42 DAEMON=/usr/sbin/masqmail
43 NAME=masqmail
44 DESC="MTA (masqmail)"
46 test -x $DAEMON || exit 0
48 if [ ! -f /etc/masqmail/masqmail.conf ] ; then
49 echo "you have to configure masqmail first."
50 exit 0
51 fi
53 # Create /var/run/masqmail if /var/run/ is a tmpfs.
54 if [ ! -d $RUN_DIR ] ; then
55 mkdir -p $RUN_DIR
56 fi
58 if [ x"$INIT_SMTP_DAEMON" = x"true" ] || [ x"$INIT_QUEUE_DAEMON" = x"true" ] ; then
59 DAEMON_ARGS=
60 if [ x"$INIT_SMTP_DAEMON" = x"true" ] ; then
61 DAEMON_ARGS=-bd
62 fi
64 if [ x"$INIT_QUEUE_DAEMON" = x"true" ] ; then
65 DAEMON_ARGS="$DAEMON_ARGS $QUEUE_DAEMON_IVAL"
66 fi
67 INIT_DAEMON=true
68 else
69 INIT_DAEMON=false
70 fi
72 case "$1" in
73 start)
74 echo -n "Starting $DESC: "
75 if [ x"$INIT_DAEMON" = x"true" ] ; then
76 update-inetd --disable smtp
77 start-stop-daemon --start --startas $DAEMON \
78 --pidfile $RUN_DIR/masqmail.pid -- $DAEMON_ARGS
79 echo -n " listen/queue"
80 fi
81 if [ x"$INIT_FETCH_DAEMON" = x"true" ] ; then
82 start-stop-daemon --start --startas $DAEMON \
83 --pidfile $RUN_DIR/masqmail-get.pid -- $FETCH_DAEMON_IVAL
84 echo -n " fetch"
85 fi
86 echo "."
87 ;;
88 stop)
89 echo -n "Stopping $DESC: "
90 if [ -f $RUN_DIR/masqmail.pid ] ; then
91 start-stop-daemon --stop --oknodo --retry 1 --name $NAME --pidfile $RUN_DIR/masqmail.pid
92 update-inetd --enable smtp
93 echo -n " listen/queue"
94 fi
95 if [ -f $RUN_DIR/masqmail-get.pid ] ; then
96 start-stop-daemon --stop --oknodo --retry 1 --name $NAME --pidfile $RUN_DIR/masqmail-get.pid
97 echo -n " fetch"
98 fi
99 echo "."
100 ;;
101 restart)
102 $0 stop
103 $0 start
104 ;;
105 reload|force-reload)
106 echo -n "Reloading $DESC configuration files: "
107 if [ -f $RUN_DIR/masqmail.pid ] ; then
108 start-stop-daemon --stop --signal 1 --pidfile $RUN_DIR/masqmail.pid
109 echo -n " listen/queue"
110 fi
111 if [ -f $RUN_DIR/masqmail-get.pid ] ; then
112 start-stop-daemon --stop --signal 1 --pidfile $RUN_DIR/masqmail-get.pid
113 echo -n " fetch"
114 fi
115 echo "."
116 ;;
117 *)
118 echo "Usage: /etc/init.d/$NAME {start|stop|restart|reload|force-reload}" >&2
119 exit 1
120 ;;
121 esac
123 exit 0