#!/usr/bin/perl # # Script for KasperskyLab AVP by Andy Wallace # # Put a call to this in your root crontab to run it every day. e.g. # 00 20 * * * /usr/local/bin/getupdate.pl use Net::FTP; # in the libnet package - you may have to get it from CPAN - I did. # Directory to download into $DIR="/usr/local/AvpLinux"; # Get current time and date ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime(time); # I just want this stuff so I can save each daily.zip as a different filename with a date attached, so I know I haven't missed any. Format is dailyddmmyy.zip (yes I'm British), so I need to make a few changes. # Jan = 0, so add 1 to $mon $mon++; if ($mon<10) { $mon="0$mon"; } # Days of month are 1-31, so that's OK if($mday<10) { $mday="0$mday"; } # gmtime thinks this year is 100! At least in my version of Perl...so don't use this script after 2099 :-) $year -= 100; if($year<10) { $year="0$year"; } # Connect to FTP server and download daily.zip $ftp = NET::FTP->new("ftp.kasperskylab.ru", Passive, 1); $ftp->login("ftp", someone\@somewhere.com"); $ftp->cwd("/bases"); $ftp->binary; $ftp->get("daily.zip", "$DIR/daily$mday$mon$year.zip"); $ftp->quit; # Check it turned up OK, if so unzip it, if not send an email if (-e "$DIR/daily$mday$mon$year.zip") { system("/usr/bin/unzip -o -qq $DIR/daily$mday$mon$year.zip -d $DIR"); } else { system("/bin/mail -s \"Antivirus daily update failure!\" root"); } # Now restart AVP daemon to load updated virus library system("/usr/local/AvpLinux/AvpDaemon -k"); system("/usr/local/AvpLinux/AvpDaemon -* /var/amavis"); # End of perl script