* Fixed (the very incomplete) anvil-manage-firewall so that it would clear a job, if a job was assigned to it.

Signed-off-by: digimer <digimer@gravitar.alteeve.com>
main
digimer 2 years ago
parent 76c8088aee
commit 0318b4bbe9
  1. 35
      tools/anvil-manage-firewall
  2. 3
      tools/anvil-provision-server

@ -39,22 +39,21 @@ if (($running_directory =~ /^\./) && ($ENV{PWD}))
my $anvil = Anvil::Tools->new(); my $anvil = Anvil::Tools->new();
# If the user has disabled auto-management of the firewall, exit. # Read switches
if (not $anvil->data->{sys}{manage}{firewall}) $anvil->Get->switches({list => [
'job-uuid',
"server"], man => $THIS_FILE});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => $anvil->data->{switches}});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0115", variables => { program => $THIS_FILE }});
$anvil->Database->connect();
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, secure => 0, key => "log_0132" });
if (not $anvil->data->{sys}{database}{connections})
{ {
# Do nothing. # No databases, exit.
$anvil->nice_exit({exit_code => 0}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, 'print' => 1, priority => "err", key => "error_0003"});
$anvil->nice_exit({exit_code => 1});
} }
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 3, secure => 0, key => "log_0115", variables => { program => $THIS_FILE }});
# Read switches
$anvil->data->{switches}{'job-uuid'} = "";
$anvil->data->{switches}{server} = "";
$anvil->Get->switches;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
'switches::job-uuid' => $anvil->data->{switches}{'job-uuid'},
'switches::server' => $anvil->data->{switches}{server},
}});
# Log our start. # Log our start.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "message_0134"}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "message_0134"});
@ -91,6 +90,14 @@ if ($anvil->data->{switches}{'job-uuid'})
} }
exit(0); exit(0);
# If the user has disabled auto-management of the firewall, exit.
if (not $anvil->data->{sys}{manage}{firewall})
{
# Do nothing.
$anvil->nice_exit({exit_code => 0});
}
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 3, secure => 0, key => "log_0115", variables => { program => $THIS_FILE }});
# This used to do all the work, but that's now moved to the method below. So all we do here now is call it. # This used to do all the work, but that's now moved to the method below. So all we do here now is call it.
$anvil->Network->manage_firewall(); $anvil->Network->manage_firewall();
if ($anvil->data->{switches}{'job-uuid'}) if ($anvil->data->{switches}{'job-uuid'})

@ -32,8 +32,7 @@ $| = 1;
my $anvil = Anvil::Tools->new(); my $anvil = Anvil::Tools->new();
# Read switches (target ([user@]host[:port]) and the file with the target's password. If the password is # Read switches
# passed directly, it will be used. Otherwise, the password will be read from the database.
$anvil->Get->switches({list => [ $anvil->Get->switches({list => [
"anvil", "anvil",
"anvil-name", "anvil-name",

Loading…
Cancel
Save