In the Developers Forum, there is a script written by George Vieira and modified by djtremors for ISPC that would update CLAMAV definitions automatically (when run regularly by a cron job) and even upgrade the clamav program if there is a new one.
http://www.howtoforge.com/forums/showthread.php?t=7937
I wanted to update my clamav installation to the newest one today, so I tried the script. I had to make a few minor changes for my OS, but it worked fine and upgraded my clamav installation in ispconfig from 0.88.7 to 0.90.
Here is the original script:
Code:
#!/bin/bash
# Version 1.01 by George Vieira
# place your ISPC admin email address here.
ADMIN="admin@wvis1.net"
# place your preferred mirror server here.
MIRROR="http://optusnet.dl.sourceforge.net/sourceforge/clamav"
# -- Nothing to change under this line -----------------------------
LOG="/var/log/clamav-prog-update.log"
APPLICATION_NAME=ispconfig
COMPILE_DIR=`pwd`
error()
{
if [ "$ADMIN" ]; then
echo "Subject:CLAMUPDATE: $1" | sendmail "$ADMIN"
else
echo "Subject:CLAMUPDATE: $1" | sendmail root
fi
}
findversion()
{
VERSION="`host -t txt current.cvd.clamav.net | sed -e 's/"//g' |cut -d ' ' -f 4|cut -d : -f 1`"
[ "$?" != 0 ] && ( echo "Error with finding new version off clamav.net site. URL may have changed!";exit 1;)
echo "DETECTED VERSION -> $VERSION" >>$LOG 2>&1
}
if [ ! -f /var/log/clam-update.log ]; then
touch /var/log/clam-update.log
chown admispconfig /var/log/clam-update.log
chmod 660 /var/log/clam-update.log
fi
STATUS="`/home/admispconfig/ispconfig/tools/clamav/bin/freshclam --log=/var/log/clam-update.log 2>&1`"
NEW="`echo \"$STATUS\" | grep \"WARNING: Local version\" | awk {'print $7'}`"
OLD="`echo \"$STATUS\" | grep \"WARNING: Local version\" | awk {'print $4'}`";
NEWUPDATE="`echo \"$STATUS\" |grep \"Current functionality level\"`"
[ "$NEWUPDATE" ] && NEW="`findversion`"
# If there's a NEW one, updated it.
if [ "$NEW" ]; then
mkdir /root/ispc.updates 2>/dev/null
cd /root/ispc.updates
if [ -d "clamav-$OLD" ]; then
rm -fr "clamav-$OLD"
fi
webget -c $MIRROR/clamav-$NEW.tar.gz >>$LOG 2>&1
RESULT=$?
if [ $RESULT = 0 ]; then
tar xvfz clamav-$NEW.tar.gz >/dev/null 2>&1
cd "clamav-$NEW"
./configure --prefix=/home/adm${APPLICATION_NAME}/${APPLICATION_NAME}/tools/clamav
--sysconfdir=/home/adm${APPLICATION_NAME}/${APPLICATION_NAME}/tools/clamav/etc
--with-user=adm${APPLICATION_NAME} --with-group=adm${APPLICATION_NAME}
--disable-clamav --disable-bzip2 >>$LOG 2>&1 || error "Could not configure ClamAV"
make || error "Could not make ClamAV"
make install || error "Could not install ClamAV"
cp -f COPYING /home/adm${APPLICATION_NAME}/${APPLICATION_NAME}/tools/clamav/
cd ${COMPILE_DIR}
cp -f clamav.conf /home/adm${APPLICATION_NAME}/${APPLICATION_NAME}/tools/clamav/etc/clamav.conf
cp -f freshclam.conf /home/adm${APPLICATION_NAME}/${APPLICATION_NAME}/tools/clamav/etc/freshclam.conf
rm -f /home/adm${APPLICATION_NAME}/${APPLICATION_NAME}/tools/clamav/etc/clamd.conf
cd /home/adm${APPLICATION_NAME}/${APPLICATION_NAME}/tools/clamav/etc/
ln -s clamav.conf clamd.conf
cd ${COMPILE_DIR}
# Bit of a shame we have to restart ALL the ISPC services and not only freshclam
/etc/rc.d/init.d/ispconfig_server restart
error "Updated from OLD=$OLD -> NEW=$NEW"
else
error "Cannot fetch new CLAMAV version, check mirror address"
fi
fi
In order for this to work on my
Fedora Core 4 server, I had to change the sendmail on lines 18 and 20 to "/usr/sbin/sendmail" and to change "webget" on line 56 to "wget". I also had to create a "clamav" user and "clamav" group.
All you do from there is to save the file on your server (I named it "getfreshclam"), chmod it 0755, and run it while you are root.
It checked my old version, checked for newest one, went and got the new install tar and installed it. THANKS GEORGE and DJTREMORS.... I no longer need to wait for an ispconfig update to freshen my clamav installation!
NOTE that on my Fedora Core 3 server, I did not get the same value for $VERSION. I had to change "|cut -d ' ' -f 4" to "|cut -d ' ' -f 3" to get the version number. Even then, the line [ "$NEWUPDATE" ] && NEW="`findversion`" failed to reassign $NEW so the script fails on FC3.
In other words, the script may not work on your OS... you may need to adjust a few things! Use it at your own risk!
Cheers,
RDB
Recent comments
18 hours 29 min ago
23 hours 28 min ago
1 day 54 min ago
1 day 1 hour ago
1 day 3 hours ago
1 day 7 hours ago
1 day 8 hours ago
1 day 10 hours ago
2 days 6 min ago
2 days 1 hour ago