]> git.etc.gen.nz Git - mirror-perl.git/commitdiff
Setup the ssh variable for backing up to remote variables. Also sanity check backedhost.
authorAndrew Ruthven <andrew@etc.gen.nz>
Sat, 16 Feb 2008 10:12:03 +0000 (23:12 +1300)
committerAndrew Ruthven <andrew@etc.gen.nz>
Sat, 16 Feb 2008 10:12:03 +0000 (23:12 +1300)
Fix up die_gracefully and messages.

mirror

diff --git a/mirror b/mirror
index cc70024786214abcb8363a2316cc39d5847c2514..e05ccd9c86e457429f15cd5f6a2a9e174b659dbd 100644 (file)
--- 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;
 }