Строка из скрипта
Код: Выделить всё
if ($file =~ /update/ && $path ne $bases_path."/eset_upd") {system("$path/lib/7z e -y $path/update.ver")};Код: Выделить всё
if ($file =~ /update/ && $path ne $bases_path."/eset_upd") {system("$path/lib/7z e -y $path/update.ver")};Спасибоlumen писал(а):Используйте 7z вместо unrar.
Строка из скриптаКод: Выделить всё
if ($file =~ /update/ && $path ne $bases_path."/eset_upd") {system("$path/lib/7z e -y $path/update.ver")};
Код: Выделить всё
#!/usr/bin/perl
# path to store updates
$PATH="/home/nod";
# wget
$WGET="/usr/local/bin/wget";
# username/password for updates registered users
$LOGIN='login';
$PASS='passwd';
# URL for updates
$URL_UPD='http://um18.eset.com/';
#$URL_UPD='';
$URL_UPD =~ s/\/$//;
$URL_UPD =~ m/(.*:\/\/)(.*?)(\/.*)/;
$site = "$1$2";
if ($site =~ m//) {
  print "Enter correct URL\n";
    return;
}
unlink("$PATH/update.ver","$PATH/update.tmp");
download($PATH,"$URL_UPD/eset_upd/update.ver",$LOGIN,$PASS);
system("/usr/local/bin/7z e -y $PATH/update.ver -o$PATH/");
rename("$PATH/update.ver","$PATH/update.tmp");
$ver = "$PATH/update.tmp";
$vers = "$PATH/update.ver";
open(VER, "< $ver") or die "Couldn't open $ver for reading: $!\n";
open(VERS, "> $vers") or die "Couldn't open $vers for writing: $!\n";
%files = ();
%urls = ();
$end = 0;
while (defined($line = <VER>) )
    {
      chomp $line;
        if ($line =~ /COMPATLIST/) {
            $end = 1;
        }
        if ($end == 0) {
          ($par,$val)=split /=/, $line;
          $val = substr($val, 0, -1);
          if ($par =~ /file/ ) {
            $name = '/'.$val;
            $name =~s/\/.*\///;
            $furl="$URL_UPD$val";
            $line="file=$name";
           }
          if ($par =~/size/ ) {
            $size = $val;
            $files{$name} = $size;
            $urls{$name} = "$furl";
           }
       }
print VERS "$line\r\n";
}
print "\n";
close(VER);
close(VERS);
                                                                                                                                                              
foreach $f (keys %files) {
  if ((-s "$PATH/$f") != $files{$f}){
    if (mylang($f) != 1) {
      $size = (-s "$PATH/$f");
      print "Not present --> $PATH/$f\t$f\t$files{$f} ---> $size\n";
      unlink("$PATH/$f");
      download($PATH,$urls{$f},$LOGIN,$PASS);
    }
   } else { # print "    Present --> $PATH/$f\t$f\t$files{$f}\n";
   }
}
                                                                                                                                                              
chmod(0644,"$PATH/*");
                                                                                                                                                              
sub download()
{
  my ($path, $url, $login, $pass) = @_;
  system("$WGET -P $path --http-user=$login --http-password=$pass $url");
}
                                                                                                                                                              
