View Single Post
  #1  
Old 14th October 2007, 14:48
bernie2004 bernie2004 is offline
Junior Member
 
Join Date: Oct 2007
Posts: 1
Thanks: 0
Thanked 6 Times in 1 Post
Default update and switch to clamd on ubuntu 7.04

this is what i did since clamav was stalling the server:

Code:
> apt-get install libgmp3-dev
> cd /some-build-directory
> wget http://ovh.dl.sourceforge.net/sourceforge/clamav/clamav-0.91.2.tar.gz
> tar xzf c*0.91.2*gz
> cd c*0.91.2
libgmp3-dev will enable verifying digital signatures (http://www.clamav.net/support/faq)

Code:
> ./configure --prefix=/home/admispconfig/ispconfig/tools/clamav \
              --sysconfdir=/home/admispconfig/ispconfig/tools/clamav/etc \
              --with-user=admispconfig \
              --with-group=admispconfig \
              --disable-clamav \
              --disable-bzip2
> make
> make install
> cp -f COPYING /home/admispconfig/ispconfig/tools/clamav/
edit clamassassin
Code:
> vi /home/admispconfig/ispconfig/tools/clamav/bin/clamassassin
Code:
CLAMSCAN=/home/admispconfig/ispconfig/tools/clamav/bin/clamdscan
create logfolder
Code:
> mkdir /var/log/clamav
> chown admispconfig:admispconfig /var/log/clamav
edit clamav.conf or clamd.conf
( clamd.conf should be a link to clamav.conf )
Code:
> vi /home/admispconfig/ispconfig/tools/clamav/etc/clamav.conf
or
> vi /home/admispconfig/ispconfig/tools/clamav/etc/clamd.conf
Code:
LogFile /var/log/clamav/clamd.log
ScanMail 1
edit freshclam.conf
Code:
> vi /home/admispconfig/ispconfig/tools/clamav/etc/freshclam.conf
Code:
UpdateLogFile /var/log/clamav/freshclam.log
NotifyClamd /home/admispconfig/ispconfig/tools/clamav/etc/clamd.conf
create startup script for clamd
( took it from the clamav-daemon package )
Code:
> vi /etc/init.d/clamav-daemon
Code:
#! /bin/sh
#		Written by Miquel van Smoorenburg <miquels@cistron.nl>.
#		Modified for Debian GNU/Linux
#		by Ian Murdock <imurdock@gnu.ai.mit.edu>.
#               Clamav version by Magnus Ekdahl <magnus@debian.org>
#               Heavily reworked by Stephen Gran <sgran@debian.org>
#
### BEGIN INIT INFO
# Provides:          clamav-daemon
# Required-Start:    $syslog
# Should-Start:      
# Required-Stop:
# Should-Stop:       
# Default-Start:     2 3 4 5
# Default-Stop:      0 6
# Short-Description: ClamAV daemon
# Description:       Clam AntiVirus userspace daemon
### END INIT INFO

PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/home/admispconfig/ispconfig/tools/clamav/sbin/clamd
NAME="clamd"
DESC="ClamAV daemon"
CLAMAVCONF=/home/admispconfig/ispconfig/tools/clamav/etc/clamd.conf
SUPERVISOR=/usr/bin/daemon
SUPERVISORNAME=daemon
SUPERVISORPIDFILE="/var/run/clamav/daemon-clamd.pid"
SUPERVISORARGS="--name=$NAME --respawn $DAEMON -F $SUPERVISORPIDFILE"
SUPERVISORPIDDIR="$(dirname $SUPERVISORPIDFILE)"
CLAMUSER="$(grep "^User" ${CLAMAVCONF} | awk '{print $2}')"
CLAMSOCKETDIR="$(dirname $(grep "^LocalSocket" ${CLAMAVCONF} | awk '{print $2}'))"


[ -x "$DAEMON" ] || exit 0
[ -r /etc/default/clamav-daemon ] && . /etc/default/clamav-daemon
. /lib/lsb/init-functions

if [ ! -f "$CLAMAVCONF" ]; then
  log_failure_msg "There is no configuration file for Clamav."
  log_failure_msg "Please either dpkg-reconfigure $DESC, or copy the example from"
  log_failure_msg "/usr/share/doc/clamav-base/examples/ to $CLAMAVCONF and run"
  log_failure_msg "'/etc/init.d/clamav-daemon start'"
  exit 1;
fi

if grep -q "^Example" $CLAMAVCONF; then
  log_failure_msg "Clamav is not configured."
  log_failure_msg "Please edit $CLAMAVCONF and run  '/etc/init.d/clamav-daemon start'"
  exit 0
fi

if egrep -qi "^Foreground[[:space:]]*(yes|true|1)" $CLAMAVCONF; then
  if [ ! -x "$SUPERVISOR" ] ; then
     log_failure_msg "Foreground specified, but $SUPERVISORNAME not found"
     exit 0
  else
     RUN_SUPERVISED=1
  fi
fi

THEPIDFILE="`grep ^PidFile $CLAMAVCONF | awk '{print $2}'`"
[ -n "$THEPIDFILE" ] || THEPIDFILE='/var/run/clamav/clamd.pid'

if [ -z "$RUN_SUPERVISED" ]; then
  if [ -f "$THEPIDFILE" ]; then
    PID=`pidofproc -p $THEPIDFILE $DAEMON`
    RUNNING=$?
  else
    PID=`pidofproc $DAEMON`
    RUNNING=$?
  fi
else
  [ -e "$SUPERVISORPIDFILE" ] && PID=`cat $SUPERVISORPIDFILE`
fi

[ "$PID" = '1' ] && unset PID

case "$1" in
  start)
  [ -x $CLAMSOCKETDIR ] && chown $CLAMUSER $CLAMSOCKETDIR -R
  [ -x $SUPERVISORPIDDIR ] && chown $CLAMUSER $SUPERVISORPIDDIR -R
  OPTIND=1
  if [ -z "$RUN_SUPERVISED" ] ; then
    log_daemon_msg "Starting $DESC" "$NAME "
    start_daemon -p $THEPIDFILE $DAEMON
    ret=$?
  else 
    log_daemon_msg "Starting $DESC" "$NAME (supervised) "
    $SUPERVISOR $SUPERVISORARGS
    ret=$?
  fi
  log_end_msg $ret
  ;;
  stop)
  log_daemon_msg "Stopping $DESC" "$NAME"
  OPTIND=1
  if [ -n "$PID" ]; then
    kill -15 -"$PID"
    ret=$?
    sleep 1
    if kill -0 "$PID" 2>/dev/null; then
      ret=$?
      log_progress_msg "Waiting . "
      cnt=0
      while kill -0 "$PID" 2>/dev/null; do
        ret=$?
        cnt=`expr "$cnt" + 1`
        if [ "$cnt" -gt 15 ]; then
          kill -9 -"$PID"
          break
        fi
        sleep 2
        log_progress_msg ". "
      done
    fi
  else
    if [ -z "$RUN_SUPERVISED" ] ; then
      killproc -p $THEPIDFILE
      ret=$?
    else
      killproc -p $SUPERVISORPIDFILE
      ret=$?
    fi
  fi
  if [ -n "$ret" ]; then
    log_end_msg $ret
  else
    log_end_msg $?
  fi
  ;;
  status)
  case "$RUNNING" in
    0) log_success_msg "$NAME is running."
    ;;
    1) log_warning_msg "$NAME is not running, but pidfile $THEPIDIFILE exists."
    ;;
    3) log_failure_msg "$NAME is not running."
    ;;
    *) log_failure_msg "$NAME is unknown."
    ;;
  esac
  ;;
  restart|force-reload)
  $0 stop
  $0 start
  ;;
  reload-database)
  OPTIND=1
  log_daemon_msg "Reloading database for $DESC" "$NAME"
  killproc -p $THEPIDFILE $DAEMON USR2
  log_end_msg $?
  ;;
  reload-log)
  OPTIND=1
  log_daemon_msg "Reloading log file for $DESC" "$NAME"
  killproc -p $THEPIDFILE $DAEMON 1
  log_end_msg $?
  ;;
  *)
  log_failure_msg "Usage: $0 {start|stop|restart|force-reload|reload-log|reload-database|status}" >&2
  exit 1
  ;;
