Blob Blame Raw
#!/bin/sh
#
# Startup script for milter-regex
#
# chkconfig: - 75 40
# description: Allows sendmail to filter mail using regular expressions
# processname: milter-regex
# config: /etc/mail/milter-regex.conf /etc/sysconfig/milter-regex

### BEGIN INIT INFO
# Provides: milter-regex
# Required-Start: $local_fs $network $syslog $named
# Required-Stop: $local_fs $network $syslog $named
# Default-Stop: 0 1 6
# Short-Description: Start or stop Regex Milter
# Description: Milter-regex allows regular expression based filtering of mail
#	messages as they arrive in sendmail
### END INIT INFO

# Source function library.
. /etc/rc.d/init.d/functions

# Source options file
[ -f /etc/sysconfig/milter-regex ] && . /etc/sysconfig/milter-regex

[ -x /usr/sbin/milter-regex ] || exit 5

prog="milter-regex"

start() {
    echo -n $"Starting $prog: " 
    daemon $prog $OPTIONS
    RETVAL=$? 
    echo
    if [ $RETVAL -eq 0 ]; then
        touch /var/lock/subsys/milter-regex
    else
        exit 7
    fi
    return 0
}

stop() {
    if test "x`pidof milter-regex`" != x; then
	echo -n $"Stopping $prog: "
	killproc milter-regex
	echo
    fi
    RETVAL=$?
    rm -f /var/lock/subsys/milter-regex
    if test "x`pidof milter-regex`" = x; then
        return 0
    else
        return 1
    fi
}

case "$1" in
	start)
	    start
	    ;;
	stop)
	    stop
	    ;;
	status)
	    status milter-regex
	    ;;
	reload)
	    # milter-regex reloads configuration automatically if the config
	    # file has changed, so the reload action is a no-op
	    exit 0
	    ;;
	force-reload|restart)
	    if test "x`pidof milter-regex`" != x; then
	        stop
	    fi
	    start
	    ;;
	condrestart|try-restart)
	    if test "x`pidof milter-regex`" != x; then
		stop
		start
	    fi
	    ;;
	*)
	    echo $"Usage: $0 {start|stop|force-reload|restart|try-restart|status}"
	    exit 2
esac