#1  
Old 4th November 2006, 23:59
djtremors djtremors is offline
Senior Member
 
Join Date: Apr 2006
Location: Sydney
Posts: 236
Thanks: 0
Thanked 6 Times in 6 Posts
Default 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`"
        
"$?" != ] && ( echo "Error with finding new version off clamav.net site. URL may have changed!";exit 1;)

        echo 
"DETECTED VERSION -> $VERSION" >>$LOG 2>&1

}

if [ ! -
/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 [ -"clamav-$OLD" ]; then
                rm 
-fr "clamav-$OLD"
        
fi

        webget 
-c $MIRROR/clamav-$NEW.tar.gz >>$LOG 2>&1
        RESULT
=$?

        if [ 
$RESULT ]; 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>&|| 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 
-/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.
Reply With Quote
  #2  
Old 5th November 2006, 13:30
till till is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 19,805
Thanks: 285
Thanked 1,805 Times in 1,357 Posts
Default

Looks nice. I will test it on my installation.
__________________
Till Brehm
--
http://www.projektfarm.com/en/
Reply With Quote
  #3  
Old 11th December 2006, 10:55
djtremors djtremors is offline
Senior Member
 
Join Date: Apr 2006
Location: Sydney
Posts: 236
Thanks: 0
Thanked 6 Times in 6 Posts
Default 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.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Windows PHP script problem richj1232003 Programming/Scripts 1 2nd November 2006 10:01
Ftp User Creation Script pushparaj Programming/Scripts 4 27th September 2006 21:15
Script questions && Gentoo version hagel Feature Requests 4 7th May 2006 14:19
PERL script help... simple issue i think gjcomputer General 3 14th March 2006 10:49
Executing ICON script lawson Programming/Scripts 3 28th December 2005 21:51


All times are GMT +2. The time now is 14:01.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Sponsored Links: Unified Communications: Thoughts, Strategies and Predictions
Join the discussion.
www.seamlessenterprise.com

IP Convergence
Integrate your wireless and wireline networks.
Learn how from the experts at Sprint.
www.seamlessenterprise.com

Wireless & Wireline Integration
Thoughts, strategies and solutions: join the discussion
www.seamlessenterprise.com

Unified Communications 2009
Join the Discussion. Now.
www.seamlessenterprise.com

Red Hat Virtual Experience - a free virtual event. Dec. 9th