
4th November 2006, 23:59
|
|
Senior Member
|
|
Join Date: Apr 2006
Location: Sydney
Posts: 236
Thanks: 0
Thanked 6 Times in 6 Posts
|
|
freshclam updated script
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
Last edited by djtremors; 11th December 2006 at 10:54.
|

5th November 2006, 13:30
|
|
Super Moderator
|
|
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 19,805
Thanks: 285
Thanked 1,805 Times in 1,357 Posts
|
|
Looks nice. I will test it on my installation.
|

11th December 2006, 10:55
|
|
Senior Member
|
|
Join Date: Apr 2006
Location: Sydney
Posts: 236
Thanks: 0
Thanked 6 Times in 6 Posts
|
|
Update 1.01
Updated the script to handle "functional level" version messages and fetches the latest version from ClamAVs DNS.
don't forget to change the email and mirror to suite.
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT +2. The time now is 14:01.
|
Recent comments
1 day 5 hours ago
1 day 10 hours ago
1 day 10 hours ago
1 day 11 hours ago
1 day 12 hours ago
1 day 14 hours ago
1 day 16 hours ago
1 day 16 hours ago
1 day 17 hours ago
1 day 18 hours ago