[svlug] request to svlug members

Nick Austin nick at digitalpipe.net
Sun Oct 19 22:45:29 PDT 2003


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Mon, 20 Oct 2003, nirmala wrote:

<..snip..>
> 
> I want all my clients to automatically upgrade the antivirus when it is
> connecting to the SMS server.

Sounds like your really looking for a login script if your trying to 
update windows clients. For Linux you can use one of the many 
software update and management packages available, such as autoupdate, 
cfengine, up2date, etc.

You can keep your virus definitions updated from Mcafee with a simple 
script like this:

#!/bin/sh

DESTPATH="/usr/local/uvscan/def-updates/"
VUSCANHOME="/usr/local/uvscan/"
#export http_proxy="http://squid:3128"
#export ftp_proxy="http://squid:3128"
PATH=$PATH:/usr/bin:/bin:/usr/local/bin:/usr/local/sbin:/usr/sbin:/sbin
debug=1

function debug_print() {

if [ "$debug" == "1" ]; then
	echo -e "$1"
fi

}

function check_md5 () {
	debug_print "DEBUG: in check_md5"
	computed_md5=`md5sum $DESTPATH$updatename | awk '{print $1}'`
	if [ "$updatemd5" == "$computed_md5" ]; then
		debug_print "\tMD5check: Pass"
		debug_print "\t\tComputed: $computed_md5"
		debug_print "\t\tStored  : $updatemd5"
		return 0
	else
		debug_print "\tMD5check: Fail"
		debug_print "\t\tComputed: $computed_md5"
		debug_print "\t\tStored  : $updatemd5"
		return 1
	fi
}

function parse_ini () {
	UPDATE_INI=$1
	debug_print "DEBUG: in parse_ini"
	updatename=`cat $UPDATE_INI | grep -A7 \\\[ZIP\\\] | grep FileName\\= | sed s/FileName\\=//g |  tr -d '\n\r'`
	updatepath=`cat $UPDATE_INI | grep -A7 \\\[ZIP\\\] | grep FilePath\\= | sed s/FilePath\\=//g | tr -d '\n\r'`
	updatemd5=`cat $UPDATE_INI | grep -A7 \\\[ZIP\\\] | grep MD5\\= | sed s/MD5\\=//g | tr -d '\n\r'`
	url="ftp://ftp.mcafee.com$updatepath$updatename"
	debug_print "DEBUG: Parsed URL: $url"

}

download_file() {
	source=$1
	dest=$2
	wget_temp=`mktemp /tmp/wget_status.XXXXXXX`
	debug_print "DEBUG: in download_file"
	debug_print "\tURL : $source"
	debug_print "\tdest: $dest"
	wget -t 20 --waitretry=20 $source -O $dest -o $wget_temp
	wget_status=$?
	if [ $wget_status -ne 0 ]; then
		echo "FATAL: failed to wget $source"
		echo "wget exited with status $wget_status"
		echo "***** WGET LOG FOLLOWS *****"
		cat $wget_temp
		rm -f $wget_temp
		exit 1
	fi
	rm -f $wget_temp
	debug_print "\tDEBUG: download_file success"
	return 0
}

UPDATE_INI=`mktemp /tmp/update.ini.XXXXXX`
if [ -z $UPDATE_INI ]; then
	echo "FATAL: UPDATE_INI is null"
	exit 1
fi

download_file ftp://ftp.mcafee.com/pub/datfiles/english/update.ini $UPDATE_INI
parse_ini $UPDATE_INI
rm -f $UPDATE_INI

if [ -f $DESTPATH$updatename ]; then
	if ! check_md5; then
		echo "NOTE: Old update file exists, but MD5 sum is wrong!"	
		need_update=1
	else
		debug_print "NOTE: No new update needed"
		exit 0
	fi
else
	need_update=1
fi

if [ "$need_update" == "1" ]; then
	rm -f $DESTPATH/*
	debug_print "NOTE: Update needed downloading: $url"
	download_file $url $DESTPATH$updatename
	if [ ! check_md5 ]; then
		echo "FATAL: Download failed md5sum wrong!!"
		exit 1
	else
		debug_print "NOTE: Download complete"
		debug_print "NOTE: Extracting files"
		unzip -o -d $VUSCANHOME $DESTPATH$updatename 2>&1 > /dev/null
		if [ $? -eq 0 ]; then
			debug_print "NOTE: File extraction success"
			exit 0
		else
			echo "FATAL: Zip file extraction failed!"
			exit 1
		fi
	fi
fi


Good Luck!


- -- 
Nick Austin
Systems Administrator 

The Fantastic Corporation®
2121 South El Camino Real
4th Floor
San Mateo, CA 94403
United States
Tel. +1-650-356-2114 (direct)
     +1-650-356-2100 (switchboard)
Fax  +1-650-574-6901
www.fantastic.com <http://www.fantastic.com/>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)
Comment: Made with pgp4pine 1.76

iD8DBQE/k3aCHmiYOiU4APYRAm9AAKDWimKA6AjH+ojFBZX9gOob0eFD4ACgzkrb
VQw4PfH4/fIv7QjpyXerTy0=
=zdgc
-----END PGP SIGNATURE-----






More information about the svlug mailing list