update and switch to clamd on ubuntu 7.04

Discussion in 'Tips/Tricks/Mods' started by bernie2004, Oct 14, 2007.

  1. bernie2004

    bernie2004 New Member

    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 <[email protected]>.
    #		Modified for Debian GNU/Linux
    #		by Ian Murdock <[email protected]>.
    #               Clamav version by Magnus Ekdahl <[email protected]>
    #               Heavily reworked by Stephen Gran <[email protected]>
    #
    ### 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: Oct 14, 2007
  2. itsimon

    itsimon New Member

    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.
     
  3. jbravo

    jbravo Member

    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.
     
  4. bwragg

    bwragg New Member

  5. Olive

    Olive New Member

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

    Science Magazine New Member

    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?
     
  7. Science Magazine

    Science Magazine New Member

    Any links / tutorials?
     
  8. SarahDenise

    SarahDenise New Member

    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. :(
     
  9. B. Osbourne

    B. Osbourne New Member

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

    falko Super Moderator Howtoforge Staff

    What's the exact error message?
     
  11. rockstar9840

    rockstar9840 New Member

    Nice post and really helpful. Thanks guys for sharing.

    But I need some tutorials because I want to know more.

    Can anyone explain it to me?
     

Share This Page