5 # Sample init script for Debian GNU/Linux
7 # Copyright (c) 2002 Georg C. F. Greve <greve@gnu.org>,
8 # all rights maintained by FSF Europe e.V.,
9 # Villa Vogelsang, Antonienallee 1, 45279 Essen, Germany
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2 of the License, or
14 # (at your option) any later version.
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 # Michael Brown <michaelb@opentext.com>
28 # This init script was modified on Thu, 30 Jan 2003 02:06:04 -0500 by
29 # Don Armstrong <don@donarmstrong.com> from contrib/spamass-milter to
30 # allow force-reload and options specified in
31 # /etc/default/spamass-milter necessary for inclusion in debian.
33 # It has been modified additionally to support LSB Boot options and
34 # status on Friday, July 6, 2007 14:02:44 PDT
38 # Provides: spamass-milter
39 # Required-Start: $syslog $local_fs $remote_fs
40 # Required-Stop: $syslog $local_fs $remote_fs
41 # Default-Start: 2 3 4 5
43 # Short-Description: milter for spamassassin
44 # Description: Calls spamassassin to allow filtering out
45 # spam from ham in libmilter compatible MTAs.
49 PATH=/sbin:/bin:/usr/sbin:/usr/bin
51 DAEMON=/usr/sbin/spamass-milter
52 SOCKET=/var/run/spamass/spamass.sock
53 PIDFILE=/var/run/spamass/spamass.pid
54 DESC="Sendmail milter plugin for SpamAssassin"
56 DEFAULT=/etc/default/spamass-milter
58 RUNAS="spamass-milter"
61 SOCKETOWNER="root:root"
63 test -x $DAEMON || exit 0
65 if [ -e /etc/mail/sendmail.cf ] && egrep -q 'X.+S=local:/var/run/sendmail/spamass\.sock' /etc/mail/sendmail.cf; then
66 SOCKET=/var/run/sendmail/spamass.sock
70 echo "WARNING: You are using the old location of spamass.sock. Change your input filter to use";
71 echo "/var/run/spamass/spamass.sock so spamass-milter can run as spamass-milter";
74 # If /usr/sbin/postfix exists, set up the defaults for a postfix install
75 # These can be overridden in /etc/default/spamass-milter
76 if [ -x /usr/sbin/postfix ]; then
77 SOCKET="/var/spool/postfix/spamass/spamass.sock"
78 SOCKETOWNER="postfix:postfix"
82 if [ -r $DEFAULT ]; then
86 if [ -n "$RUNAS" ]; then
87 CHUID="--chuid $RUNAS";
93 # Because the default socket is in the same location as the
94 # pidfile, we create them in this order.
95 for DIR in "$(dirname $PIDFILE)" "$(dirname $SOCKET)"; do
96 # if the dirname is '.', then it's some kind of odd socket, like
97 # an inet socket. Don't create the directory in such a case
98 if [ "$DIR" != "." ] && [ ! -d "$DIR" ]; then
100 if [ -x /sbin/restorecon ]; then
101 /sbin/restorecon "$DIR";
103 if [ -n "$RUNAS" ]; then
104 chown "$RUNAS" "$DIR";
108 if [ -n "$RUNAS" ] && [ -d $(dirname $PIDFILE) ] &&
109 [ "$(stat -c '%U' $(dirname $PIDFILE))" != "$RUNAS" ]; then
110 echo "WARNING: $NAME will run as user $RUNAS but $(dirname $PIDFILE) is not owned by $RUNAS";
111 echo "Either delete this directory or chown it appropriately. Startup attempts may fail.";
113 if [ -n "$RUNAS" ] && [ $(dirname $SOCKET) != "." ] &&
114 [ -d $(dirname $SOCKET) ] &&
115 [ "$(stat -c '%U' $(dirname $SOCKET))" != "$RUNAS" ]; then
116 echo "WARNING: $NAME will run as user $RUNAS but $(dirname $SOCKET) is not owned by $RUNAS";
117 echo "Either delete this directory or chown it appropriately. Startup attempts may fail.";
119 if [ $(dirname $SOCKET) != "." ]; then
122 start-stop-daemon --start -p $PIDFILE $CHUID --exec $DAEMON -- -P $PIDFILE -f -p $SOCKET $OPTIONS
124 if [ -n "$SOCKETMODE" ]; then
125 chmod $SOCKETMODE $SOCKET;
127 if [ -n "$SOCKETOWNER" ]; then
128 chown $SOCKETOWNER $SOCKET;
133 start-stop-daemon --oknodo --stop -p $PIDFILE --signal 3 --exec $DAEMON
140 if [ -e $PIDFILE ]; then
141 if kill -0 $(cat $PIDFILE); then
142 echo "${NAME} running";
145 echo "${NAME} dead but $PIDFILE exists";
148 echo "${NAME} not running";
155 echo -n "Starting $DESC: "
160 echo -n "Stopping $DESC: "
164 force-reload | restart)
165 echo -n "Restarting $DESC: "
176 echo "Usage: $N {start|stop|restart|force-reload|status}" >&2