From ec192d90414fcf9fb347832e7790514fb7b9f38b Mon Sep 17 00:00:00 2001 From: Digimer Date: Tue, 23 Mar 2021 00:36:17 -0400 Subject: [PATCH] * Fixed a bug where backing up a file on a remote machine returned a failure, if the target backup directory had to be created (even if it was created successfully). * Fixed a bug in a mini bash command to chmod / chown a directory being created on a remote machine. Signed-off-by: Digimer --- Anvil/Tools/Database.pm | 4 +++- Anvil/Tools/Storage.pm | 31 +++++++++++++++++-------------- tools/striker-initialize-host | 2 +- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/Anvil/Tools/Database.pm b/Anvil/Tools/Database.pm index 9b126a1f..88503dc9 100644 --- a/Anvil/Tools/Database.pm +++ b/Anvil/Tools/Database.pm @@ -13606,6 +13606,7 @@ sub manage_anvil_conf secure => 1, target => $target, }); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { anvil_conf => $anvil_conf }}); if ($anvil_conf eq "!!error!!") { @@ -13891,6 +13892,7 @@ sub manage_anvil_conf # Now update! my ($failed) = $anvil->Storage->write_file({ + debug => $debug, secure => 1, file => $anvil->data->{path}{configs}{'anvil.conf'}, body => $new_body, @@ -13906,7 +13908,7 @@ sub manage_anvil_conf $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { failed => $failed }}); if ($failed) { - # Simething went weong. + # Something went weong. return(1); } diff --git a/Anvil/Tools/Storage.pm b/Anvil/Tools/Storage.pm index 5430623f..6072a484 100644 --- a/Anvil/Tools/Storage.pm +++ b/Anvil/Tools/Storage.pm @@ -1223,12 +1223,16 @@ fi"; port => $port, }); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { failed => $failed }}); - $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0170", variables => { - method => "copy_file", - source_file => $source_file, - target_file => $target_file, - }}); - return(1); + if ($failed) + { + # Failed to create the directory, abort. + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0170", variables => { + method => "copy_file", + source_file => $source_file, + target_file => $target_file, + }}); + return(1); + } } # Now backup the file. @@ -1713,28 +1717,27 @@ sub make_directory my $shell_call = " if [ -d '".$working_directory."' ]; then - ".$anvil->data->{path}{exe}{echo}." 'exists' + ".$anvil->data->{path}{exe}{echo}." 'exists' else - ".$anvil->data->{path}{exe}{'mkdir'}." $working_directory + ".$anvil->data->{path}{exe}{'mkdir'}." $working_directory "; if ($mode) { - $shell_call .= " ".$anvil->data->{path}{exe}{'chmod'}." ".$mode."\n"; + $shell_call .= " ".$anvil->data->{path}{exe}{'chmod'}." ".$mode." ".$working_directory."\n"; } if (($user) && ($group)) { - $shell_call .= " ".$anvil->data->{path}{exe}{'chown'}." ".$user.":".$group."\n"; + $shell_call .= " ".$anvil->data->{path}{exe}{'chown'}." ".$user.":".$group." ".$working_directory."\n"; } elsif ($user) { - $shell_call .= " ".$anvil->data->{path}{exe}{'chown'}." ".$user.":\n"; + $shell_call .= " ".$anvil->data->{path}{exe}{'chown'}." ".$user.": ".$working_directory."\n"; } elsif ($group) { - $shell_call .= " ".$anvil->data->{path}{exe}{'chown'}." :".$group."\n"; + $shell_call .= " ".$anvil->data->{path}{exe}{'chown'}." :".$group." ".$working_directory."\n"; } - $shell_call .= " - if [ -d '".$working_directory."' ]; + $shell_call .= " if [ -d '".$working_directory."' ]; then ".$anvil->data->{path}{exe}{echo}." 'created' else diff --git a/tools/striker-initialize-host b/tools/striker-initialize-host index 7a909add..b6f0c8be 100755 --- a/tools/striker-initialize-host +++ b/tools/striker-initialize-host @@ -155,7 +155,7 @@ sub add_databases first => $local_host, second => $target, }); - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { match => $match }}); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { match => $match }}); # We'll sort in reverse order, so if there is a BCN address, we'll use it. my $host_uuid = $anvil->data->{sys}{host_uuid};