added shell escape and removed the debug comments stable
authorHeiko Schlittermann <hs@schlittermann.de>
Mon, 01 Feb 2010 00:27:40 +0100
branchstable
changeset 39 06bffc9d8977
parent 38 38af4add892a
child 41 24d57a2e8df7
added shell escape and removed the debug comments
is
lib/SI/dumper.pm
lib/SI/grub.pm
--- a/is	Mon Feb 01 00:07:30 2010 +0100
+++ b/is	Mon Feb 01 00:27:40 2010 +0100
@@ -45,15 +45,14 @@
     do "$src/info/devices";
     my %devices = %$VAR1;
 
-    #SI::ptable::restore(%devices);
-    #SI::ptable::mkfs(%devices);
-    #SI::lvm::pvcreate(%devices);
-    #SI::lvm::vgcfgrestore("$src/lvm/vg.*", %devices);
-    #SI::lvm::mkfs(%devices);
-    #SI::dumper::restore("$src/dump/*", %devices);
+    SI::ptable::restore(%devices);
+    SI::ptable::mkfs(%devices);
+    SI::lvm::pvcreate(%devices);
+    SI::lvm::vgcfgrestore("$src/lvm/vg.*", %devices);
+    SI::lvm::mkfs(%devices);
+    SI::dumper::restore("$src/dump/*", %devices);
     SI::grub::restore(%devices);
 
-
     exit;
     die Dumper \%devices;
 
--- a/lib/SI/dumper.pm	Mon Feb 01 00:07:30 2010 +0100
+++ b/lib/SI/dumper.pm	Mon Feb 01 00:27:40 2010 +0100
@@ -31,7 +31,7 @@
     my @dumps = glob(shift);
     my $devs = shift;
 
-    my $tmpdir = tempdir (CLEANUP => 1);
+    my $tmpdir = tempdir (CLEANUP => 0);
 
     foreach my $dump (@dumps) {
 	# suppose it's gzipped
@@ -48,15 +48,20 @@
 
 	verbose("restore $dump -> $dev : $fs\n");
 	run("mount -t $fs $dev $tmpdir");
-	my $pid = fork or do {
-	    open(STDIN, $dump) or die "Can't open $dump as STDIN: $!\n";
-	    chdir $tmpdir  or die "Can't chdir to $tmpdir: $!\n";
-	    exec restore => "-orf-";
-	    die "Can't exec restore: $!\n";
+
+	eval {
+		my $pid = fork or do {
+		    open(STDIN, $dump) or die "Can't open $dump as STDIN: $!\n";
+		    chdir $tmpdir  or die "Can't chdir to $tmpdir: $!\n";
+		    exec restore => "-orf-";
+		    die "Can't exec restore: $!\n";
+		};
+		waitpid($pid, 0);
 	};
-	waitpid($pid, 0);
 	run("umount $tmpdir");
+	die $@ if $@;
     }
+    rmdir($tmpdir);
 }
 
 
--- a/lib/SI/grub.pm	Mon Feb 01 00:07:30 2010 +0100
+++ b/lib/SI/grub.pm	Mon Feb 01 00:27:40 2010 +0100
@@ -58,7 +58,8 @@
 
 	run("chroot $tmpdir grub-mkdevicemap");
 	run("chroot $tmpdir /usr/sbin/grub-install '(hd0)'");
-	#system("/bin/bash --login");
+	system("/bin/bash --login")
+		if $ENV{_SHELL};
     };
     if ($@) {
 	warn "** EVAL: $@\n";