diff --git a/pandora_agents/ChangeLog b/pandora_agents/ChangeLog index f88b5a7da1..f1553344ed 100644 --- a/pandora_agents/ChangeLog +++ b/pandora_agents/ChangeLog @@ -1,3 +1,7 @@ +2011-06-27 Vanessa Gil + + * unix/pandora_agent: Create configuration file for drone agents in Unix. + 2011-06-21 Vanessa Gil * win32/pandora_windows_service.cc diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index a2c9608fcc..2a9a8c5ff3 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -418,19 +418,36 @@ 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 (); + + close (BROKER_FILE); + close (CONF_FILE); +} + ################################################################################ # Read configuration file. Exit on error. ################################################################################ sub read_config (;$) { my $token = shift; my $module; - + error ("File '$ConfDir/$ConfFile' not found.") unless (-e "$ConfDir/$ConfFile"); open (CONF_FILE, "$ConfDir/$ConfFile") or error ("Could not open file '$ConfDir/$ConfFile': $!."); my @file = ; - while (my $line = ) { + close(CONF_FILE); + foreach my $line (@file){ # Skip comments and empty lines next if ($line =~ m/^\s*#/) or ($line =~ m/^\s*$/); @@ -438,8 +455,7 @@ sub read_config (;$) { if (defined ($token)) { 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,21 +463,24 @@ sub read_config (;$) { parse_conf_modules(\@file_conf); close (FILE); } - - # Configuration token - if ($line =~ /^\s*(\S+)\s+(.*)$/) { - + #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 - parse_conf_modules(\@file); + parse_conf_modules(\@file); # Token not found if (defined ($token)) { @@ -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. ################################################################################