From d33b655cec733e5d7521911b6fe31dbc9bdc058b Mon Sep 17 00:00:00 2001 From: Andrew Ruthven Date: Sat, 16 Feb 2008 23:12:03 +1300 Subject: [PATCH] Setup the ssh variable for backing up to remote variables. Also sanity check backedhost. Fix up die_gracefully and messages. --- mirror | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/mirror b/mirror index cc70024..e05ccd9 100644 --- a/mirror +++ b/mirror @@ -152,6 +152,19 @@ sub load_config { $c->{'save'}{'days'} = 7; } + if (defined $c->{'remote'}{'host'}) { + die_gracefully("You can't specify both backendhost, and remote host.") + if defined $c->{'backedhost'}; + + die_gracefully("You've specified the remote host, but not the remote login.") + unless defined $c->{'remote'}{'login'}; + + $c->{'rmtssh'} = "ssh " + . (defined $c->{'remote'}{'sshargs'} ? $c->{'remote'}{'sshargs'} . ' ' : '') + . " -l $c->{'remote'}{'login'} $c->{'remote'}{'host'}"; + } + + $c->{'cp'} ||= "cp -alf"; $c->{'weekdir'} = "$c->{'backuproot'}/$c->{'hostid'}/weekly"; $c->{'daydir'} = "$c->{'backuproot'}/$c->{'hostid'}/daily"; @@ -165,6 +178,7 @@ sub load_config { $c->{'lday'} = strftime("image-%Y-%m-%d-%H", localtime() - 3600 * 24); $c->{'1week'} = strftime("image-%Y-%m-%d-%H", localtime() - 3600 * 24 * 7); + return $c; }; @@ -312,13 +326,13 @@ sub run_and_return { sub die_gracefully { my $message = shift; + push @errors, $message + if defined $message; + if ($#errors > 0 || $#warnings > 0 || defined $message) { handle_output($message); } - print "$message\n" - if defined $message; - exit 0; } -- 2.30.2