1 |
filippocarletti |
1.1 |
--- e-smith-base-5.2.0-old/root/usr/lib/perl5/site_perl/esmith/console/perform_restore.pm.orig 2008-03-26 17:49:00.000000000 +0100 |
2 |
|
|
+++ e-smith-base-5.2.0/root/usr/lib/perl5/site_perl/esmith/console/perform_restore.pm 2010-01-13 16:03:01.000000000 +0100 |
3 |
|
|
@@ -25,6 +25,7 @@ |
4 |
|
|
gettext("Do you wish to restore from backup?"), |
5 |
|
|
); |
6 |
|
|
return unless $rc == 0; |
7 |
|
|
+ mkdir("/mnt/bootstrap-console-backup"); |
8 |
|
|
system("/etc/init.d/messagebus", "start"); |
9 |
|
|
system("/etc/init.d/haldaemon", "start"); |
10 |
|
|
INITIATE_RESTORE: |
11 |
|
|
@@ -39,19 +40,22 @@ |
12 |
|
|
unless ($rc == 0) { |
13 |
|
|
system("/etc/init.d/haldaemon", "stop"); |
14 |
|
|
system("/etc/init.d/messagebus", "stop"); |
15 |
|
|
+ rmdir("/mnt/bootstrap-console-backup"); |
16 |
|
|
return; |
17 |
|
|
} |
18 |
|
|
sleep(3); |
19 |
|
|
my @dirs; |
20 |
|
|
@dirs = (); |
21 |
|
|
- open(FSTAB, "</etc/fstab"); |
22 |
|
|
- while (<FSTAB>) |
23 |
|
|
- { |
24 |
|
|
- next unless m:^(\S+)\s+(/media/\S+)\s+(\S+)\s+(\S+):; |
25 |
|
|
- my ($dev, $mount, $filesys, $options) = ($1, $2, $3, $4); |
26 |
|
|
- push @dirs, $mount; |
27 |
|
|
+ foreach my $udi (qx(hal-find-by-property --key volume.fsusage --string filesystem)) { |
28 |
|
|
+ $udi =~ m/^(\S+)/; |
29 |
|
|
+ my $is_mounted = qx(hal-get-property --udi $1 --key volume.is_mounted); |
30 |
|
|
+ |
31 |
|
|
+ if ($is_mounted eq "false\n") { |
32 |
|
|
+ my $blkdev = qx(hal-get-property --udi $1 --key block.device); |
33 |
|
|
+ $blkdev =~ m/^(\S+)/; |
34 |
|
|
+ push @dirs, $1; |
35 |
|
|
+ } |
36 |
|
|
} |
37 |
|
|
- close FSTAB; |
38 |
|
|
unless ($dirs[0]) |
39 |
|
|
{ |
40 |
|
|
($rc, $choice) = $console->message_page |
41 |
|
|
@@ -82,10 +86,10 @@ |
42 |
|
|
my %args_hash = ( @args ); |
43 |
|
|
$device = $args_hash{$choice}; |
44 |
|
|
} |
45 |
|
|
- system("/bin/mount", "$device"); |
46 |
|
|
+ system("/bin/mount", "$device", "/mnt/bootstrap-console-backup"); |
47 |
|
|
sleep(1); |
48 |
|
|
|
49 |
|
|
- unless (-f "$device/smeserver.tgz") |
50 |
|
|
+ unless (-f "/mnt/bootstrap-console-backup/smeserver.tgz") |
51 |
|
|
{ |
52 |
|
|
system("/bin/umount", "$device"); |
53 |
|
|
($rc, $choice) = $console->message_page |
54 |
|
|
@@ -98,14 +102,14 @@ |
55 |
|
|
goto INITIATE_RESTORE; |
56 |
|
|
} |
57 |
|
|
use File::stat; |
58 |
|
|
- my $st = stat("$device/smeserver.tgz"); |
59 |
|
|
+ my $st = stat("/mnt/bootstrap-console-backup/smeserver.tgz"); |
60 |
|
|
my $size = $st->size; |
61 |
|
|
|
62 |
|
|
($rc, $choice) = $console->yesno_page |
63 |
|
|
( |
64 |
|
|
title => gettext("Start restore from backup"), |
65 |
|
|
text => |
66 |
|
|
- gettext("Backup file found:") . " $device/smeserver.tgz " . |
67 |
|
|
+ gettext("Backup file found:") . " smeserver.tgz ($device) " . |
68 |
|
|
gettext("size") . " $size " . gettext("bytes") . |
69 |
|
|
"\n\n" . |
70 |
|
|
gettext("Do you wish to restore from this file?"), |
71 |
|
|
@@ -115,7 +119,7 @@ |
72 |
|
|
goto INITIATE_RESTORE; |
73 |
|
|
} |
74 |
|
|
system("/sbin/e-smith/signal-event", "pre-restore"); |
75 |
|
|
- system("(cd / ; cat $device/smeserver.tgz | |
76 |
|
|
+ system("(cd / ; cat /mnt/bootstrap-console-backup/smeserver.tgz | |
77 |
|
|
pv -n -s $size | |
78 |
|
|
gunzip | |
79 |
|
|
tar xf - > /dev/null ) 2>&1 | |
80 |
|
|
@@ -124,6 +128,7 @@ |
81 |
|
|
system("/bin/umount", "$device"); |
82 |
|
|
system("/etc/init.d/haldaemon", "stop"); |
83 |
|
|
system("/etc/init.d/messagebus", "stop"); |
84 |
|
|
+ rmdir("/mnt/bootstrap-console-backup"); |
85 |
|
|
} |
86 |
|
|
|
87 |
|
|
#use esmith::console; |