Previous TOC Next

Technical document: Virus detection with Clam Antivirus
Appendix A - Clam Antivirus startup and shutdown script
This is a simple startup and shutdown script for the Clam AntiVirus daemon clamd. It is an adapted version of the script to start up and shutdown clamsmtpd.

#!/bin/sh

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

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

# The user to run as
user=clamav

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

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

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

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

Previous: Chapter 2 - Setting up ClamSMTP TOC Next: Appendix B - Freshclam startup and shutdown script