Merge branch '1201-Error_al_iniciar_el_agente_de_Pandora' into 'develop'
fixed error in pandora_agent collections See merge request artica/pandorafms!934
This commit is contained in:
commit
46e7d29f5a
|
@ -1244,7 +1244,11 @@ sub check_collections () {
|
||||||
|
|
||||||
# Delete old collections if there are no broker agents
|
# Delete old collections if there are no broker agents
|
||||||
if ($BrokerEnabled == 0) {
|
if ($BrokerEnabled == 0) {
|
||||||
opendir (DIR, "$ConfDir/collections") || return;
|
if(!opendir (DIR, "$ConfDir/collections")){
|
||||||
|
log_message ('Collection', "Could not open dir $ConfDir/collections");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
while (defined (my $file_name = readdir(DIR))) {
|
while (defined (my $file_name = readdir(DIR))) {
|
||||||
next if ($file_name eq '.' || $file_name eq '..');
|
next if ($file_name eq '.' || $file_name eq '..');
|
||||||
|
|
||||||
|
@ -1252,8 +1256,14 @@ sub check_collections () {
|
||||||
$file_name =~ s/\.md5$//;
|
$file_name =~ s/\.md5$//;
|
||||||
|
|
||||||
if (! defined ($Collections{$file_name})) {
|
if (! defined ($Collections{$file_name})) {
|
||||||
rmrf ("$ConfDir/collections/$file_name");
|
if(opendir (DIR_check, "$ConfDir/collections/$file_name")){
|
||||||
unlink ("$ConfDir/collections/$file_name.md5");
|
closedir (DIR_check);
|
||||||
|
rmrf ("$ConfDir/collections/$file_name");
|
||||||
|
unlink ("$ConfDir/collections/$file_name.md5");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
log_message ('Collection', "Could not open dir $ConfDir/collections/$file_name");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
closedir (DIR);
|
closedir (DIR);
|
||||||
|
@ -1272,7 +1282,11 @@ sub check_collections () {
|
||||||
|
|
||||||
# Get remote md5
|
# Get remote md5
|
||||||
error ("File '$Conf{'temporal'}/$collection_md5_file' already exists as a symlink and could not be removed: $!.") if (-l "$Conf{'temporal'}/$collection_md5_file" && !unlink("$Conf{'temporal'}/$collection_md5_file"));
|
error ("File '$Conf{'temporal'}/$collection_md5_file' already exists as a symlink and could not be removed: $!.") if (-l "$Conf{'temporal'}/$collection_md5_file" && !unlink("$Conf{'temporal'}/$collection_md5_file"));
|
||||||
next unless (recv_file ($collection_md5_file, $Conf{'server_path_md5'}) == 0);
|
if(recv_file ($collection_md5_file, $Conf{'server_path_md5'}) != 0){
|
||||||
|
log_message ('Collection', "Could not write $collection_md5_file on " . $Conf{'server_path_md5'});
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
open (MD5_FILE, "< $Conf{'temporal'}/$collection_md5_file") || error ("Could not open file '$Conf{'temporal'}/$collection_md5_file' for reading: $!.");
|
open (MD5_FILE, "< $Conf{'temporal'}/$collection_md5_file") || error ("Could not open file '$Conf{'temporal'}/$collection_md5_file' for reading: $!.");
|
||||||
my $remote_collection_md5 = <MD5_FILE>;
|
my $remote_collection_md5 = <MD5_FILE>;
|
||||||
close (MD5_FILE);
|
close (MD5_FILE);
|
||||||
|
@ -1284,13 +1298,20 @@ sub check_collections () {
|
||||||
$local_collection_md5 = <MD5_FILE>;
|
$local_collection_md5 = <MD5_FILE>;
|
||||||
close MD5_FILE;
|
close MD5_FILE;
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
log_message ('Collection', "Could not open dir $ConfDir/collections/$collection_md5_file");
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
# Check for changes
|
# Check for changes
|
||||||
$local_collection_md5 = $remote_collection_md5 unless defined ($local_collection_md5);
|
$local_collection_md5 = $remote_collection_md5 unless defined ($local_collection_md5);
|
||||||
next if ($local_collection_md5 eq $remote_collection_md5);
|
next if ($local_collection_md5 eq $remote_collection_md5);
|
||||||
|
|
||||||
# Download and unzip
|
# Download and unzip
|
||||||
next unless (recv_file ($collection_file, $Conf{'server_path_zip'}) == 0);
|
if(recv_file ($collection_md5_file, $Conf{'server_path_md5'}) != 0){
|
||||||
|
log_message ('Collection', "Could not write $collection_file on " . $Conf{'server_path_zip'});
|
||||||
|
next;
|
||||||
|
}
|
||||||
rmrf ("$ConfDir/collections/$collection");
|
rmrf ("$ConfDir/collections/$collection");
|
||||||
`unzip -d "$ConfDir/collections/$collection" "$Conf{'temporal'}/$collection_file" 2>$DevNull`;
|
`unzip -d "$ConfDir/collections/$collection" "$Conf{'temporal'}/$collection_file" 2>$DevNull`;
|
||||||
unlink ("$Conf{'temporal'}/$collection_file");
|
unlink ("$Conf{'temporal'}/$collection_file");
|
||||||
|
|
Loading…
Reference in New Issue