[Rebranding] Implemented server rebranding through environment vars
This commit is contained in:
parent
a54c074b11
commit
7afc617e62
|
@ -519,7 +519,7 @@ sub main() {
|
|||
|
||||
# Daemonize and put in background
|
||||
if ($Config{'daemon'} == 1) {
|
||||
print_message (\%Config, " [*] Backgrounding Pandora FMS Server process.\n", 1);
|
||||
print_message (\%Config, " [*] Backgrounding " . pandora_get_initial_product_name() . " Server process.\n", 1);
|
||||
pandora_daemonize (\%Config);
|
||||
}
|
||||
|
||||
|
@ -528,8 +528,8 @@ sub main() {
|
|||
print_message (\%Config, " [*] Pandora FMS Enterprise module not available.", 1);
|
||||
logger (\%Config, " [*] Pandora FMS Enterprise module not available.", 1);
|
||||
} else {
|
||||
print_message (\%Config, " [*] Pandora FMS Enterprise module loaded.", 1);
|
||||
logger (\%Config, " [*] Pandora FMS Enterprise module loaded.", 1);
|
||||
print_message (\%Config, " [*] " . pandora_get_initial_product_name() . " Enterprise module loaded.", 1);
|
||||
logger (\%Config, " [*] " . pandora_get_initial_product_name() . " Enterprise module loaded.", 1);
|
||||
|
||||
if($Config{'policy_manager'} == 1) {
|
||||
# Start thread to patrol policy queue
|
||||
|
@ -687,7 +687,7 @@ $SIG{__DIE__} = 'pandora_crash';
|
|||
$SIG{'ALRM'} = 'IGNORE';
|
||||
|
||||
# Initialize
|
||||
pandora_init(\%Config, 'Pandora FMS Server');
|
||||
pandora_init(\%Config, pandora_get_initial_product_name() . ' Server');
|
||||
pandora_load_config (\%Config);
|
||||
|
||||
# Parse command line options.
|
||||
|
|
|
@ -39,6 +39,8 @@ our @EXPORT = qw(
|
|||
pandora_start_log
|
||||
pandora_get_sharedconfig
|
||||
pandora_get_tconfig_token
|
||||
pandora_get_initial_product_name
|
||||
pandora_get_initial_copyright_notice
|
||||
);
|
||||
|
||||
# version: Defines actual version of Pandora Server for this module only
|
||||
|
@ -56,7 +58,7 @@ my %pa_config;
|
|||
##########################################################################
|
||||
|
||||
sub help_screen {
|
||||
print "\nSyntax: \n\n pandora_server [ options ] < fullpathname to configuration file (pandora_server.conf) > \n\n";
|
||||
print "\nSyntax: \n\n pandora_server [ options ] < fullpathname to configuration file > \n\n";
|
||||
print "Following options are optional : \n";
|
||||
print " -v : Verbose mode activated. Writes more information in the logfile \n";
|
||||
print " -d : Debug mode activated. Writes extensive information in the logfile \n";
|
||||
|
@ -77,13 +79,13 @@ sub help_screen {
|
|||
sub pandora_init {
|
||||
my $pa_config = $_[0];
|
||||
my $init_string = $_[1];
|
||||
print "\n$init_string $pandora_version Build $pandora_build Copyright (c) 2004-2015 ArticaST\n";
|
||||
print "\n$init_string $pandora_version Build $pandora_build Copyright (c) 2004-2018 " . pandora_get_initial_copyright_notice() . "\n";
|
||||
print "This program is OpenSource, licensed under the terms of GPL License version 2.\n";
|
||||
print "You can download latest versions and documentation at http://www.pandorafms.org \n\n";
|
||||
print "You can download latest versions and documentation at official web page.\n\n";
|
||||
|
||||
# Load config file from command line
|
||||
if ($#ARGV == -1 ){
|
||||
print "I need at least one parameter: Complete path to Pandora FMS Server configuration file \n";
|
||||
print "I need at least one parameter: Complete path to " . pandora_get_initial_product_name() . " Server configuration file \n";
|
||||
help_screen;
|
||||
exit;
|
||||
}
|
||||
|
@ -124,7 +126,7 @@ sub pandora_init {
|
|||
}
|
||||
}
|
||||
if ($pa_config->{"pandora_path"} eq ""){
|
||||
print " [ERROR] I need at least one parameter: Complete path to Pandora FMS configuration file. \n";
|
||||
print " [ERROR] I need at least one parameter: Complete path to " . pandora_get_initial_product_name() . " configuration file. \n";
|
||||
print " For example: ./pandora_server /etc/pandora/pandora_server.conf \n\n";
|
||||
exit;
|
||||
}
|
||||
|
@ -496,7 +498,7 @@ sub pandora_load_config {
|
|||
# Check for file
|
||||
if ( ! -f $archivo_cfg ) {
|
||||
printf "\n [ERROR] Cannot open configuration file at $archivo_cfg. \n";
|
||||
printf " Please specify a valid Pandora FMS configuration file in command line. \n";
|
||||
printf " Please specify a valid " . pandora_get_initial_product_name() ." configuration file in command line. \n";
|
||||
print " Standard configuration file is at /etc/pandora/pandora_server.conf \n";
|
||||
exit 1;
|
||||
}
|
||||
|
@ -1165,10 +1167,10 @@ sub pandora_start_log ($){
|
|||
my $pa_config = shift;
|
||||
|
||||
# Dump all errors to errorlog
|
||||
open (STDERR, ">> " . $pa_config->{'errorlog_file'}) or die " [ERROR] Pandora FMS can't write to Errorlog. Aborting : \n $! \n";
|
||||
open (STDERR, ">> " . $pa_config->{'errorlog_file'}) or die " [ERROR] " . pandora_get_initial_product_name() . " can't write to Errorlog. Aborting : \n $! \n";
|
||||
my $mode = 0664;
|
||||
chmod $mode, $pa_config->{'errorlog_file'};
|
||||
print STDERR strftime ("%Y-%m-%d %H:%M:%S", localtime()) . ' - ' . $pa_config->{'servername'} . " Starting Pandora FMS Server. Error logging activated.\n";
|
||||
print STDERR strftime ("%Y-%m-%d %H:%M:%S", localtime()) . ' - ' . $pa_config->{'servername'} . " Starting " . pandora_get_initial_product_name() . " Server. Error logging activated.\n";
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
|
@ -1185,6 +1187,26 @@ sub pandora_get_tconfig_token ($$$) {
|
|||
return $default_value;
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
# Get the product name in previous tasks to read from database.
|
||||
##########################################################################
|
||||
sub pandora_get_initial_product_name {
|
||||
# PandoraFMS product name
|
||||
my $product_name = $ENV{'PANDORA_RB_PRODUCT_NAME'};
|
||||
return 'Pandora FMS' unless (defined ($product_name) && $product_name ne '');
|
||||
return $product_name;
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
# Get the copyright notice.
|
||||
##########################################################################
|
||||
sub pandora_get_initial_copyright_notice {
|
||||
# PandoraFMS product name
|
||||
my $name = $ENV{'PANDORA_RB_COPYRIGHT_NOTICE'};
|
||||
return 'Artica ST' unless (defined ($name) && $name ne '');
|
||||
return $name;
|
||||
}
|
||||
|
||||
# End of function declaration
|
||||
# End of defined Code
|
||||
|
||||
|
|
|
@ -399,7 +399,7 @@ sub pandora_daemonize {
|
|||
|
||||
# check if pandora_server is running
|
||||
if (kill (0, $pid)) {
|
||||
die "[FATAL] pandora_server already running, pid: $pid.";
|
||||
die "[FATAL] " . pandora_get_initial_product_name() . " Server already running, pid: $pid.";
|
||||
}
|
||||
logger ($pa_config, '[W] Stale PID file, overwriting.', 1);
|
||||
}
|
||||
|
@ -674,10 +674,13 @@ sub enterprise_load ($) {
|
|||
eval 'require PandoraFMS::Enterprise;';
|
||||
}
|
||||
|
||||
|
||||
|
||||
# Ops
|
||||
if ($@) {
|
||||
# Remove the rebranding if open version
|
||||
if ($^O ne 'MSWin32') {
|
||||
`unset PANDORA_RB_PRODUCT_NAME`;
|
||||
`unset PANDORA_RB_COPYRIGHT_NOTICE`;
|
||||
}
|
||||
|
||||
# Enterprise.pm not found.
|
||||
return 0 if ($@ =~ m/PandoraFMS\/Enterprise\.pm.*\@INC/);
|
||||
|
|
|
@ -555,9 +555,9 @@ sub pandora_compactdb ($$) {
|
|||
sub pandora_init ($) {
|
||||
my $conf = shift;
|
||||
|
||||
log_message ('', "\nDB Tool $version Copyright (c) 2004-2018 Artica ST\n");
|
||||
log_message ('', "\nDB Tool $version Copyright (c) 2004-2018 " . pandora_get_initial_copyright_notice() . "\n");
|
||||
log_message ('', "This program is Free Software, licensed under the terms of GPL License v2\n");
|
||||
log_message ('', "You can download latest versions and documentation at http://www.pandorafms.org\n\n");
|
||||
log_message ('', "You can download latest versions and documentation at official web\n\n");
|
||||
|
||||
# Load config file from command line
|
||||
help_screen () if ($#ARGV < 0);
|
||||
|
@ -897,7 +897,7 @@ sub pandora_checkdb_consistency {
|
|||
# Print a help screen and exit.
|
||||
##############################################################################
|
||||
sub help_screen{
|
||||
log_message ('', "Usage: $0 <path to pandora_server.conf> [options]\n\n");
|
||||
log_message ('', "Usage: $0 <path to configuration file> [options]\n\n");
|
||||
log_message ('', "\t\t-p Only purge and consistency check, skip compact.\n");
|
||||
log_message ('', "\t\t-f Force execution event if another instance of $0 is running.\n\n");
|
||||
exit -1;
|
||||
|
@ -1031,10 +1031,10 @@ pandora_load_config (\%conf);
|
|||
|
||||
# Load enterprise module
|
||||
if (enterprise_load (\%conf) == 0) {
|
||||
log_message ('', " [*] Pandora FMS Enterprise module not available.\n\n");
|
||||
log_message ('', " [*] " . pandora_get_initial_product_name() . " Enterprise module not available.\n\n");
|
||||
}
|
||||
else {
|
||||
log_message ('', " [*] Pandora FMS Enterprise module loaded.\n\n");
|
||||
log_message ('', " [*] " . pandora_get_initial_product_name() . " Enterprise module loaded.\n\n");
|
||||
}
|
||||
|
||||
# Connect to the DB
|
||||
|
|
Loading…
Reference in New Issue