diff --git a/tools/anvil-manage-firewall b/tools/anvil-manage-firewall index b40cc75d..707cb59e 100755 --- a/tools/anvil-manage-firewall +++ b/tools/anvil-manage-firewall @@ -39,22 +39,21 @@ if (($running_directory =~ /^\./) && ($ENV{PWD})) my $anvil = Anvil::Tools->new(); -# If the user has disabled auto-management of the firewall, exit. -if (not $anvil->data->{sys}{manage}{firewall}) +# Read switches +$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. - $anvil->nice_exit({exit_code => 0}); + # No databases, exit. + $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. $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); +# 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. $anvil->Network->manage_firewall(); if ($anvil->data->{switches}{'job-uuid'}) @@ -176,4 +183,4 @@ sub wait_for_server } return(0); -} \ No newline at end of file +} diff --git a/tools/anvil-provision-server b/tools/anvil-provision-server index 7b8608e5..a4cfe4cc 100755 --- a/tools/anvil-provision-server +++ b/tools/anvil-provision-server @@ -32,8 +32,7 @@ $| = 1; my $anvil = Anvil::Tools->new(); -# Read switches (target ([user@]host[:port]) and the file with the target's password. If the password is -# passed directly, it will be used. Otherwise, the password will be read from the database. +# Read switches $anvil->Get->switches({list => [ "anvil", "anvil-name",