#!/usr/local/bin/perl # # Much improved update Script # instead of getting all days the whole update we suck and parse the # update.ini - file. # # Beat Rubischon $SERVER="ftp://ftpeur.nai.com"; # ftp-server $INIFILE="/pub/antivirus/datfiles/4.x/update.ini"; # path of ini $UVSCANBIN="/opt/bin/uvscan"; # binary or wrapper $UVSCANDIR="/opt/uvscan"; # directory $TEMP="/opt/amavis/tmp"; # temp directory $datupd="no"; $engupd="no"; open IN, "wget -q -O - ".$SERVER.$INIFILE." |"; $section=""; while() { chomp; tr/\r//d; if(/^\[.*\]/) { ($section)=(m/^\[(.*)\]/); } if ($section eq "ZIP") { if (/^DATVersion=/) { ($datftp)=(m/^DATVersion=(.*)$/) } if (/^FileName=/) { ($datfile)=(m/^FileName=(.*)$/) } if (/^FilePath=/) { ($datpath)=(m/^FilePath=(.*)$/) } } if ($section eq "Engine-LINUX") { if (/^EngineVersion=/) { ($engftp)=(m/^EngineVersion=(.*)$/) } if (/^FileName=/) { ($engfile)=(m/^FileName=(.*)$/) } if (/^FilePath=/) { ($engpath)=(m/^FilePath=(.*)$/) } } } close IN; open IN, $UVSCANBIN." --version |"; while() { chomp; if (/^Scan engine /) { ($engcur)=(m/Scan engine v(.*) for Linux./); $engcur=~tr/\.//d; } if (/^Virus data file /) { ($datcur)=(m/Virus data file v(.*) created/); $engcur=~tr/\.//d; } } close IN; if ($datftp gt $datcur) { $datupd="yes"; } if ($engftp gt $engcur) { $engupd="yes"; } print "engine: current $engcur ftp $engftp update $engupd\n"; print "dat-version: current $datcur ftp $datftp update $datupd\n\n"; print "dat-file: ".$SERVER.$datpath.$datfile."\n"; print "engine-file: ".$SERVER.$engpath.$engfile."\n\n"; if ($engupd eq "yes") { system "wget -O ".$TEMP."/".$engfile." ".$SERVER.$engpath.$engfile; system "unzip -d ".$UVSCANDIR." -o ".$TEMP."/".$engfile; } if ($datupd eq "yes") { system "wget -O ".$TEMP."/".$datfile." ".$SERVER.$datpath.$datfile; system "unzip -d ".$UVSCANDIR." -o ".$TEMP."/".$datfile; } if (engupd eq "yes" or $datupd eq "yes") { system $UVSCANBIN." --version"; }