Previous TOC Next

Technical document: Virus detection with Clam Antivirus
Appendix C - ClamSMTP startup and shutdown script
This is a simple startup and shutdown script for clamsmtpd. It is a slightly modified version of the script found here.

#!/bin/sh

###########################################################################
# CONFIGURATION

# Most configuration options are found in the clamsmtpd.conf file.
# For more info see:
# man clamsmtpd.conf

# The user to run as
user=clamav

# The prefix clamsmtpd was installed to
prefix=/usr/local/sbin

# The location for pid file
piddir=/var/run/clamav

###########################################################################
# SCRIPT

case $1 in
start)
        echo "Starting clamsmtpd"
        mkdir -p $piddir
        chown $user $piddir
        su -m $user -c "$prefix/clamsmtpd -p $piddir/clamsmtpd.pid"
        ;;
stop)
        echo "Stopping clamsmtpd"
        [ -f $piddir/clamsmtpd.pid ] && kill `cat $piddir/clamsmtpd.pid`
        ;;
*)
        echo "usage: clamsmptd.sh { start | stop }" >&2
        ;;
esac

Previous: Appendix B - Freshclam startup and shutdown script TOC Next: Back to Table of Contents