mirror of
https://github.com/ovh/the-bastion.git
synced 2025-02-26 16:43:03 +08:00
enh: osh-piv-grace-reaper: run only on master, standardize config reading
This commit is contained in:
parent
7fa2523bfc
commit
572ced2af7
1 changed files with 17 additions and 7 deletions
|
@ -8,8 +8,17 @@ use OVH::Bastion;
|
|||
use OVH::Result;
|
||||
use OVH::SimpleLog;
|
||||
|
||||
# this'll be used in syslog
|
||||
$ENV{'UNIQID'} = OVH::Bastion::generate_uniq_id()->value;
|
||||
|
||||
my $fnret;
|
||||
|
||||
# abort early if we're not a master instance
|
||||
if (OVH::Bastion::config('readOnlySlaveMode')->value) {
|
||||
_log "We're not a master instance, don't do anything";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
$fnret = OVH::Bastion::load_configuration_file(
|
||||
file => OVH::Bastion::main_configuration_directory() . "/osh-piv-grace-reaper.conf",
|
||||
secure => 1,
|
||||
|
@ -17,13 +26,18 @@ $fnret = OVH::Bastion::load_configuration_file(
|
|||
);
|
||||
|
||||
my $config;
|
||||
if (not $fnret) {
|
||||
_err "Error while loading configuration, continuing anyway with default values...";
|
||||
if (!$fnret) {
|
||||
if (-e OVH::Bastion::main_configuration_directory() . "/osh-piv-grace-reaper.conf") {
|
||||
_warn "Error while loading configuration, continuing anyway with default values...";
|
||||
}
|
||||
else {
|
||||
_log "No configuration file found, using default config values...";
|
||||
}
|
||||
}
|
||||
else {
|
||||
$config = $fnret->value;
|
||||
if (ref $config ne 'HASH') {
|
||||
_err "Invalid data returned while loading configuration, continuing anyway with default values...";
|
||||
_warn "Invalid data returned while loading configuration, continuing anyway with default values...";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,10 +58,6 @@ if (!$fnret) {
|
|||
_err "Couldn't get account list: " . $fnret->msg;
|
||||
exit 1;
|
||||
}
|
||||
|
||||
# this'll be used in syslog
|
||||
$ENV{'UNIQID'} = OVH::Bastion::generate_uniq_id()->value;
|
||||
|
||||
foreach my $account (sort keys %{$fnret->value}) {
|
||||
|
||||
# if account doesn't have PIV grace, we have nothing to do
|
||||
|
|
Loading…
Reference in a new issue