We are going to use DSPAM in daemon mode using the following command:
If that works we need to reload the postfix configuration to enable our new content filter. You can do that by issuing the following command:
This is of course the manual method of starting DSpam, but you want to be sure it starts after the next scheduled reboot. Because by the time you do that you will have forgotten all about it.
First we need to create a shell script that will start and stop DSpam in daemon mode. I’ve created a script called dspam_startup in /usr/local/bin next to all the other DSpam commands. It looks like:
#!/bin/sh
#
# dspam: Starts dspam in daemon mode
#
# with minimal resources.
# processname: dspam
# pidfile: /var/run/dspam.pid
#
# Source function library.
PATH=/usr/local/sbin:/usr/local/bin:$PATH
start() {
echo -n $”Starting dspam: ”
dspam –daemon 2>/dev/null &
}
stop() {
echo -n $”Stopping dspam: ”
kill $(sudo cat /var/run/dspam.pid)
}
# See how we were called.
case “$1″ in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo $”Usage: $0 {start|stop|restart}”
;;
esac
exit $RETVAL
Please don’t forget to set the execute bit on the script to be able to use it:
Next we need to create the StartupItem scripts that are called during boot and shutdown processes. To do this you need to download the Dspam-startup.tar archive and extract as root into ‘/Library/StartupItems’.
The DSpam startup item looks like:
##
# DSPAM spam filter
#
# Richard5
##
. /etc/rc.common
StartService ()
{
if [ "${DSPAMDAEMON:=-NO-}" = "-YES-" ]; then
echo “Starting DSpam daemon”
/usr/local/bin/dspam_startup start
fi
}
StopService ()
{
echo “Stopping DSpam daemon”
/usr/local/bin/dspam_startup stop
}
RestartService ()
{
if [ "${DSPAMDAEMON:=-NO-}" = "-YES-" ]; then
echo “Restarting DSpam daemon”
/usr/local/bin/dspam_startup restart
else
StopService
fi
}
RunService “$1″
The file StartupParameters.plist will help in setting the correct order for programs to start to fulfill any dependencies. DSpam requires MySQL to be running and this file will help to accomplish this, the content should look like:
Description = “DSpam mail spam filter”;
Provides = (“Dspam”);
Uses = (“MySQL”);
}
The last thing to do is to add the following line to the /etc/hostconfig file:
This controls if you want DSpam to be started after a reboot.
Next step: Training DSPAM with scripts


