fix(Anvil): add clean up logic when failed to validate Apache conf after modify

main
Tsu-ba-me 3 years ago
parent d2d7a5380c
commit 92335b29cc
  1. 15
      Anvil/Tools/Striker.pm

@ -220,7 +220,7 @@ sub check_httpd_conf
return(0); 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 } }); $anvil->Log->variables({ source => $THIS_FILE, line => __LINE__, level => $debug, list => { diff_output => $diff_output } });
# Test the new config file before overwriting. # 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} }); $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); return(0);

Loading…
Cancel
Save