
If you are running McAfee anti-virus on your Linux box, this is the better script I've found on auto-updating from a cron job. Its not mine, its from Jorge Becerra, but its worth listing since I had a real hard time finding it on search engines. Just customize the first section of the script with your location of files, and schedule it to run daily through cron. Works much better than the other version I've seen, which regularly never exited properly, then deleted my dat files without replacing them, therefore stopping all email from getting through.
But this one works great. It will email you the log whenever it updates. It won't download and process unless there is a new version to be installed. Works great!
#!/bin/bash
# dat_update version 0.01 20000502
# Jorge Becerra jorgeATsodatec.org
#
# Feel free to use the script and distribute
# if you found any mistake, please email the author
# Where to get the nai update from
FTPDIR="ftp://ftp.nai.com/pub/antivirus/datfiles/4.x"
MAILTO="root"
# Location of uvscan files
UVSCANDIR="/usr/local/uvscan"
UVSCAN="$UVSCANDIR/uvscan"
# Location of files (check on your distribution) - maybe use for that whereis.
LYNX="/usr/bin/lynx"
GREP="/bin/grep"
CUT="/usr/bin/cut"
WGET="/usr/bin/wget"
CP="/bin/cp"
RM="/bin/rm"
ECHO="/bin/echo"
MKDIR="/bin/mkdir"
CAT="/bin/cat"
TAR="/bin/tar"
MAIL="/bin/mail"
#
# You not need to change from here
# At least if you don' know exactly what means :-)
#
#Verify files needed
if [ ! -x $GREP ] ; then
$ECHO "grep not installed"
exit
fi
if [ ! -x $CUT ] ; then
$ECHO "cut not installed"
exit
fi
if [ ! -x $UVSCAN ] ; then
$ECHO "uvscan not installed on: $UVSCAN"
exit
fi
if [ ! -x $LYNX ] ; then
$ECHO "lynx not installed"
exit
fi
cd $UVSCANDIR
if [ ! -d tmp ]; then
$MKDIR tmp
fi
cd tmp
# Get the page from nai
$LYNX -dump "$FTPDIR" > nai.ls
# Extract filename of last version
$CAT nai.ls | $GREP 'ftp://ftp.nai.com' nai.ls | $GREP .tar | $CUT -c 7- >nai.fn
# Get current version
VERSION_CURRENT=`cut -d - -f 2 nai.fn | cut -d . -f 1`
if [ -z "$VERSION_CURRENT" ] ; then
$ECHO "can' get uvscan current version"
exit
fi
# Get version installed
VERSION_USED=`$UVSCAN --version | $GREP "Virus data file" | $CUT -d" " -f4 | $CUT -c2-`
$ECHO "Current : $VERSION_CURRENT"
$ECHO "Used : $VERSION_USED"
if [ -z "$VERSION_USED" ] ; then
$ECHO "uvscan not installed"
exit
fi
if [ "$VERSION_USED" -ge "$VERSION_CURRENT" ] ; then
$ECHO "Is up to date"
exit
fi
$ECHO "need to update"
DATNAME="dat-${VERSION_CURRENT}"
pwd
$WGET -c -o wupdate.log $FTPDIR/$DATNAME.tar
if [ $? -eq 0 ]; then
if [ ! -d extract ] ; then
$MKDIR extract
fi
$RM -f extract/*
$TAR --extract --directory extract < $DATNAME.tar
if [ ! $? -eq 0 ]; then
$ECHO "ERROR extracting"
exit
fi
$RM -f extract/*.exe
$CP -f extract/* $UVSCANDIR/
$RM -f extract/*
$MAIL -s "uvscan dat updated to version: ${VERSION_CURRENT}" $MAILTO <wupdate.log
fi
$RM -f wupdate.log