#!/bin/sh # # $Id$ # # Sample init script for Debian GNU/Linux # # Copyright (c) 2002 Georg C. F. Greve , # all rights maintained by FSF Europe e.V., # Villa Vogelsang, Antonienallee 1, 45279 Essen, Germany # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Contact: # Michael Brown # This init script was modified on Thu, 30 Jan 2003 02:06:04 -0500 by # Don Armstrong from contrib/spamass-milter to # allow force-reload and options specified in # /etc/default/spamass-milter necessary for inclusion in debian. PATH=/sbin:/bin:/usr/sbin:/usr/bin DAEMON=/usr/sbin/spamass-milter SOCKET=/var/run/spamass/spamass.sock PIDFILE=/var/run/spamass/spamass.pid DESC="Sendmail milter plugin for SpamAssassin" DEFAULT=/etc/default/spamass-milter OPTIONS="" RUNAS="nobody" CHUID="" SOCKETMODE="0660" SOCKETOWNER="root:adm" test -x $DAEMON || exit 0 # If /usr/sbin/postfix exists, set up the defaults for a postfix install # These can be overridden in /etc/default/spamass-milter if [ -x /usr/sbin/postfix ]; then SOCKET="/var/spool/postfix/spamass/spamass.sock" PIDFILE="/var/spool/postfix/spamass/spamass.pid" SOCKETOWNER="postfix:postfix" fi; if [ -r $DEFAULT ]; then . $DEFAULT; fi; if [ -n "$RUNAS" ]; then CHUID="--chuid $RUNAS"; fi; set -e start() { if [ ! -d $(dirname $SOCKET) ]; then mkdir -p $(dirname $SOCKET); if [ -n "$SOCKETOWNER" ]; then chown "$SOCKETOWNER" $(dirname $SOCKET); fi; fi; if [ ! -d $(dirname $PIDFILE) ]; then mkdir -p $(dirname $PIDFILE); if [ -n "$RUNAS" ]; then chown "$RUNAS" $(dirname $PIDFILE); fi; fi; # Drop in a compatibility symlink for the old sendmail socket location if [ -d /var/run/sendmail ] && [ -n "$RUNAS" ] && [ "$SOCKET" == "/var/run/spamass/spamass.sock" ] && ! [ -e /var/run/sendmail/spamass.sock ]; then ln -s $SOCKET /var/run/sendmail/spamass.sock; fi; /bin/rm -f $SOCKET start-stop-daemon --start -p $PIDFILE $CHUID --exec $DAEMON -- -P $PIDFILE -f -p $SOCKET $OPTIONS sleep 1s if [ -n "$SOCKETMODE" ]; then chmod $SOCKETMODE $SOCKET; fi; if [ -n "$SOCKETOWNER" ]; then chown $SOCKETOWNER $SOCKET: fi; } stop(){ start-stop-daemon --stop -p $PIDFILE --signal 3 --exec $DAEMON /bin/sleep 5s /bin/rm -f $SOCKET } case "$1" in start) echo -n "Starting $DESC: " start echo "${DAEMON}" ;; stop) echo -n "Stopping $DESC: " stop echo "${DAEMON}" ;; force-reload | restart) echo -n "Restarting $DESC: " stop start echo "${DAEMON}" ;; *) N=$0 echo "Usage: $N {start|stop|restart}" >&2 exit 1 ;; esac exit 0