HOWTO: Control ClamAV from Service Monitor

myH2Oservers

Verified User
Joined
Mar 13, 2006
Messages
246
Location
Netherlands
This howto shows you how to control (start/stop/restart) clamav from the DirectAdmin Service Monitor screen:

This has been tested with Debian 3.1 and works, it is possible that you have to edit the program lines in the control script to make it work with any other OS

Edit:
Code:
nano /usr/local/directadmin/data/admin/services.status
Add:
Code:
clamd=ON

Edit:
Code:
nano /etc/init.d/clamd
Add:
Code:
#!/bin/sh
# Start/stop/restart clamav.

# Start clamav:
clamav_start() {
  if [ -x /usr/local/sbin/clamd ]; then
    echo "Starting clamd daemon:  /usr/local/sbin/clamd"
    /usr/local/sbin/clamd
    # Give clamd a change to make the socket
    sleep 1
    echo "Starting freshclam daemon:  /usr/local/bin/freshclam -d -c 6"
    /usr/local/bin/freshclam -d -c 6
  fi
}

# Stop clamav:
clamav_stop() {
  kill `cat /var/run/clamav/clamd.pid`
  kill `cat /var/run/clamav/freshclam.pid`
}

# Restart clamav:
clamav_restart() {
  clamav_stop
  sleep 1
  clamav_start
}

case "$1" in
'start')
  clamav_start
  ;;
'stop')
  clamav_stop
  ;;
'restart')
  clamav_restart
  ;;
*)
  echo "usage $0 start|stop|restart"
esac

Edit:
Code:
nano /etc/clamd.conf
Change:
Code:
#PidFile /var/run/clamd.pid --> PidFile /var/run/clamav/clamd.pid

Edit:
Code:
nano /etc/freshclam.conf
Change:
Code:
#PidFile /var/run/freshclam.pid --> PidFile /var/run/clamav/freshclam.pid

Code:
mkdir -p var/run/clamav
chown -R clamav:clamav /var/run/clamav
chmod -R 700 /var/run/clamav

Test it:
Code:
/etc/init.d/clamd stop
/etc/init.d/clamd start
If there are no errors:

Code:
/etc/init.d/exim restart

Only need to know how to get ClamAV visible in the "System Information" window.
 
Last edited:
Why do you restart exim at all?

Otherwise, good info. I just added clamd=ON to that file, used RedHat's init script (for CentOS) from clamav source directory and it shows in DA service monitor!
 
You forgot a / with /var/run/clamav directory.

Also you don't need to edit the "/etc/init.d/clamd" file on CentOS 4.6. Just add the dirs and modify the services file and it's okay.
 
Only start and restart buttons are fine in DA,
with stop and reload I am getting:
An error has occurred
none
/sbin/service clamd reload 2>&1

Any idea?
 
Back
Top