aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2020-01-20 11:56:03 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2020-01-20 11:56:03 +0200
commit2dbd1f123e2c9dd5d81513ef0b2d6443bf5edde3 (patch)
treed5f56ec364216c50fb0fb1473e488b1576187556
parentc4bcbcbfd6cce382249f16b1f536484d98842e3d (diff)
downloadacmeman-2dbd1f123e2c9dd5d81513ef0b2d6443bf5edde3.tar.gz
acmeman-2dbd1f123e2c9dd5d81513ef0b2d6443bf5edde3.tar.bz2
Create backup copies of Apache configuration files during setup on Slackware.
-rw-r--r--lib/App/Acmeman/Apache/Layout/slackware.pm10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/App/Acmeman/Apache/Layout/slackware.pm b/lib/App/Acmeman/Apache/Layout/slackware.pm
index d09017a..fd9ea31 100644
--- a/lib/App/Acmeman/Apache/Layout/slackware.pm
+++ b/lib/App/Acmeman/Apache/Layout/slackware.pm
@@ -2,12 +2,13 @@ package App::Acmeman::Apache::Layout::slackware;
use strict;
use warnings;
use Carp;
use parent 'App::Acmeman::Apache::Layout';
use Apache::Config::Preproc;
use App::Acmeman::Log qw(:all);
+use File::BackupCopy;
our $PRIORITY = 10;
sub new {
my $class = shift;
my $ap = shift;
@@ -172,13 +173,20 @@ sub run_commands_for_file {
}
if (@commands) {
error((0+@commands) . " left unmatched in edit queue for file $file");
error("$file left unchanged");
} else {
- # FIXME: backup/rollback
+ my $backup_name = backup_copy($app->filename, error => \my $error);
+ if ($backup_name) {
+ debug(1, "modifying ".$app->filename."; prior version saved in $backup_name");
+ } elsif ($error) {
+ error("can't backup ".$app->filename.": $error");
+ error("file left unchanged");
+ return;
+ }
$app->save;
}
}
sub _replace_directive_at {
my ($self, $app, $node, $text) = @_;

Return to:

Send suggestions and report system problems to the System administrator.