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:
parent
a304149340
commit
287f4c256a
|
@ -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>
|
2011-06-21 Vanessa Gil <vanessa.gil@artica.es>
|
||||||
|
|
||||||
* win32/pandora_windows_service.cc
|
* win32/pandora_windows_service.cc
|
||||||
|
|
|
@ -418,19 +418,36 @@ sub parse_conf_modules($) {
|
||||||
return;
|
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.
|
# Read configuration file. Exit on error.
|
||||||
################################################################################
|
################################################################################
|
||||||
sub read_config (;$) {
|
sub read_config (;$) {
|
||||||
my $token = shift;
|
my $token = shift;
|
||||||
my $module;
|
my $module;
|
||||||
|
|
||||||
error ("File '$ConfDir/$ConfFile' not found.") unless (-e "$ConfDir/$ConfFile");
|
error ("File '$ConfDir/$ConfFile' not found.") unless (-e "$ConfDir/$ConfFile");
|
||||||
open (CONF_FILE, "$ConfDir/$ConfFile") or error ("Could not open file '$ConfDir/$ConfFile': $!.");
|
open (CONF_FILE, "$ConfDir/$ConfFile") or error ("Could not open file '$ConfDir/$ConfFile': $!.");
|
||||||
|
|
||||||
my @file = <CONF_FILE>;
|
my @file = <CONF_FILE>;
|
||||||
while (my $line = <CONF_FILE>) {
|
close(CONF_FILE);
|
||||||
|
|
||||||
|
foreach my $line (@file){
|
||||||
# Skip comments and empty lines
|
# Skip comments and empty lines
|
||||||
next if ($line =~ m/^\s*#/) or ($line =~ m/^\s*$/);
|
next if ($line =~ m/^\s*#/) or ($line =~ m/^\s*$/);
|
||||||
|
|
||||||
|
@ -438,8 +455,7 @@ sub read_config (;$) {
|
||||||
if (defined ($token)) {
|
if (defined ($token)) {
|
||||||
return $2 if ($line =~ /^\s*(\S+)\s+(.*)$/ && $1 eq $token);
|
return $2 if ($line =~ /^\s*(\S+)\s+(.*)$/ && $1 eq $token);
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
#Additional configuration file
|
#Additional configuration file
|
||||||
if ($line =~ /^include\s+(.*)\s*/){
|
if ($line =~ /^include\s+(.*)\s*/){
|
||||||
open (FILE, "$1") or next;
|
open (FILE, "$1") or next;
|
||||||
|
@ -447,21 +463,24 @@ sub read_config (;$) {
|
||||||
parse_conf_modules(\@file_conf);
|
parse_conf_modules(\@file_conf);
|
||||||
close (FILE);
|
close (FILE);
|
||||||
}
|
}
|
||||||
|
#Broker agent
|
||||||
# Configuration token
|
if ($line =~ /^broker_agent\s+(\w*)\s*/){
|
||||||
if ($line =~ /^\s*(\S+)\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");
|
log_message ('setup', "$1 is $2");
|
||||||
$Conf{$1} = $2;
|
$Conf{$1} = $2;
|
||||||
|
|
||||||
# Remove trailing spaces
|
# Remove trailing spaces
|
||||||
$Conf{$1} =~ s/\s*$//;
|
$Conf{$1} =~ s/\s*$//;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Module, plugin and collection definition
|
# Module, plugin and collection definition
|
||||||
parse_conf_modules(\@file);
|
parse_conf_modules(\@file);
|
||||||
|
|
||||||
# Token not found
|
# Token not found
|
||||||
if (defined ($token)) {
|
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');
|
$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 ($) {
|
sub fix_directory ($) {
|
||||||
my $dir = shift;
|
my $dir = shift;
|
||||||
|
|
||||||
|
@ -503,6 +521,8 @@ sub fix_directory ($) {
|
||||||
return $dir . $char;
|
return $dir . $char;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Sends a file to the server.
|
# Sends a file to the server.
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
Loading…
Reference in New Issue