A Script to Automatically Update Clamav Packages

Clamav is an excellent open source multi-platform antivirus program that we use on our systems and projects.  While clamav comes with utilities to update the antivirus definitions, there isn’t a utility to update the engine (instead the antivirus update gives a warning).

The following is a shell script that uses the wget to grab the latest version from Sourceforge, compile, and install it. (The original is at Mac OS X Hints, but needed an update to get the latest clamav version.)

#!/bin/sh
############################################
## Documentation:
## Please modify the url variable to the mirror closest to you.
############################################
url="http://easynews.dl.sourceforge.net/sourceforge/clamav/clamav-"
latest=`lynx -dump "http://www.clamav.net/download/sources" \
| grep "Latest stable release:" | awk '{print $5}' | head -1`
wget $url$latest.tar.gz && \
printf "The latest version of clamav or %s has been downloaded!\n" $latest && \
tar zxvf clamav-$latest.tar.gz && \
cd clamav-$latest
./configure &&
make && \
make install && \
printf "Ok I am updating to the latest virus definitions for \
version %s by running freshclam.", $latest && \
freshclam && \
cd ..

Enjoy!