mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2024-12-14 10:13:05 +02:00
Moved more config logic to Config.pm
This commit is contained in:
parent
6124558347
commit
c76a8d64d0
@ -12,7 +12,6 @@ use warnings;
|
||||
use Carp;
|
||||
|
||||
use File::Basename;
|
||||
use Getopt::Long;
|
||||
use Pod::Usage;
|
||||
|
||||
use lib dirname($0) . '/../lib';
|
||||
@ -54,70 +53,29 @@ pg_backrest.pl [options] [operation]
|
||||
=cut
|
||||
|
||||
####################################################################################################################################
|
||||
# Operation constants - basic operations that are allowed in backrest
|
||||
# Load command line parameters and config
|
||||
####################################################################################################################################
|
||||
use constant
|
||||
{
|
||||
OP_ARCHIVE_GET => 'archive-get',
|
||||
OP_ARCHIVE_PUSH => 'archive-push',
|
||||
OP_BACKUP => 'backup',
|
||||
OP_EXPIRE => 'expire'
|
||||
};
|
||||
|
||||
####################################################################################################################################
|
||||
# Command line parameters
|
||||
####################################################################################################################################
|
||||
my $strConfigFile; # Configuration file
|
||||
my $strStanza; # Stanza in the configuration file to load
|
||||
my $strType; # Type of backup: full, diff (differential), incr (incremental)
|
||||
my $bNoStartStop = false; # Do not perform start/stop backup (and archive-required gets set to false)
|
||||
my $bForce = false; # Force an action that would not normally be allowed (varies by action)
|
||||
my $bVersion = false; # Display version and exit
|
||||
my $bHelp = false; # Display help and exit
|
||||
|
||||
# Test parameters - not for general use
|
||||
my $bNoFork = false; # Prevents the archive process from forking when local archiving is enabled
|
||||
my $bTest = false; # Enters test mode - not harmful in anyway, but adds special logging and pauses for unit testing
|
||||
my $iTestDelay = 5; # Amount of time to delay after hitting a test point (the default would not be enough for manual tests)
|
||||
|
||||
GetOptions ('config=s' => \$strConfigFile,
|
||||
'stanza=s' => \$strStanza,
|
||||
'type=s' => \$strType,
|
||||
'no-start-stop' => \$bNoStartStop,
|
||||
'force' => \$bForce,
|
||||
'version' => \$bVersion,
|
||||
'help' => \$bHelp,
|
||||
|
||||
# Test parameters - not for general use (and subject to change without notice)
|
||||
'no-fork' => \$bNoFork,
|
||||
'test' => \$bTest,
|
||||
'test-delay=s' => \$iTestDelay)
|
||||
or pod2usage(2);
|
||||
# Load the config file
|
||||
config_load();
|
||||
|
||||
# Display version and exit if requested
|
||||
if ($bVersion || $bHelp)
|
||||
if (param_get(PARAM_VERSION) || param_get(PARAM_HELP))
|
||||
{
|
||||
print 'pg_backrest ' . version_get() . "\n";
|
||||
|
||||
if (!$bHelp)
|
||||
if (!param_get(PARAM_HELP))
|
||||
{
|
||||
exit 0;
|
||||
}
|
||||
}
|
||||
|
||||
# Display help and exit if requested
|
||||
if ($bHelp)
|
||||
if (param_get(PARAM_HELP))
|
||||
{
|
||||
print "\n";
|
||||
pod2usage();
|
||||
}
|
||||
|
||||
# Set test parameters
|
||||
test_set($bTest, $iTestDelay);
|
||||
|
||||
# Load the config file
|
||||
config_load($strConfigFile, $strStanza);
|
||||
|
||||
####################################################################################################################################
|
||||
# Global variables
|
||||
####################################################################################################################################
|
||||
@ -184,28 +142,6 @@ eval {
|
||||
####################################################################################################################################
|
||||
# START MAIN
|
||||
####################################################################################################################################
|
||||
# Get the operation
|
||||
my $strOperation = $ARGV[0];
|
||||
|
||||
# Validate the operation
|
||||
if (!defined($strOperation))
|
||||
{
|
||||
confess &log(ERROR, 'operation is not defined');
|
||||
}
|
||||
|
||||
if ($strOperation ne OP_ARCHIVE_GET &&
|
||||
$strOperation ne OP_ARCHIVE_PUSH &&
|
||||
$strOperation ne OP_BACKUP &&
|
||||
$strOperation ne OP_EXPIRE)
|
||||
{
|
||||
confess &log(ERROR, "invalid operation ${strOperation}");
|
||||
}
|
||||
|
||||
# Type should only be specified for backups
|
||||
if (defined($strType) && $strOperation ne OP_BACKUP)
|
||||
{
|
||||
confess &log(ERROR, 'type can only be specified for the backup operation')
|
||||
}
|
||||
|
||||
####################################################################################################################################
|
||||
# DETERMINE IF THERE IS A REMOTE
|
||||
@ -234,7 +170,7 @@ else
|
||||
####################################################################################################################################
|
||||
# ARCHIVE-PUSH Command
|
||||
####################################################################################################################################
|
||||
if ($strOperation eq OP_ARCHIVE_PUSH)
|
||||
if (operation_get() eq OP_ARCHIVE_PUSH)
|
||||
{
|
||||
# Make sure the archive push operation happens on the db side
|
||||
if ($strRemote eq REMOTE_DB)
|
||||
@ -263,7 +199,7 @@ if ($strOperation eq OP_ARCHIVE_PUSH)
|
||||
|
||||
if ($bArchiveLocal)
|
||||
{
|
||||
$strStopFile = "${strArchivePath}/lock/${strStanza}-archive.stop";
|
||||
$strStopFile = "${strArchivePath}/lock/" + param_get(PARAM_STANZA) + "-archive.stop";
|
||||
}
|
||||
|
||||
# If an archive file is defined, then push it
|
||||
@ -285,7 +221,7 @@ if ($strOperation eq OP_ARCHIVE_PUSH)
|
||||
# Create the file object
|
||||
my $oFile = new BackRest::File
|
||||
(
|
||||
$strStanza,
|
||||
param_get(PARAM_STANZA),
|
||||
config_key_load($strSection, CONFIG_KEY_PATH, true),
|
||||
$bArchiveLocal ? REMOTE_NONE : $strRemote,
|
||||
$bArchiveLocal ? undef : remote_get()
|
||||
@ -313,7 +249,7 @@ if ($strOperation eq OP_ARCHIVE_PUSH)
|
||||
}
|
||||
|
||||
# Fork and exit the parent process so the async process can continue
|
||||
if (!$bNoFork)
|
||||
if (!param_get(PARAM_TEST_NO_FORK))
|
||||
{
|
||||
if (fork())
|
||||
{
|
||||
@ -336,7 +272,7 @@ if ($strOperation eq OP_ARCHIVE_PUSH)
|
||||
&log(INFO, 'starting async archive-push');
|
||||
|
||||
# Create a lock file to make sure async archive-push does not run more than once
|
||||
my $strLockPath = "${strArchivePath}/lock/${strStanza}-archive.lock";
|
||||
my $strLockPath = "${strArchivePath}/lock/" . param_get(PARAM_STANZA) . "-archive.lock";
|
||||
|
||||
if (!lock_file_create($strLockPath))
|
||||
{
|
||||
@ -345,7 +281,7 @@ if ($strOperation eq OP_ARCHIVE_PUSH)
|
||||
}
|
||||
|
||||
# Build the basic command string that will be used to modify the command during processing
|
||||
my $strCommand = $^X . ' ' . $0 . " --stanza=${strStanza}";
|
||||
my $strCommand = $^X . ' ' . $0 . " --stanza=" . param_get(PARAM_STANZA);
|
||||
|
||||
# Get the new operational flags
|
||||
my $bCompress = config_key_load(CONFIG_SECTION_BACKUP, CONFIG_KEY_COMPRESS, true, 'y') eq 'y' ? true : false;
|
||||
@ -356,7 +292,7 @@ if ($strOperation eq OP_ARCHIVE_PUSH)
|
||||
# Create the file object
|
||||
my $oFile = new BackRest::File
|
||||
(
|
||||
$strStanza,
|
||||
param_get(PARAM_STANZA),
|
||||
config_key_load(CONFIG_SECTION_BACKUP, CONFIG_KEY_PATH, true),
|
||||
$strRemote,
|
||||
remote_get()
|
||||
@ -381,7 +317,8 @@ if ($strOperation eq OP_ARCHIVE_PUSH)
|
||||
|
||||
while (!defined($iLogTotal) || $iLogTotal > 0)
|
||||
{
|
||||
$iLogTotal = archive_xfer($strArchivePath . "/archive/${strStanza}", $strStopFile, $strCommand, $iArchiveMaxMB);
|
||||
$iLogTotal = archive_xfer($strArchivePath . "/archive/" . param_get(PARAM_STANZA), $strStopFile,
|
||||
$strCommand, $iArchiveMaxMB);
|
||||
|
||||
if ($iLogTotal > 0)
|
||||
{
|
||||
@ -442,7 +379,7 @@ if ($strOperation eq OP_ARCHIVE_PUSH)
|
||||
####################################################################################################################################
|
||||
# ARCHIVE-GET Command
|
||||
####################################################################################################################################
|
||||
if ($strOperation eq OP_ARCHIVE_GET)
|
||||
if (operation_get() eq OP_ARCHIVE_GET)
|
||||
{
|
||||
# Make sure the archive file is defined
|
||||
if (!defined($ARGV[1]))
|
||||
@ -459,7 +396,7 @@ if ($strOperation eq OP_ARCHIVE_GET)
|
||||
# Init the file object
|
||||
my $oFile = new BackRest::File
|
||||
(
|
||||
$strStanza,
|
||||
param_get(PARAM_STANZA),
|
||||
config_key_load(CONFIG_SECTION_BACKUP, CONFIG_KEY_PATH, true),
|
||||
$strRemote,
|
||||
remote_get()
|
||||
@ -487,7 +424,7 @@ if (defined(config_key_load(CONFIG_SECTION_BACKUP, CONFIG_KEY_HOST)))
|
||||
confess &log(ASSERT, 'backup/expire operations must be performed locally on the backup server');
|
||||
}
|
||||
|
||||
log_file_set(config_key_load(CONFIG_SECTION_BACKUP, CONFIG_KEY_PATH, true) . "/log/${strStanza}");
|
||||
log_file_set(config_key_load(CONFIG_SECTION_BACKUP, CONFIG_KEY_PATH, true) . "/log/" . param_get(PARAM_STANZA));
|
||||
|
||||
####################################################################################################################################
|
||||
# GET MORE CONFIG INFO
|
||||
@ -498,33 +435,24 @@ if ($strRemote eq REMOTE_BACKUP)
|
||||
confess &log(ERROR, 'backup and expire operations must run on the backup host');
|
||||
}
|
||||
|
||||
# Set the backup type
|
||||
if (!defined($strType))
|
||||
{
|
||||
$strType = BACKUP_TYPE_INCR;
|
||||
}
|
||||
elsif ($strType ne BACKUP_TYPE_FULL && $strType ne BACKUP_TYPE_DIFF && $strType ne BACKUP_TYPE_INCR)
|
||||
{
|
||||
confess &log(ERROR, 'backup type must be full, diff (differential), incr (incremental)');
|
||||
}
|
||||
|
||||
# Get the operational flags
|
||||
my $bCompress = config_key_load(CONFIG_SECTION_BACKUP, CONFIG_KEY_COMPRESS, true, 'y') eq 'y' ? true : false;
|
||||
my $bChecksum = config_key_load(CONFIG_SECTION_BACKUP, CONFIG_KEY_CHECKSUM, true, 'y') eq 'y' ? true : false;
|
||||
|
||||
# Set the lock path
|
||||
my $strLockPath = config_key_load(CONFIG_SECTION_BACKUP, CONFIG_KEY_PATH, true) . "/lock/${strStanza}-${strOperation}.lock";
|
||||
my $strLockPath = config_key_load(CONFIG_SECTION_BACKUP, CONFIG_KEY_PATH, true) . '/lock/' .
|
||||
param_get(PARAM_STANZA) . '-' . operation_get() . '.lock';
|
||||
|
||||
if (!lock_file_create($strLockPath))
|
||||
{
|
||||
&log(ERROR, "backup process is already running for stanza ${strStanza} - exiting");
|
||||
&log(ERROR, 'backup process is already running for stanza ' . param_get(PARAM_STANZA) . ' - exiting');
|
||||
remote_exit(0);
|
||||
}
|
||||
|
||||
# Initialize the default file object
|
||||
my $oFile = new BackRest::File
|
||||
(
|
||||
$strStanza,
|
||||
param_get(PARAM_STANZA),
|
||||
config_key_load(CONFIG_SECTION_BACKUP, CONFIG_KEY_PATH, true),
|
||||
$strRemote,
|
||||
remote_get()
|
||||
@ -533,7 +461,7 @@ my $oFile = new BackRest::File
|
||||
# Initialize the db object
|
||||
my $oDb;
|
||||
|
||||
if (!$bNoStartStop)
|
||||
if (!param_get(PARAM_NO_START_STOP))
|
||||
{
|
||||
$oDb = new BackRest::Db
|
||||
(
|
||||
@ -548,32 +476,32 @@ backup_init
|
||||
(
|
||||
$oDb,
|
||||
$oFile,
|
||||
$strType,
|
||||
param_get(PARAM_TYPE),
|
||||
config_key_load(CONFIG_SECTION_BACKUP, CONFIG_KEY_COMPRESS, true, 'y') eq 'y' ? true : false,
|
||||
config_key_load(CONFIG_SECTION_BACKUP, CONFIG_KEY_HARDLINK, true, 'y') eq 'y' ? true : false,
|
||||
!$bChecksum,
|
||||
config_key_load(CONFIG_SECTION_BACKUP, CONFIG_KEY_THREAD_MAX),
|
||||
config_key_load(CONFIG_SECTION_BACKUP, CONFIG_KEY_ARCHIVE_REQUIRED, true, 'y') eq 'y' ? true : false,
|
||||
config_key_load(CONFIG_SECTION_BACKUP, CONFIG_KEY_THREAD_TIMEOUT),
|
||||
$bNoStartStop,
|
||||
$bForce
|
||||
param_get(PARAM_NO_START_STOP),
|
||||
param_get(PARAM_FORCE)
|
||||
);
|
||||
|
||||
####################################################################################################################################
|
||||
# BACKUP
|
||||
####################################################################################################################################
|
||||
if ($strOperation eq OP_BACKUP)
|
||||
if (operation_get() eq OP_BACKUP)
|
||||
{
|
||||
backup(config_key_load(CONFIG_SECTION_STANZA, CONFIG_KEY_PATH),
|
||||
config_key_load(CONFIG_SECTION_BACKUP, CONFIG_KEY_START_FAST, true, 'n') eq 'y' ? true : false);
|
||||
|
||||
$strOperation = OP_EXPIRE;
|
||||
operation_set(OP_EXPIRE);
|
||||
}
|
||||
|
||||
####################################################################################################################################
|
||||
# EXPIRE
|
||||
####################################################################################################################################
|
||||
if ($strOperation eq OP_EXPIRE)
|
||||
if (operation_get() eq OP_EXPIRE)
|
||||
{
|
||||
backup_expire
|
||||
(
|
||||
|
@ -15,6 +15,7 @@ use Thread::Queue;
|
||||
|
||||
use lib dirname($0);
|
||||
use BackRest::Utility;
|
||||
use BackRest::Config;
|
||||
use BackRest::File;
|
||||
use BackRest::Db;
|
||||
|
||||
@ -45,16 +46,6 @@ my @oThreadQueue;
|
||||
my @oMasterQueue;
|
||||
my %oFileCopyMap;
|
||||
|
||||
####################################################################################################################################
|
||||
# BACKUP Type Constants
|
||||
####################################################################################################################################
|
||||
use constant
|
||||
{
|
||||
BACKUP_TYPE_FULL => 'full',
|
||||
BACKUP_TYPE_DIFF => 'diff',
|
||||
BACKUP_TYPE_INCR => 'incr'
|
||||
};
|
||||
|
||||
####################################################################################################################################
|
||||
# BACKUP_INIT
|
||||
####################################################################################################################################
|
||||
|
@ -9,13 +9,22 @@ use warnings;
|
||||
use Carp;
|
||||
|
||||
use File::Basename;
|
||||
use Getopt::Long;
|
||||
|
||||
use lib dirname($0) . '/../lib';
|
||||
use BackRest::Utility;
|
||||
|
||||
use Exporter qw(import);
|
||||
|
||||
our @EXPORT = qw(config_load config_key_load
|
||||
our @EXPORT = qw(config_load config_key_load operation_get operation_set param_get
|
||||
|
||||
OP_ARCHIVE_GET OP_ARCHIVE_PUSH OP_BACKUP OP_EXPIRE
|
||||
|
||||
BACKUP_TYPE_FULL BACKUP_TYPE_DIFF BACKUP_TYPE_INCR
|
||||
|
||||
PARAM_CONFIG PARAM_STANZA PARAM_TYPE PARAM_NO_START_STOP PARAM_FORCE PARAM_VERSION PARAM_HELP
|
||||
|
||||
PARAM_TEST PARAM_TEST_DELAY PARAM_TEST_NO_FORK
|
||||
|
||||
CONFIG_SECTION_COMMAND CONFIG_SECTION_COMMAND_OPTION CONFIG_SECTION_LOG CONFIG_SECTION_BACKUP
|
||||
CONFIG_SECTION_ARCHIVE CONFIG_SECTION_RETENTION CONFIG_SECTION_STANZA
|
||||
@ -33,7 +42,46 @@ our @EXPORT = qw(config_load config_key_load
|
||||
CONFIG_KEY_ARCHIVE_RETENTION);
|
||||
|
||||
####################################################################################################################################
|
||||
# Configuration constants - configuration sections and keys
|
||||
# Operation constants - basic operations that are allowed in backrest
|
||||
####################################################################################################################################
|
||||
use constant
|
||||
{
|
||||
OP_ARCHIVE_GET => 'archive-get',
|
||||
OP_ARCHIVE_PUSH => 'archive-push',
|
||||
OP_BACKUP => 'backup',
|
||||
OP_EXPIRE => 'expire'
|
||||
};
|
||||
|
||||
####################################################################################################################################
|
||||
# BACKUP Type Constants
|
||||
####################################################################################################################################
|
||||
use constant
|
||||
{
|
||||
BACKUP_TYPE_FULL => 'full',
|
||||
BACKUP_TYPE_DIFF => 'diff',
|
||||
BACKUP_TYPE_INCR => 'incr'
|
||||
};
|
||||
|
||||
####################################################################################################################################
|
||||
# Parameter constants
|
||||
####################################################################################################################################
|
||||
use constant
|
||||
{
|
||||
PARAM_CONFIG => 'config',
|
||||
PARAM_STANZA => 'stanza',
|
||||
PARAM_TYPE => 'type',
|
||||
PARAM_NO_START_STOP => 'no-start-stop',
|
||||
PARAM_FORCE => 'force',
|
||||
PARAM_VERSION => 'version',
|
||||
PARAM_HELP => 'help',
|
||||
|
||||
PARAM_TEST => 'test',
|
||||
PARAM_TEST_DELAY => 'test-delay',
|
||||
PARAM_TEST_NO_FORK => 'no-fork'
|
||||
};
|
||||
|
||||
####################################################################################################################################
|
||||
# Configuration constants
|
||||
####################################################################################################################################
|
||||
use constant
|
||||
{
|
||||
@ -75,8 +123,8 @@ use constant
|
||||
# Global variables
|
||||
####################################################################################################################################
|
||||
my %oConfig; # Configuration hash
|
||||
|
||||
my $strStanza; # Config stanza
|
||||
my %oParam = (); # Parameter hash
|
||||
my $strOperation; # Operation (backup, archive-get, ...)
|
||||
|
||||
####################################################################################################################################
|
||||
# CONFIG_LOAD
|
||||
@ -86,17 +134,69 @@ my $strStanza; # Config stanza
|
||||
sub config_load
|
||||
{
|
||||
my $strFile = shift; # Full path to ini file to load from
|
||||
my $strStanzaParam = shift; # Stanza specified on command line
|
||||
|
||||
if (!defined($strFile))
|
||||
# Default for general parameters
|
||||
param_set(PARAM_NO_START_STOP, false); # Do not perform start/stop backup (and archive-required gets set to false)
|
||||
param_set(PARAM_FORCE, false); # Force an action that would not normally be allowed (varies by action)
|
||||
param_set(PARAM_VERSION, false); # Display version and exit
|
||||
param_set(PARAM_HELP, false); # Display help and exit
|
||||
|
||||
# Defaults for test parameters - not for general use
|
||||
param_set(PARAM_TEST_NO_FORK, false); # Prevents the archive process from forking when local archiving is enabled
|
||||
param_set(PARAM_TEST, false); # Enters test mode - not harmful, but adds special logging and pauses for unit testing
|
||||
param_set(PARAM_TEST_DELAY, 5); # Seconds to delay after a test point (default is not enough for manual tests)
|
||||
|
||||
# Get command line parameters
|
||||
GetOptions (\%oParam, PARAM_CONFIG . '=s', PARAM_STANZA . '=s', PARAM_TYPE . '=s', PARAM_NO_START_STOP, PARAM_FORCE,
|
||||
PARAM_VERSION, PARAM_HELP,
|
||||
PARAM_TEST, PARAM_TEST_DELAY . '=s', PARAM_TEST_NO_FORK)
|
||||
or pod2usage(2);
|
||||
|
||||
# Get and validate the operation
|
||||
$strOperation = $ARGV[0];
|
||||
|
||||
if (!defined($strOperation))
|
||||
{
|
||||
$strFile = '/etc/pg_backrest.conf';
|
||||
confess &log(ERROR, 'operation is not defined');
|
||||
}
|
||||
|
||||
ini_load($strFile, \%oConfig);
|
||||
if ($strOperation ne OP_ARCHIVE_GET &&
|
||||
$strOperation ne OP_ARCHIVE_PUSH &&
|
||||
$strOperation ne OP_BACKUP &&
|
||||
$strOperation ne OP_EXPIRE)
|
||||
{
|
||||
confess &log(ERROR, "invalid operation ${strOperation}");
|
||||
}
|
||||
|
||||
# Type should only be specified for backups
|
||||
if (defined(param_get(PARAM_TYPE)) && $strOperation ne OP_BACKUP)
|
||||
{
|
||||
confess &log(ERROR, 'type can only be specified for the backup operation')
|
||||
}
|
||||
|
||||
# Set the backup type
|
||||
if ($strOperation ne OP_BACKUP)
|
||||
{
|
||||
if (!defined(param_get(PARAM_TYPE)))
|
||||
{
|
||||
param_set(PARAM_TYPE, BACKUP_TYPE_INCR);
|
||||
}
|
||||
elsif (param_get(PARAM_TYPE) ne BACKUP_TYPE_FULL && param_get(PARAM_TYPE) ne BACKUP_TYPE_DIFF &&
|
||||
param_get(PARAM_TYPE) ne BACKUP_TYPE_INCR)
|
||||
{
|
||||
confess &log(ERROR, 'backup type must be full, diff (differential), incr (incremental)');
|
||||
}
|
||||
}
|
||||
|
||||
if (!defined(param_get(PARAM_CONFIG)))
|
||||
{
|
||||
param_set(PARAM_CONFIG, '/etc/pg_backrest.conf');
|
||||
}
|
||||
|
||||
ini_load(param_get(PARAM_CONFIG), \%oConfig);
|
||||
|
||||
# Load and check the cluster
|
||||
if (!defined($strStanzaParam))
|
||||
if (!defined(param_get(PARAM_STANZA)))
|
||||
{
|
||||
confess 'a backup stanza must be specified';
|
||||
}
|
||||
@ -105,8 +205,8 @@ sub config_load
|
||||
log_level_set(uc(config_key_load(CONFIG_SECTION_LOG, CONFIG_KEY_LEVEL_FILE, true, INFO)),
|
||||
uc(config_key_load(CONFIG_SECTION_LOG, CONFIG_KEY_LEVEL_CONSOLE, true, ERROR)));
|
||||
|
||||
# Set globals
|
||||
$strStanza = $strStanzaParam;
|
||||
# Set test parameters
|
||||
test_set(param_get(PARAM_TEST), param_get(PARAM_TEST_DELAY));
|
||||
}
|
||||
|
||||
####################################################################################################################################
|
||||
@ -130,13 +230,13 @@ sub config_key_load
|
||||
# Look in the default stanza section
|
||||
if ($strSection eq CONFIG_SECTION_STANZA)
|
||||
{
|
||||
$strValue = $oConfig{"${strStanza}"}{"${strKey}"};
|
||||
$strValue = $oConfig{param_get(PARAM_STANZA)}{"${strKey}"};
|
||||
}
|
||||
# Else look in the supplied section
|
||||
else
|
||||
{
|
||||
# First check the stanza section
|
||||
$strValue = $oConfig{"${strStanza}:${strSection}"}{"${strKey}"};
|
||||
$strValue = $oConfig{param_get(PARAM_STANZA) . ":${strSection}"}{"${strKey}"};
|
||||
|
||||
# If the stanza section value is undefined then check global
|
||||
if (!defined($strValue))
|
||||
@ -168,4 +268,51 @@ sub config_key_load
|
||||
return $strValue;
|
||||
}
|
||||
|
||||
####################################################################################################################################
|
||||
# OPERATION_GET
|
||||
#
|
||||
# Get the current operation.
|
||||
####################################################################################################################################
|
||||
sub operation_get
|
||||
{
|
||||
return $strOperation;
|
||||
}
|
||||
|
||||
####################################################################################################################################
|
||||
# OPERATION_SET
|
||||
#
|
||||
# Set current operation (usually for triggering follow-on operations).
|
||||
####################################################################################################################################
|
||||
sub operation_set
|
||||
{
|
||||
my $strValue = shift;
|
||||
|
||||
$strOperation = $strValue;
|
||||
}
|
||||
|
||||
####################################################################################################################################
|
||||
# PARAM_GET
|
||||
#
|
||||
# Get param value.
|
||||
####################################################################################################################################
|
||||
sub param_get
|
||||
{
|
||||
my $strParam = shift;
|
||||
|
||||
return $oParam{$strParam};
|
||||
}
|
||||
|
||||
####################################################################################################################################
|
||||
# PARAM_SET
|
||||
#
|
||||
# Set param value.
|
||||
####################################################################################################################################
|
||||
sub param_set
|
||||
{
|
||||
my $strParam = shift;
|
||||
my $strValue = shift;
|
||||
|
||||
$oParam{$strParam} = $strValue;
|
||||
}
|
||||
|
||||
1;
|
||||
|
Loading…
Reference in New Issue
Block a user