ClamAV - start on boot?

Best practice information from Scalix users relating to integration of Scalix with other products.

Moderator: ScalixSupport

Ruthiness
Posts: 79
Joined: Tue Nov 13, 2007 8:11 pm

ClamAV - start on boot?

Postby Ruthiness » Thu Dec 27, 2007 4:54 pm

Question for anyone who is using ClamAV

I have ClamAV all working from command line but want everything to start on boot.

Do I simply setup a link in /etc/rc3.d to the clamd and clamav-milter startup scripts?
I suppose clamd needs to start first?

Since I ran clamav-milter to create the socket once to create it during setup- do I need to run it on boot to create the socket again and if so, do I need to modify the startup script per my own domain name etc?

Why are these questions not answered in any of the docs - both the Scalix Knowledgebase or the ClamAV pdf?

TIA

techsharp
Posts: 436
Joined: Tue Jan 16, 2007 9:01 pm

Postby techsharp » Thu Dec 27, 2007 5:01 pm

Here is the clamav script I use to start and stop clamd and freshclam. You may have to edit it some to match your environment.

Once in place add it to chkconfig and then you should be all set. Let me know how it works out for you.

#!/bin/bash
#
# clamav This shell script takes care of starting and stopping
# clamav.
#
# chkconfig: - 61 39
# description: Clamav is a is a GPL anti-virus toolkit for UNIX.
# processname: clamav
# config: /etc/clamd.conf
# pidfile: /var/run/clamav/clamd.pid

# Source function library.
. /etc/rc.d/init.d/functions

# Source clamav configureation.
if [ -f /etc/sysconfig/clamav ] ; then
. /etc/sysconfig/clamav
fi

[ -f /usr/sbin/clamd ] || exit 0

RETVAL=0
prog="clamd"

start() {
# Start daemons.

echo -n $"Starting $prog: "
daemon /usr/sbin/clamd
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/clamd

if [ "$CLAMAV_MILTER" == "yes" ] ; then
echo -n $"Starting clamav-milter: "
daemon clamav-milter --config-file=/etc/clamd.conf \
--max-children=10 \
--force-scan \
--quiet \
--dont-log-clean \
--noreject \
-obl local:/var/run/clamav/clmilter.socket
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/clamav-milter
fi

echo -n $"Starting freshclam: "
touch /var/run/clamav/freshclam.pid
chown clamav:clamav /var/run/clamav/freshclam.pid
if [ -x /usr/bin/selinuxenabled ] && /usr/bin/selinuxenabled; then
/sbin/restorecon /var/run/clamav/freshclam.pid
fi
daemon --check freshclam \
/usr/bin/freshclam -d -c 24 \
--quiet \
-p /var/run/clamav/freshclam.pid \
--daemon-notify=/etc/clamd.conf
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/freshclam

return $RETVAL
}

stop() {
# Stop daemons.
echo -n $"Shutting down $prog: "
killproc clamd
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/clamd
if test -f /var/lock/subsys/clamav-milter; then
echo -n $"Shutting down clamav-milter: "
killproc clamav-milter
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/clamav-milter
fi
if test -f /var/run/clamav/freshclam.pid; then
echo -n $"Shutting down freshclam: "
killproc freshclam
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/run/clamav/freshclam.pid
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/freshclam
fi
return $RETVAL
}

reload() {
stop
start
}

# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
reload)
reload
RETVAL=$?
;;
restart)
stop
start
RETVAL=$?
;;
condrestart)
if [ -f /var/lock/subsys/clamd ]; then
stop
start
RETVAL=$?
fi
;;
status)
status clamd
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|condrestart|status}"
exit 1
esac

exit $RETVAL

Ruthiness
Posts: 79
Joined: Tue Nov 13, 2007 8:11 pm

Postby Ruthiness » Thu Dec 27, 2007 6:04 pm

Thanks much...

It seems I already had a startup in /etc/rc2.d for clamav-milter. Do I just remove that now and have it all start from your script (which I named clamd)?

so right now I have your script which chkconfig added to /etc/rc2.d for the startup and /etc/rc3.d for the kill script. I guess clamav-milter was already there?

I tested your script and it starts and stops clamav just fine.

Thanks!

techsharp
Posts: 436
Joined: Tue Jan 16, 2007 9:01 pm

Postby techsharp » Fri Dec 28, 2007 10:19 am

Ruthiness -

Yeah check to see if the script takes care of clamav-milter - we do not have that so I am not sure, if it does not then just do a chkconfig on it and it will do the trick.

Glad it worked out for you!


Return to “Third Party Integration”



Who is online

Users browsing this forum: No registered users and 2 guests