2011-06-27 Vanessa Gil <vanessa.gil@artica.es>

* unix/pandora_agent: Create configuration file for drone agents in Unix.


git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4487 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
vgilc 2011-06-27 15:18:34 +00:00
parent a304149340
commit 287f4c256a
2 changed files with 40 additions and 16 deletions

View File

@ -1,3 +1,7 @@
2011-06-27 Vanessa Gil <vanessa.gil@artica.es>
* unix/pandora_agent: Create configuration file for drone agents in Unix.
2011-06-21 Vanessa Gil <vanessa.gil@artica.es>
* win32/pandora_windows_service.cc

View File

@ -418,6 +418,22 @@ sub parse_conf_modules($) {
return;
}
################################################################################
# Create configuration file for drone agents.
################################################################################
sub write_broker_conf($$){
my ($conf_file, $broker_file) = @_;
my $content = '';
open (CONF_FILE, "$ConfDir/$ConfFile") or error ("Could not open file '$ConfDir/$ConfFile': $!.");
open (BROKER_FILE, ">$broker_file") or error ("Could not write configuration file: $!");
print BROKER_FILE while (<CONF_FILE>);
close (BROKER_FILE);
close (CONF_FILE);
}
################################################################################
# Read configuration file. Exit on error.
################################################################################
@ -429,8 +445,9 @@ sub read_config (;$) {
open (CONF_FILE, "$ConfDir/$ConfFile") or error ("Could not open file '$ConfDir/$ConfFile': $!.");
my @file = <CONF_FILE>;
while (my $line = <CONF_FILE>) {
close(CONF_FILE);
foreach my $line (@file){
# Skip comments and empty lines
next if ($line =~ m/^\s*#/) or ($line =~ m/^\s*$/);
@ -439,7 +456,6 @@ sub read_config (;$) {
return $2 if ($line =~ /^\s*(\S+)\s+(.*)$/ && $1 eq $token);
next;
}
#Additional configuration file
if ($line =~ /^include\s+(.*)\s*/){
open (FILE, "$1") or next;
@ -447,17 +463,20 @@ sub read_config (;$) {
parse_conf_modules(\@file_conf);
close (FILE);
}
# Configuration token
#Broker agent
if ($line =~ /^broker_agent\s+(\w*)\s*/){
my $path_conf = "$ConfDir/$ConfFile";
my $path_broker = "$ConfDir/$1.conf";
write_broker_conf($path_conf, $path_broker);
}
#Configuration token
if ($line =~ /^\s*(\S+)\s+(.*)$/) {
log_message ('setup', "$1 is $2");
$Conf{$1} = $2;
# Remove trailing spaces
$Conf{$1} =~ s/\s*$//;
}
}
# Module, plugin and collection definition
@ -489,12 +508,11 @@ sub read_config (;$) {
$Conf{'secondary_server_opts'} = '-c ' . $Conf{'secondary_server_opts'} if ($Conf{'secondary_server_ssl'} eq 'yes');
}
close (CONF_FILE);
}
################################################################################
# Remove any trailing / from directory names.
################################################################################
#################################################################################
## Remove any trailing / from directory names.
#################################################################################
sub fix_directory ($) {
my $dir = shift;
@ -503,6 +521,8 @@ sub fix_directory ($) {
return $dir . $char;
}
################################################################################
# Sends a file to the server.
################################################################################