HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   Tips/Tricks/Mods (http://www.howtoforge.com/forums/forumdisplay.php?f=19)
-   -   update and switch to clamd on ubuntu 7.04 (http://www.howtoforge.com/forums/showthread.php?t=16204)

bernie2004 14th October 2007 14:48

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.

itsimon 28th April 2008 23:52

Could you post an instruction about how to swith to clamd in other version of linux? e.g Redhat. It will be great if you do that. Cheers.

jbravo 29th April 2008 09:21

There are many posts about it. Please search forum first.
It's easy to find out how to use your distribution supplied clamav daemon (clamd).
Edit
Code:

/home/admispconfig/ispconfig/tools/clamav/bin/clamassassin
file and change CLAMSCAN value to clamd absolute path, for example (SLES10SP1):
Code:

CLAMSCAN=/usr/bin/clamdscan
Also edit ispconfig startup file
Code:

/etc/init.d/ispconfig_server
and comment out freshclam startup/shutdown lines and use your distribution freshclamd daemon.

Above solution (topic author's) did not require to do that - but personally i prefer this one.

bwragg 6th September 2008 00:02

If your trying to get this working on centos check out

http://www.howtoforge.com/forums/showthread.php?t=16723

and

http://www.howtoforge.com/forums/showthread.php?t=12864 Page 2

This helped me fix the above init.d script as it didn't work on centos.

Cheers,

bwragg

Olive 12th June 2010 04:33

Great posts. Thanks for the responses, I used to have the same problems but your solutions worked for me. Great help!

Science Magazine 16th June 2010 16:23

I am new to open source software / operating systems and this forum will be helpful. Thanks for posting the solutions. Is there any link to common issues in Linux?

Science Magazine 17th June 2010 18:08

Any links / tutorials?

SarahDenise 26th June 2010 09:20

Yep! I too need links. I am encountering so much error messages from the server. I am an ojt here in our company and i am assigned to correct this one. :(

B. Osbourne 27th June 2010 06:49

Hi! I tried following the script in this post but I am not getting it :( I just get an error message.

falko 27th June 2010 13:55

What's the exact error message?


All times are GMT +2. The time now is 17:46.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.