Home|Cudeso|Linux|*NIX / BSD|Misc|
 

Anti Virus download

Contents

1. Introduction

2. Code

3. Configuration





1. Introduction

McAfee Anti Virus offers has an automatic download-facility to update your DAT-files. When you're managing several hosts this means that all of them are download around 1.7 megs a time. You can save bandwidth an stay in control of the update process by using this script.

2. Code

Download code here.
#
# $Id: get_virus_update,v 0.1 2002/10/04 Exp $
#
# the software is GNU licensing dependent.
# Copyright (C) 2002, cudeso.be http://linux.cudeso.be
#
# This program is free software; you van redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTLY; without even the implied warranty of
# MERCHANTABILITY of FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General License for more details.

# First declare some variables

declare -i McDat

# File-locations
WGET=/usr/bin/wget
LOGGER=/usr/bin/logger
DRIFT_FILE=/home/AntiVirus/get_virus_update.drift
OUTPUT_LOCATION=/home/AntiVirus/
OUTPUT_CURRENT_LOCATION=/home/AntiVirusCurrent/

# Variables
WGET_OPTIONS="-q --tries=3"
McURL=http://download.mcafee.com/products/licensed/superdat/english/intel/
# or ftp://ftp.nai.com/pub/antivirus/superdat/intel/ 
# thanks to Gareth Evans
McDat=$(cat $DRIFT_FILE)
McDatExtra=.exe       # changed from McDatExtra=xdat.exe (Gareth Evans)
McDatLeadIn=sdat      # added 15-jul-04 by Gareth Evans
McUpdateFile=$McDatLeadIn$McDat$McDatExtra    # changed from McUpdateFile=$McDat$McDatExtra by Gareth Evans

http_proxy=proxy.mydomain.com:3128
export http_proxy

cd $OUTPUT_LOCATION


# Build the execute string and do it
res="$WGET $WGET_OPTIONS $McURL$McUpdateFile"
($res)


# Did we get a file?
if (test -f $McUpdateFile)
then    # If so, remove the old one
   let FutureMcDat=(McDat + 1)   # and update the driftfile
   let OldMcDat=(McDat -1)
   echo $FutureMcDat > $DRIFT_FILE
   rm -f $OldMcDat$McDatExtra
   $LOGGER -p user.notice -t VIRUS_UPDATE "====== New dat-file $McUpdateFile ========="
   cp -f $McUpdateFile $OUTPUT_CURRENT_LOCATION/latestdat.exe
else    # We did not find anything
   echo "" > /dev/null    # sit back
fi

3. Configuration

Configuratin is very easy.

The variables WGET and LOGGER are the paths to the binaries. Change them to your system-settings.

DRIFTFILE is the file that holds the version number of the last downloaded DAT-file. OUTPUT_LOCATION is the location where the DAT-files needs to be saved. When there's a file downloaded, it will copy this file to the location specified in OUTPUT_CURRENT_LOCATION and rename the dat-file to latestdat.exe (OUTPUT_CURRENT_LOCATION is prefereably a directory that's shared by Samba and writable - for the temporary-files). This way, just prepare a sheduled batch-file on your Windows-machine that gets the latest datfiles.
\\MySambaServer\AntiVirus\latestdat.exe /SILENT
Place the script in your crontab and make sure the cron-user has write/read access to the directory specified in OUTPUT_LOCATION.

Also, check that you have at least a starting-driftfile to get it going. Create one like this
echo "4323" > DRIFT_FILE (replace with the name of your driftfile)
(thanks to Gareth Evans)
Copyleft 2002-2007 - cudeso.bewebmaster@cudeso.betop