sub mylang()
{
  my ($filename) = @_;
  if (index($filename,"ukr") != -1) {return 1;}
  if (index($filename,"bgr") != -1) {return 1;}
  if (index($filename,"chs") != -1) {return 1;}
  if (index($filename,"cht") != -1) {return 1;}
  if (index($filename,"csy") != -1) {return 1;}
  if (index($filename,"dan") != -1) {return 1;}
  if (index($filename,"deu") != -1) {return 1;}
  if (index($filename,"esn") != -1) {return 1;}
  if (index($filename,"fin") != -1) {return 1;}
  if (index($filename,"fra") != -1) {return 1;}
  if (index($filename,"hrv") != -1) {return 1;}
  if (index($filename,"hun") != -1) {return 1;}
  if (index($filename,"ita") != -1) {return 1;}
  if (index($filename,"nld") != -1) {return 1;}
  if (index($filename,"nor") != -1) {return 1;}
  if (index($filename,"plk") != -1) {return 1;}
  if (index($filename,"ptb") != -1) {return 1;}
  if (index($filename,"rom") != -1) {return 1;}
  if (index($filename,"sky") != -1) {return 1;}
  if (index($filename,"slv") != -1) {return 1;}
  if (index($filename,"sve") != -1) {return 1;}
  if (index($filename,"trk") != -1) {return 1;}
  if (index($filename,"_nt64_") != -1) {return 1;}
  if (index($filename,"_64_") != -1) {return 1;}
  return 0;
}
Ну и зачем они мне например на датском? Да и еще для 64 битной версии нода???server801 писал(а):эти "многовесящие компоненты" - это обновки самой программы, то есть установщика.
Код: Выделить всё
#!/usr/bin/perl -w
###################################################################
# NOD32 version 3 update mirror creator with auto keys searching  #								  #
# Created by Cmyker aka Igorek Vokar. 				  #
# Send bug reports and thanks to cmyk777@gmail.com		  #
# Greets to my girlfriend Alenka and VITYAN666			  #
###################################################################
use FindBin;
use lib $FindBin::Bin;
use lib $FindBin::Bin . "/lib";
use LWP::UserAgent;
use Data::Dumper;
use File::Path;
use Time::localtime;
use lib::keys;
use strict;
our $bases_path = "/usr/local/nod"; #Path for downloaded bases
our $nolog = 0; #Write log? 0 - yes, 1 - no
our $upd_file = "update.ver";
our $path = $FindBin::Bin;
our ($username, $password);
start();
sub start {
    my $status = shift(@_);
    my $result = 1;
    open(AUTHFILE, "$path/lib/nod32.auth") or $result = 0;
    if (!$result) {logging("Can't open authfile nod32.auth"); keys::start(); start(); return;}
    $username = <AUTHFILE>;
    $username =~ s/username=//;
    chomp $username;
    $password = <AUTHFILE>;
    $password =~ s/password=//;
    chomp $password;
    if (!$status) {init()};
}
sub init {
    my $downl_result = 1;
    if (-e "$path/$upd_file") { 
	my (@hosts, %updver, %updver_old);
    	my ($hosts_ref, $updver_ref_old) = read_updatever("$upd_file"); @hosts = @$hosts_ref;
	for (my $i = 0; $i <= $#hosts; $i++) {
    	    if ($downl_result) {
		logging("Checking $hosts[$i]");
		rename("$path/$upd_file", "$path/$upd_file.old") || die "Can't rename $upd_file: $!";
		my ($hosts_ref, $updver_ref_old) = read_updatever("$upd_file.old"); %updver_old = %$updver_ref_old;
	    }
    	    my $server = $hosts[$i];
	    $downl_result = downl_file("/update.ver", $server, $path);
	    if (!$downl_result) {next};
	    my ($hosts_new_ref, $updver_ref) = read_updatever("$upd_file"); %updver = %$updver_ref;
	    check_files_ver(\%updver_old, \%updver, $server);
	}
    } else {
	my $server = "http://update.eset.com/eset_upd/";
	downl_file("/update.ver", $server, $path);
	if (!(-d "$bases_path/download/engine3")) { 
	    mkpath("$bases_path/download/engine3", 0, 0777) || die "Can't create dir $bases_path/download/engine3: $!\n";
	    mkpath("$bases_path/download/engine3ess", 0, 0777) || die "Can't create dir $bases_path/download/engine3ess: $!\n";	    
	    mkpath("$bases_path/eset_upd", 0, 0777) || die "Can't create dir $bases_path/eset_upd: $!\n";	    
	    my ($hosts_new_ref, $updver_ref) = read_updatever("$upd_file"); my %updver = %$updver_ref;
	    my $server = "http://update.eset.com/";
	    for my $filename ( keys %updver ) {
		$downl_result = downl_file($updver{$filename}{file}, $server, $bases_path);	
	    }
	}
	read_updatever("$upd_file");
	init();
    }
}
sub check_files_ver {
    my %updver_old = %{shift(@_)};
    my %updver = %{shift(@_)};
    my $server = shift(@_);
    $server =~ s/\/eset_upd\///;
    my $updver_flag;
    for my $filename ( keys %updver ) {
	if (!defined($updver_old{$filename}{file}) or !defined($updver{$filename}{file})) {
	    next;
	}
	my $localfilesize = (-s $bases_path.$updver{$filename}{file});
	my $serverfilesize = $updver{$filename}{size};
	if (($updver{$filename}{version}) > ($updver_old{$filename}{version}) 
	or !(-e $bases_path.$updver{$filename}{file}) or ($localfilesize != $serverfilesize
	&& $updver{$filename}{version} > $updver_old{$filename}{version})) {
	    $updver_flag = 1;
	    logging("Downloading $updver{$filename}{file}($updver{$filename}{version}) old version ($updver_old{$filename}{version}) from $server");
	    downl_file($updver{$filename}{file}, $server, $bases_path);
	}
    }
    if ($updver_flag) {
	downl_file("/update.ver", $server."/eset_upd/", $bases_path."/eset_upd");
    } else {
	logging("Local bases copy is up to date");
    }
}
sub downl_file {
    my $file = shift(@_);    
    my $server = shift(@_);
    $server =~ s/\/$//;
    my $path = shift(@_);
    my $ua = LWP::UserAgent->new;
    $ua->timeout(10);
    my $req = HTTP::Request->new(GET => $server.$file);
    $req->authorization_basic($username, $password);
    my $res=$ua->request($req);
    open(F, ">$path/$file");  
    binmode F;
    print F $res->decoded_content;
    close F;
    my $status=$res->status_line;
    if ($status =~ /401/) {logging("Auth to $server failed searching for new key"); keys::start(); start("1"); return 0;}
    if ($status =~ /500 read/) {logging("Connection timeout to $server while checking $file");return 0;}
    if ($status =~ /500 Cannot/) {logging("Error writing $file: $!");return 0;}
    if ($file =~ /update/ && $path ne $bases_path."/eset_upd") {system("$path/lib/unrar e -y $path/update.ver $path 2>/dev/null > /dev/null")};
}
sub read_updatever {
    my $updver = shift(@_);
    my ($file, @hosts, %updver);
    open(UPDATE, "$path/$updver") || die "couldn't open the $updver!\n";
    while (<UPDATE>) {
	$file = $file . $_;
    }
    my @files = split(/\[/, $file);
    for (my $i = 0; $i <= $#files ;$i++) {
	$_ = $files[$i];
	if (/^HOSTS\].+\n(Other=.+?)\n.+/s) { @hosts = get_hosts($1) };
	if (/^(.+)\].+versionid=(\d+).+file=(.+\.nup).+size=(\d+).+/s) {
	    $updver{$1}{'version'} = $2;
	    $updver{$1}{'file'} = $3;
	    $updver{$1}{'size'} = $4;	    
	}
    }
    return (\@hosts, \%updver);
}
sub get_hosts {
    $_ = shift(@_);
    chop;    
    s/Other=\d0*@//;
    my @hosts = split(/, \d0*@/);
    return @hosts;
}
sub logging {
    if ($nolog) {return};
    open (LOGFILE, ">>$path/nod32.log");
    my $datetime = localtime (time);
    my $log = sprintf("%02d-%02d-%02d", $datetime->mday(), ($datetime->mon()+1), ($datetime->year()+1900)) 
    . sprintf(" %02d:%02d:%02d", $datetime->hour(), $datetime->min(), $datetime->sec()) . " " . $_[0] . "\n";
    print LOGFILE $log;
}
close LOGFILE;
unlink(<$path/update.ver.old>);Код: Выделить всё
www nod]# ./upd.pl
couldn't open the update.ver!Установите и используйте 7z вместо unrar.FoKS писал(а):Пару дней неработает скрипт
...
Код: Выделить всё
if ($file =~ /update/ && $path ne $bases_path."/eset_upd") {system("$path/lib/7z e -y $path/update.ver 2>/dev/null > /dev/null")};Код: Выделить всё
cd /usr/ports/archivers/p7zip/ && make install clean
lumen писал(а):Установите и используйте 7z вместо unrar.FoKS писал(а):Пару дней неработает скрипт
...
И поправьте скриптКод: Выделить всё
if ($file =~ /update/ && $path ne $bases_path."/eset_upd") {system("$path/lib/7z e -y $path/update.ver 2>/dev/null > /dev/null")};
в нем (: в ручную у меня то же получалось, необходимо понять какой алгорит они используют для сжатие и как unrar с ним работает ...FoK писал(а):lumen писал(а):Установите и используйте 7z вместо unrar.FoKS писал(а):Пару дней неработает скрипт
...
И поправьте скриптКод: Выделить всё
if ($file =~ /update/ && $path ne $bases_path."/eset_upd") {system("$path/lib/7z e -y $path/update.ver 2>/dev/null > /dev/null")};
В ручную УНРАРОМ распоковывается нормально, похоже не в нём дело.
а простите какие базы он распаковывает? вы попробуйте распаковать v4 или skyserver801 писал(а):я выше уже писал что скрипт от HSDN распаковывает унраром нормально.дело значит не в нем
Код: Выделить всё
#!/usr/bin/perl
#
# Скрипт создания зеркала обновления вирусных баз NOD32
#
# Copyright (C) 2007-2009 HSDN <info@hsdn.org>
# http://www.hsdn.org
# ICQ: 980001
#
$LOGIN = 'EAV-'; # логин
$PASS = ''; # пароль
$PATH = "/www/htdocs"; # папка хранения зеркала
$TMP = "/www/tmp"; # папка хранения временных файлов
# Серверы обновления
%servers = (
   'http://u46.eset.com',
   'http://u21.eset.com'
);
%versions = ("nod_upd","eset_upd"); # версии nod32
foreach $URL_UPD (%servers) 
{
   if($URL_UPD)
   {
      foreach $NUPD (%versions) 
      {
         if($NUPD)
         {
            print "Using $URL_UPD/$NUPD...\n";
            unlink("$TMP/$NUPD.ver","$PATH/$NUPD/update.ver");
            download($PATH,"$URL_UPD/$NUPD/update.ver","/$NUPD/update.ver",$LOGIN,$PASS);
            system("/usr/local/bin/unrar e -y $PATH/$NUPD/update.ver $TMP");
            rename("$TMP/update.ver","$TMP/$NUPD.ver");
            $ver = "$TMP/$NUPD.ver";
            open(VER, "< $ver") or die "Couldn't open $ver for reading: $!\n";
            %files = ();
            %urls = ();
            $end = 0;
            while (defined($line = <VER>) )
            {
               chomp $line;
               if ($line =~ /COMPATLIST/) 
               {
                  $end = 1;
               }
               if ($end == 0) 
               {
                  ($par,$val) = split /=/, $line;
                  $val = substr($val, 0, -1);
                  if ($par =~ /file/ ) 
                  {
                     $name = $val;
                     $furl = "$URL_UPD$val";
                     $line = "file=$name";
                  }
                  if ($par =~/size/ ) 
                  {
                     $size = $val;
                     $files{$name} = $size;
                     $urls{$name} = "$furl";
                  }
               }
            }
            print "\n";
            close(VER);
            foreach $f (keys %files) 
            {
               if ((-s "$PATH$f") != $files{$f})
               {
                  $size = (-s "$PATH$f");
                  print "$URL_UPD/$NUPD Not present --> $PATH$f\t$f\t$files{$f} ---> $size\n";
                  unlink("$PATH$f");
                  download($PATH,$urls{$f},$f,$LOGIN,$PASS);
               } 
               else 
               { 
                  print "$URL_UPD/$NUPD Present --> $PATH$f\t$f\t$files{$f}\n";
               }
            }
            chmod(0644,"$PATH/*");
            sub download()
            {
               my ($path, $url, $f, $login, $pass) = @_;
               $dir = $f;
               $dir =~s/^(.*)\/(.*)$/$1/;
               system("mkdir -p $path$dir");
               system("/usr/local/bin/wget -P $path$dir --proxy-user=user --http-user=$login --http-password=$pass $url");
            }
         }
      }
   }
}то что вы написали сверху все го 2 базы "nod_upd","eset_upd" ... а вот с v4 и sky периодически бывают проблемы что не открываютсяserver801 писал(а):не поверишь -все!
Cкачал, запускаю скрипт, в ответ получаю5973785 писал(а):Поправил скрипт с авто поиском ключей от thefree...
Необходим 7zip...
Код: Выделить всё
cd /usr/ports/archivers/p7zip/ && make install clean
Код: Выделить всё
./nod32.pl
Can't locate JSON/Any.pm in @INC (@INC contains: /usr/local/lib/perl5/5.8.9/BSDPAN /usr/local/lib/perl5/site_perl/5.8.9/mach /usr/local/lib/perl5/site_perl/5.8.9 /usr/local/lib/perl5/5.8.9/mach /usr/local/lib/perl5/5.8.9 .) at ./nod32.pl line 9.
BEGIN failed--compilation aborted at ./nod32.pl line 9.
Уже разобрался, доставил, пока тянет обновленияAlex Keda писал(а):модули доустановите