#!/bin/sh # Source function library . /usr/local/etc/rc.d/functions PROGBIN=/usr/bin/spamd PROGNAME=spamd PROG_PID=/var/run/spamd.pid #check the command line for actions start() { echo -n "Starting SpamAssassin: " daemon $PROGBIN -d -c -m 15 --ipv4 --pidfile=$PROG_PID if [ $? = 0 ]; then echo "[ OK ]"; else echo "[ FAILED ]"; fi } stop() { RET=1; echo -n "Stopping SpamAssassin: " pid=`cat $PROG_PID`; if [ -d /proc/$pid ]; then kill -TERM $pid RET=$? else killall -KILL $PROGNAME 1>/dev/null 2>/dev/null RET=$? fi sleep 1; killall -KILL $PROGNAME 1>/dev/null 2>/dev/null; if [ $RET = 0 ]; then echo "[ OK ]"; else echo "[ FAILED ]"; fi } show_status() { echo -n "status (pid"; PID=`cat $PROG_PID` PIDS=`grep $PID /proc/*/status | cut -d/ -f3` for i in $PIDS; do { echo -n " $i"; }; done; echo ")"; } case "$1" in start) start ;; stop) stop ;; status) show_status ;; restart) stop start ;; reload) restart ;; *) echo "Usage: $1 {start|stop|status|reload|restart}" exit 1 esac exit 0