From 92335b29ccd4ad0e41ac754b33aa7bea2a261d0a Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Wed, 28 Jul 2021 19:29:24 -0400 Subject: [PATCH] fix(Anvil): add clean up logic when failed to validate Apache conf after modify --- Anvil/Tools/Striker.pm | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Anvil/Tools/Striker.pm b/Anvil/Tools/Striker.pm index cf6121f8..68228d45 100644 --- a/Anvil/Tools/Striker.pm +++ b/Anvil/Tools/Striker.pm @@ -220,7 +220,7 @@ sub check_httpd_conf return(0); } - my $diff_output = diff $anvil->data->{path}{data}{httpd_conf}, $new_httpd_conf, { STYLE => 'Unified' }; + my $diff_output = diff $anvil->data->{path}{data}{httpd_conf}, $new_httpd_conf, { STYLE => 'Unified' }; $anvil->Log->variables({ source => $THIS_FILE, line => __LINE__, level => $debug, list => { diff_output => $diff_output } }); # Test the new config file before overwriting. @@ -254,6 +254,19 @@ sub check_httpd_conf $anvil->System->restart_daemon({ debug => $debug, daemon => $anvil->data->{sys}{daemon}{httpd} }); } + else + { + # Found issues during the test; clean up. + + $write_shell_call = $anvil->data->{path}{exe}{rm}." -f ".$new_httpd_conf; + + ($shell_output, $shell_return_code) = $anvil->System->call({ shell_call => $write_shell_call }); + $anvil->Log->variables({ source => $THIS_FILE, line => __LINE__, level => $debug, list => { + shell_call => $write_shell_call, + shell_output => $shell_output, + shell_return_code => $shell_return_code + } }); + } } return(0);