[dspam-users] Init script for RHEL 4

From: Scott Russell <lnxgeek@us.ibm.com>
Date: Wed Aug 24 2005 - 14:10:10 EDT

Not sure what others are using but since I didn't see an init script for
dspam in CVS HEAD or the list archives I put together a quick solution.
This works on RHEL 4 and should work on RHEL 3 as well. The start()
function could use some work so suggestions welcome.

Obviously this is most useful when running dspam in daemon mode. Drop it
into /etc/init.d/ and then run: chkconfig --add dspam; chkconfig dspam on;

-- 
Scott Russell <lnxgeek@us.ibm.com>
IBM Linux Technology Center System Admin

#!/bin/sh
#
# dspam: Starts dspam in daemon mode
#
# chkconfig: 345 70 30
# description: DSPAM (De-Spam) is a scalable, open-source statistical \
# anti-spam filter that provides high levels of accuracy \
# with minimal resources.
# processname: dspam
# pidfile: /var/run/dspam.pid
#

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

PATH=/usr/local/sbin:/usr/local/bin:$PATH
RETVAL=0

start() {
    echo -n $"Starting dspam: "
    dspam --daemon 2>/dev/null &
    RETVAL=$?
    if [ $RETVAL -eq 0 ] && touch /var/lock/subsys/dspam ; then
            echo_success
            echo
    else
            echo_failure
            echo
    fi

}

stop() {
    echo -n $"Stopping dspam: "
    killproc dspam
    RETVAL=$?
    echo
    if [ $RETVAL -eq 0 ]; then
        rm -f /var/lock/subsys/dspam
    fi
}

# See how we were called.
case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    status)
        status dspam
        RETVAL=$?
        ;;
    restart)
        stop
        start
        ;;
    condrestart)
        if [ -f /var/lock/subsys/dspam ]; then
            stop
            start
        fi
        ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|condrestart}"
        ;;
esac
exit $RETVAL
Received on Wed Aug 24 14:11:16 2005

This archive was generated by hypermail 2.1.8 : Thu Sep 29 2005 - 13:51:29 EDT