[Mimedefang] Clam/MIMEdefang install procedure

David F. Skoll dfs at roaringpenguin.com
Mon Nov 17 14:31:17 EST 2003


On Mon, 17 Nov 2003, Bill Curtis wrote:

> Tried that one, but wasn't overly impressed with it's init script.

Here's the init script we use with our commercial CanIt software.
You need to configure your clam file to drop the PID in
/var/spool/MIMEDefang/clamd.pid and use the UNIX-domain
socket /var/spool/MIMEDefang/clamd.sock.  It also has to
run as the same user as MIMEDefang.

Regards,

David.

#!/bin/sh
#
# clamd		Start and stop the clamd virus scanner.
#
# chkconfig: 2345 87 13
# description: Clamd is a GPL'd virus scanner

##########################################################################
# Copyright 2002-2003, Roaring Penguin Software Inc.  All rights reserved.
#
# Current Revision:
#
# $Source: /home/cvsroot/CanIt/clamav/initscript,v $
# $Revision: 1.1 $
# $Author: dfs $
# $Date: 2003/04/14 14:41:45 $
#
##########################################################################

prog='clamd'

# Is the program executable?  We search in various places
PROGDIR=''
SPOOLDIR=/var/spool/MIMEDefang
PID=$SPOOLDIR/clamd.pid
SOCKET=$SPOOLDIR/clamd.sock

for d in /usr/local/sbin /usr/sbin /usr/local/bin /usr/bin ; do
    if [ -x $d/$prog ] ; then
	PROGDIR=$d
	break
    fi
done

if test "$PROGDIR" = "" ; then
    exit 0
fi

start_clamd() {
    if test -r $PID ; then
	if kill -0 `cat $PID` > /dev/null 2>&1 ; then
	    echo "clamd (`cat $PID`) seems to be running."
	    return 1
	fi
    fi

    # Start clamd
    printf "%-60s" "Starting $prog: "
    rm -f $SOCKET > /dev/null 2>&1
    $PROGDIR/$prog
    RETVAL=$?
    if [ $RETVAL = 0 ] ; then
	echo "[  OK  ]"
	return 0
    else
	echo "[FAILED]"
	return 1
    fi
}

status() {
    RETVAL=0
    # Check status of clamd
    if test -f "$PID" ; then
	X=`cat $PID`
	kill -0 $X > /dev/null 2>&1
	if test "$?" = 0 ; then
	    echo "clamd                  is running (pid $X)"
	else
	    echo "clamd                  is stopped (pid $X)"
	    RETVAL=1
	fi
    else
	echo "clamd                  is stopped"
	RETVAL=1
    fi
    return $RETVAL
}

stop_clamd() {
    # Stop daemon
    printf "%-60s" "Shutting down $prog: "
    if test -f "$PID" ; then
	kill `cat $PID`
	RETVAL=$?
    else
	RETVAL=1
    fi
    if [ $RETVAL = 0 ] ; then
	echo "[  OK  ]"
    else
	echo "[FAILED]"
    fi

    rm -f $SOCKET > /dev/null 2>&1
    rm -f $PID > /dev/null 2>&1
}

# See how we were called.
case "$1" in
  start)
  start_clamd
    ;;

  stop)
  stop_clamd
    ;;

  restart)
    stop_clamd
    start_clamd
    RETVAL=$?
    ;;

  status)
    status
    RETVAL=$?
    ;;

  *)
    echo "Usage: $0 {start|stop|restart|status}"
    exit 1
esac

exit $RETVAL



More information about the MIMEDefang mailing list