esac

exit 0
install the script
Code:
> update-rc.d clamav-daemon defaults
run freshclam
Code:
> cd /home/admispconfig/ispconfig/tools/clamav/bin
> ./freshclam

ClamAV update process started at Sun Oct 14 14:07:17 2007
main.cvd is up to date (version: 44, sigs: 133163, f-level: 20, builder: sven)
daily.inc is up to date (version: 4540, sigs: 26673, f-level: 21, builder: ccordes)
start clamd
restart ispconfig
Code:
> /etc/init.d/clamav-daemon start
> /etc/rc.d/init.d/ispconfig_server restart
got eicar testfile from
http://www.eicar.org/anti_virus_test_file.htm
send a mail and checked the log:

Code:
+++ Started at Sun Oct 14 14:25:32 2007
clamd daemon 0.91.2 (OS: linux-gnu, ARCH: i386, CPU: i686)
Running as user admispconfig (UID 116, GID 116)
Log file size limited to 1048576 bytes.
Reading databases from /home/admispconfig/ispconfig/tools/clamav/share/clamav
Not loading PUA signatures.
Loaded 159835 signatures.
Unix socket file /home/admispconfig/ispconfig/temp/clamd
Setting connection queue length to 15
Archive: Archived file size limit set to 10485760 bytes.
Archive: Recursion level limit set to 5.
Archive: Files limit set to 1000.
Archive: Compression ratio limit set to 250.
Archive support enabled.
Algorithmic detection enabled.
Portable Executable support enabled.
ELF support enabled.
Mail files support enabled.
Mail: Recursion level limit set to 64.
OLE2 support enabled.
PDF support disabled.
HTML support enabled.
Self checking every 1800 seconds.
stream 1688: Eicar-Test-Signature FOUND

if you find anything wrong
please feel free to notify me.

Last edited by bernie2004; 14th October 2007 at 14:51.
Reply With Quote
Sponsored Links