#! /bin/sh
#
# /etc/init.d/smtp-vilter
# starts the smtp-vilter program from Marc Balmer <marc@msys.ch>
#
# init-Script for SuSE 8.0
# by Ralf Naegele <ralf.naegele@she.net>
####################
# smtp-vilter is chrooted to /var/smtp-vilter
# running with uid _vilter and gid _vilter
# so you first have to create this uid/gid and directory with
# its subdirectories. 
# see smtp-vilter-<version>/README
# Add "START_VILTER = YES" to /etc/rc.config
#####################
### BEGIN INIT INFO
# Provides: smtp-vilter
# Required-Start: $network $sendmail
# Required-Stop: $network $sendmail
# Default-Start: 3 5
# Default-Stop: 0 1 2 4 6
# Description: high performance content filter for sendmail
### END INIT INFO

test -s /etc/sysconfig/mail && \
      . /etc/sysconfig/mail

test -s /etc/sysconfig/sendmail && \
      . /etc/sysconfig/sendmail

# Source SuSE config (if still necessary, most info has been moved)
test -r /etc/rc.config && . /etc/rc.config
test "$START_VILTER" = yes || exit 0

vilterpid=/var/run/smtp-vilter.pid
vilterbin=/usr/local/sbin/smtp-vilter

. /etc/rc.status
rc_reset
case "$1" in
    start)
	echo -n "Starting smtp-vilter"
        startproc $vilterbin
	rc_status -v
	;;
    stop)
	echo -n "Shutting down smtp-vilter"
	killproc -p $vilterpid -TERM $vilterbin
	rc_status -v
	;;
    try-restart)
	$0 stop && $0 start
	rc_status
	;;
    restart)
	$0 stop
	$0 start
	rc_status
	;;
    status)
	echo -n "Checking for service smtp-vilter: "
	checkproc -p $vilterpid /usr/local/sbin/smtp-vilter
	rc_status -v
	;;
    *)
	echo "Usage: $0 {start|stop|status|try-restart|restart}"
	exit 1
esac

rc_exit
