hey all,
in a previous post somewhere I had a script mentioned which not only auto updates clamav but also checks if there's a new version and downloads/compiles and restarts whatever services.
I have now done it for ISPC if you guys want to try it out. You have to use the crontab option instead of the daemon to do updates as the script does it and also checks for binary updates.
I've done this to mine and so far it appears to work fine. The only time it ever broke was when the mirror no longer hosted it and i got an email notice about it to change the mirror setting.
Parameters needed to set are the ADMIN and the MIRROR variables, the rest are fine.
This beats waiting for a new ISPC to get an update or if your happy to keep your ispc version at least you get binary updates too.
PHP Code:
#!/bin/bash
# Version 1.01 by George Vieira
# place your ISPC admin email address here.
ADMIN="admin@yourdomain.com"
# 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
Recent comments
4 hours 24 min ago
11 hours 5 min ago
14 hours 55 min ago
16 hours 34 min ago
1 day 1 hour ago
1 day 10 hours ago
1 day 11 hours ago
1 day 14 hours ago
1 day 19 hours ago
1 day 19 hours ago