1 |
wellsi |
1.1 |
diff -ruN e-smith-base-5.4.0.v61/root/sbin/e-smith/console-menu-items/usbBackup.pl e-smith-base-5.4.0/root/sbin/e-smith/console-menu-items/usbBackup.pl |
2 |
|
|
--- e-smith-base-5.4.0.v61/root/sbin/e-smith/console-menu-items/usbBackup.pl 2008-03-26 09:48:59.000000000 -0700 |
3 |
|
|
+++ e-smith-base-5.4.0/root/sbin/e-smith/console-menu-items/usbBackup.pl 1969-12-31 16:00:00.000000000 -0800 |
4 |
|
|
@@ -1,3 +0,0 @@ |
5 |
|
|
-package esmith::console::perform_backup; |
6 |
|
|
-use esmith::console::perform_backup; |
7 |
|
|
-return new esmith::console::perform_backup; |
8 |
|
|
diff -ruN e-smith-base-5.4.0.v61/root/sbin/e-smith/console-menu-items/usbRestore.pl e-smith-base-5.4.0/root/sbin/e-smith/console-menu-items/usbRestore.pl |
9 |
|
|
--- e-smith-base-5.4.0.v61/root/sbin/e-smith/console-menu-items/usbRestore.pl 2014-03-20 21:35:22.000000000 -0700 |
10 |
|
|
+++ e-smith-base-5.4.0/root/sbin/e-smith/console-menu-items/usbRestore.pl 1969-12-31 16:00:00.000000000 -0800 |
11 |
|
|
@@ -1,3 +0,0 @@ |
12 |
|
|
-package esmith::console::perform_restore; |
13 |
|
|
-use esmith::console::perform_restore; |
14 |
|
|
-return new esmith::console::perform_restore; |
15 |
|
|
diff -ruN e-smith-base-5.4.0.v61/root/usr/share/perl5/vendor_perl/esmith/console/backup_running.pm e-smith-base-5.4.0/root/usr/share/perl5/vendor_perl/esmith/console/backup_running.pm |
16 |
|
|
--- e-smith-base-5.4.0.v61/root/usr/share/perl5/vendor_perl/esmith/console/backup_running.pm 2007-01-26 17:56:31.000000000 -0800 |
17 |
|
|
+++ e-smith-base-5.4.0/root/usr/share/perl5/vendor_perl/esmith/console/backup_running.pm 1969-12-31 16:00:00.000000000 -0800 |
18 |
|
|
@@ -1,62 +0,0 @@ |
19 |
|
|
-package esmith::console::backup_running; |
20 |
|
|
-use strict; |
21 |
|
|
-use warnings; |
22 |
|
|
-use esmith::ConfigDB; |
23 |
|
|
-use Locale::gettext; |
24 |
|
|
- |
25 |
|
|
-sub new |
26 |
|
|
-{ |
27 |
|
|
- my $class = shift; |
28 |
|
|
- my $self = {}; |
29 |
|
|
- bless $self, $class; |
30 |
|
|
- return $self; |
31 |
|
|
-} |
32 |
|
|
- |
33 |
|
|
-sub doit |
34 |
|
|
-{ |
35 |
|
|
- my ($self, $console, $db) = @_; |
36 |
|
|
- #------------------------------------------------------------- |
37 |
|
|
- # check whether a backup in process and incomplete |
38 |
|
|
- #------------------------------------------------------------- |
39 |
|
|
- my $restore_db = esmith::ConfigDB->open_ro("/etc/e-smith/restore"); |
40 |
|
|
- return unless $restore_db; |
41 |
|
|
- |
42 |
|
|
- my $restore_state = $restore_db->get_prop('restore', 'state') |
43 |
|
|
- || 'idle'; |
44 |
|
|
- |
45 |
|
|
- return unless ($restore_state eq 'running'); |
46 |
|
|
- my ($rc, $choice) = $console->message_page |
47 |
|
|
- ( |
48 |
|
|
- title => gettext("Inconsistent system state"), |
49 |
|
|
- text => |
50 |
|
|
- gettext("********** Inconsistent system state detected ***********") . |
51 |
|
|
- "\n\n" . |
52 |
|
|
- gettext("The restoration of a system backup was running and incomplete at the time of the last reboot. The system should not be used in this state.") . |
53 |
|
|
- "\n\n" . |
54 |
|
|
- gettext("Consult the User Guide for further instructions."), |
55 |
|
|
- ); |
56 |
|
|
- |
57 |
|
|
- ($rc, $choice) = $console->yesno_page |
58 |
|
|
- ( |
59 |
|
|
- title => gettext("System will be halted"), |
60 |
|
|
- text => |
61 |
|
|
- gettext("The server will now be halted.") . |
62 |
|
|
- "\n\n" . |
63 |
|
|
- gettext("Consult the User Guide for recovery instructions.") . |
64 |
|
|
- "\n\n" . |
65 |
|
|
- gettext("Do you wish to halt the system right now?"), |
66 |
|
|
- ); |
67 |
|
|
- |
68 |
|
|
- return unless ($rc == 0); |
69 |
|
|
- |
70 |
|
|
- system("/usr/bin/tput", "clear"); |
71 |
|
|
- system("/sbin/e-smith/signal-event", "halt"); |
72 |
|
|
- |
73 |
|
|
- # A bit of a hack to avoid the console restarting before the |
74 |
|
|
- # reboot takes effect. |
75 |
|
|
- |
76 |
|
|
- sleep(600); |
77 |
|
|
-} |
78 |
|
|
- |
79 |
|
|
-1; |
80 |
|
|
- |
81 |
|
|
diff -ruN e-smith-base-5.4.0.v61/root/usr/share/perl5/vendor_perl/esmith/console/perform_backup.pm e-smith-base-5.4.0/root/usr/share/perl5/vendor_perl/esmith/console/perform_backup.pm |
82 |
|
|
--- e-smith-base-5.4.0.v61/root/usr/share/perl5/vendor_perl/esmith/console/perform_backup.pm 2014-03-20 21:35:21.000000000 -0700 |
83 |
|
|
+++ e-smith-base-5.4.0/root/usr/share/perl5/vendor_perl/esmith/console/perform_backup.pm 1969-12-31 16:00:00.000000000 -0800 |
84 |
|
|
@@ -1,257 +0,0 @@ |
85 |
|
|
-package esmith::console::perform_backup; |
86 |
|
|
-use strict; |
87 |
|
|
-use warnings; |
88 |
|
|
-use esmith::ConfigDB; |
89 |
|
|
-use esmith::console; |
90 |
|
|
-use esmith::util; |
91 |
|
|
-use Locale::gettext; |
92 |
|
|
-use esmith::Backup; |
93 |
|
|
-#use Filesys::DiskFree; |
94 |
|
|
-#use Sys::Filesystem; |
95 |
|
|
- |
96 |
|
|
-sub new |
97 |
|
|
-{ |
98 |
|
|
- my $class = shift; |
99 |
|
|
- my $self = { |
100 |
|
|
- name => gettext("Perform backup to removable media"), |
101 |
|
|
- order => 80, |
102 |
|
|
- }; |
103 |
|
|
- bless $self, $class; |
104 |
|
|
- return $self; |
105 |
|
|
-} |
106 |
|
|
- |
107 |
|
|
-sub name |
108 |
|
|
-{ |
109 |
|
|
- return $_[0]->{name}; |
110 |
|
|
-} |
111 |
|
|
- |
112 |
|
|
-sub order |
113 |
|
|
-{ |
114 |
|
|
- return $_[0]->{order}; |
115 |
|
|
-} |
116 |
|
|
- |
117 |
|
|
-sub backup_size |
118 |
|
|
-{ |
119 |
|
|
- my $self = shift; |
120 |
|
|
- |
121 |
|
|
-} |
122 |
|
|
- |
123 |
|
|
-sub make_backup_callback |
124 |
|
|
-{ |
125 |
|
|
- my ($device, $CompressionLevel) = @_; |
126 |
|
|
- return sub { |
127 |
|
|
- my $fh = shift; |
128 |
|
|
- my @backup_list = esmith::Backup->restore_list; |
129 |
|
|
- |
130 |
|
|
- unless (open(DU, "-|")) |
131 |
|
|
- { |
132 |
|
|
- open(STDERR, ">/dev/null"); |
133 |
|
|
- exec qw(/usr/bin/du -sb), map { "/$_" } @backup_list; |
134 |
|
|
- } |
135 |
|
|
- my $backup_size = 0; |
136 |
|
|
- while (<DU>) |
137 |
|
|
- { |
138 |
|
|
- next unless (/^(\d+)/); |
139 |
|
|
- $backup_size += $1; |
140 |
|
|
- } |
141 |
|
|
- close DU; |
142 |
|
|
- |
143 |
|
|
- open(OLDSTDOUT, ">&STDOUT"); |
144 |
|
|
- unless (open(STDOUT, ">/mnt/bootstrap-console-backup/smeserver.tgz")) |
145 |
|
|
- { |
146 |
|
|
- return gettext("Could not create backup file on device").": $!\n"; |
147 |
|
|
- } |
148 |
|
|
- |
149 |
|
|
- open(OLDSTDERR, ">&STDERR"); |
150 |
|
|
- my $logger = open(STDERR, "|-"); |
151 |
|
|
- die "Can't fork: $!\n" unless defined $logger; |
152 |
|
|
- |
153 |
|
|
- unless ($logger) |
154 |
|
|
- { |
155 |
|
|
- exec qw(/usr/bin/logger -p local1.info -t console_backup); |
156 |
|
|
- } |
157 |
|
|
- |
158 |
|
|
- my $status = 0; |
159 |
|
|
- |
160 |
|
|
- my $gzip = open(GZIP, "|-"); |
161 |
|
|
- return "could not run gzip" unless defined $gzip; |
162 |
|
|
- unless ($gzip) |
163 |
|
|
- { |
164 |
|
|
- close $fh; |
165 |
|
|
- exec "gzip", $CompressionLevel; |
166 |
|
|
- } |
167 |
|
|
- |
168 |
|
|
- my $pv = open(PV, "|-"); |
169 |
|
|
- return "could not run pv" unless defined $pv; |
170 |
|
|
- unless ($pv) |
171 |
|
|
- { |
172 |
|
|
- open(STDOUT, ">&GZIP"); |
173 |
|
|
- close GZIP; |
174 |
|
|
- open(STDERR, ">&$fh"); |
175 |
|
|
- exec qw(pv -i 0.2 -n -s), $backup_size |
176 |
|
|
- } |
177 |
|
|
- |
178 |
|
|
- my $tar = fork; |
179 |
|
|
- return "could not run tar" unless defined $tar; |
180 |
|
|
- unless ($tar) |
181 |
|
|
- { |
182 |
|
|
- open(STDOUT, ">&PV"); |
183 |
|
|
- close PV; |
184 |
|
|
- close GZIP; |
185 |
|
|
- close $fh; |
186 |
|
|
- chdir "/"; |
187 |
|
|
- exec qw(tar cf -), grep { -e $_ } @backup_list; |
188 |
|
|
- } |
189 |
|
|
- waitpid($tar, 0); |
190 |
|
|
- warn "status from tar was $?\n" if $?; |
191 |
|
|
- unless (close PV) |
192 |
|
|
- { |
193 |
|
|
- $status |= $! ? $! : $?; |
194 |
|
|
- warn "status from pv is $status\n" if $status; |
195 |
|
|
- } |
196 |
|
|
- unless (close GZIP) |
197 |
|
|
- { |
198 |
|
|
- $status |= $! ? $! : $?; |
199 |
|
|
- warn "status from gzip is $status\n" if $status; |
200 |
|
|
- } |
201 |
|
|
- |
202 |
|
|
- open(STDOUT, ">&OLDSTDOUT"); |
203 |
|
|
- open(STDERR, ">&OLDSTDERR"); |
204 |
|
|
- close(OLDSTDERR); |
205 |
|
|
- close(OLDSTDOUT); |
206 |
|
|
- return $status ? gettext("Backup failed. Look at the log files for more details.") : gettext("Backup successfully created."); |
207 |
|
|
- }; |
208 |
|
|
-} |
209 |
|
|
- |
210 |
|
|
-sub doit |
211 |
|
|
-{ |
212 |
|
|
- my ($self, $console, $db) = @_; |
213 |
|
|
- my @backup_list = esmith::Backup->restore_list; |
214 |
|
|
- |
215 |
|
|
- $ENV{PATH} = "/bin:/usr/bin"; |
216 |
|
|
- $ENV{HOME} = "/root"; |
217 |
|
|
- |
218 |
|
|
- my $compressionLevel = $db->get_prop("backupconsole", "CompressionLevel") || "-6"; |
219 |
|
|
- my ($rc, $choice) = $console->yesno_page |
220 |
|
|
- ( |
221 |
|
|
- title => gettext("Create Backup to removable media"), |
222 |
|
|
- defaultno => 1, |
223 |
|
|
- text => |
224 |
|
|
- gettext("Do you wish to create backup on removable media?"), |
225 |
|
|
- ); |
226 |
|
|
- return unless $rc == 0; |
227 |
|
|
- INITIATE_BACKUP: |
228 |
|
|
- ($rc, $choice) = $console->yesno_page |
229 |
|
|
- ( |
230 |
|
|
- title => gettext("Insert media to use for backup"), |
231 |
|
|
- left => gettext("Next"), |
232 |
|
|
- right => gettext("Cancel"), |
233 |
|
|
- text => |
234 |
|
|
- gettext("Insert removable media, then hit the enter key."), |
235 |
|
|
- ); |
236 |
|
|
- return unless $rc == 0; |
237 |
|
|
- sleep(3); |
238 |
|
|
- my @dirs = (); |
239 |
|
|
- my @labels = (); |
240 |
|
|
- foreach my $udi (qx(hal-find-by-property --key volume.fsusage --string filesystem)) { |
241 |
|
|
- $udi =~ m/^(\S+)/; |
242 |
|
|
- |
243 |
|
|
- my $is_readonly = qx(hal-get-property --udi $1 --key volume.is_mounted_read_only); |
244 |
|
|
- |
245 |
|
|
- if ($is_readonly eq "false\n") { |
246 |
|
|
- |
247 |
|
|
- my $is_mounted = qx(hal-get-property --udi $1 --key volume.is_mounted); |
248 |
|
|
- |
249 |
|
|
- if ($is_mounted eq "false\n") { |
250 |
|
|
- my $blkdev = qx(hal-get-property --udi $1 --key block.device); |
251 |
|
|
- $blkdev =~ m/^(\S+)/; |
252 |
|
|
- push @dirs, $1; |
253 |
|
|
- } |
254 |
|
|
- if ($is_mounted eq "false\n") { |
255 |
|
|
- my $vollbl = qx(hal-get-property --udi $1 --key volume.label); |
256 |
|
|
- $vollbl =~ m/^(\S+)/; |
257 |
|
|
- if ($vollbl =~ /^\s/) {$vollbl = 'nolabel';} |
258 |
|
|
- chomp $vollbl; |
259 |
|
|
- push @labels, lc($vollbl); |
260 |
|
|
- } |
261 |
|
|
- } |
262 |
|
|
- } |
263 |
|
|
- unless ($dirs[0]) |
264 |
|
|
- { |
265 |
|
|
- ($rc, $choice) = $console->message_page |
266 |
|
|
- ( |
267 |
|
|
- title => gettext("Writable backup medium not found"), |
268 |
|
|
- right => gettext("Back"), |
269 |
|
|
- text => |
270 |
|
|
- gettext("No removable and/or writable media or device found"), |
271 |
|
|
- ); |
272 |
|
|
- goto INITIATE_BACKUP; |
273 |
|
|
- } |
274 |
|
|
- mkdir("/mnt/bootstrap-console-backup"); |
275 |
|
|
- |
276 |
|
|
- my $device = $dirs[0]; |
277 |
|
|
- if (defined $dirs[1]) |
278 |
|
|
- { |
279 |
|
|
- my $count=1; |
280 |
|
|
- my @args = map { $count++ . '.' => $_ } @dirs; |
281 |
|
|
- |
282 |
|
|
- my ($rc, $choice) = $console->menu_page |
283 |
|
|
- ( |
284 |
|
|
- title => gettext("Choose device to use for backup"), |
285 |
|
|
- text => ("@dirs \n @labels"), |
286 |
|
|
- argsref => \@args, |
287 |
|
|
- left => gettext("Cancel"), |
288 |
|
|
- right => gettext("OK"), |
289 |
|
|
- ); |
290 |
|
|
- goto INITIATE_BACKUP unless ($rc == 0); |
291 |
|
|
- my %args_hash = ( @args ); |
292 |
|
|
- $device = $args_hash{$choice}; |
293 |
|
|
- } |
294 |
|
|
- system("/bin/mount", "$device", "/mnt/bootstrap-console-backup"); |
295 |
|
|
- |
296 |
|
|
- use File::stat; |
297 |
|
|
- my $st = stat("/mnt/bootstrap-console-backup/smeserver.tgz"); |
298 |
|
|
- if ($st) |
299 |
|
|
- { |
300 |
|
|
-# TODO |
301 |
|
|
-# old backup exists - what do we want to do with it? |
302 |
|
|
- my $size = $st->size; |
303 |
|
|
- |
304 |
|
|
- } |
305 |
|
|
- |
306 |
|
|
- $console->infobox( |
307 |
|
|
- title => gettext("Preparing for backup"), |
308 |
|
|
- text => gettext("Please stand by while the system is prepared for backup..."), |
309 |
|
|
- ); |
310 |
|
|
- |
311 |
|
|
- my $backup_size = 0; |
312 |
|
|
- system("/sbin/e-smith/signal-event", "pre-backup"); |
313 |
|
|
- unless (open(DU, "-|")) |
314 |
|
|
- { |
315 |
|
|
- open(STDERR, ">/dev/null"); |
316 |
|
|
- exec qw(/usr/bin/du -sb), map { "/$_" } @backup_list; |
317 |
|
|
- } |
318 |
|
|
- while (<DU>) |
319 |
|
|
- { |
320 |
|
|
- next unless (/^(\d+)/); |
321 |
|
|
- $backup_size += $1; |
322 |
|
|
- } |
323 |
|
|
- close DU; |
324 |
|
|
- |
325 |
|
|
- $console->gauge(make_backup_callback("/mnt/bootstrap-console-backup",$compressionLevel), 'title' => gettext("Creating backup file")); |
326 |
|
|
- |
327 |
|
|
- system("/bin/umount", "/mnt/bootstrap-console-backup"); |
328 |
|
|
- rmdir("/mnt/bootstrap-console-backup"); |
329 |
|
|
- system("/sbin/e-smith/signal-event", "post-backup"); |
330 |
|
|
- ($rc, $choice) = $console->message_page |
331 |
|
|
- ( |
332 |
|
|
- title => gettext("Backup complete"), |
333 |
|
|
- text => |
334 |
|
|
- gettext("Remove removable media, then hit the enter key."), |
335 |
|
|
- ); |
336 |
|
|
-} |
337 |
|
|
- |
338 |
|
|
-#use esmith::console; |
339 |
|
|
-#esmith::console::perform_backup->new->doit(esmith::console->new, |
340 |
|
|
-# esmith::ConfigDB->open); |
341 |
|
|
-1; |
342 |
|
|
diff -ruN e-smith-base-5.4.0.v61/root/usr/share/perl5/vendor_perl/esmith/console/perform_restore.pm e-smith-base-5.4.0/root/usr/share/perl5/vendor_perl/esmith/console/perform_restore.pm |
343 |
|
|
--- e-smith-base-5.4.0.v61/root/usr/share/perl5/vendor_perl/esmith/console/perform_restore.pm 2014-03-20 21:35:22.000000000 -0700 |
344 |
|
|
+++ e-smith-base-5.4.0/root/usr/share/perl5/vendor_perl/esmith/console/perform_restore.pm 1969-12-31 16:00:00.000000000 -0800 |
345 |
|
|
@@ -1,182 +0,0 @@ |
346 |
|
|
-package esmith::console::perform_restore; |
347 |
|
|
-use strict; |
348 |
|
|
-use warnings; |
349 |
|
|
-use esmith::ConfigDB; |
350 |
|
|
-use esmith::console; |
351 |
|
|
-use Locale::gettext; |
352 |
|
|
- |
353 |
|
|
-sub new |
354 |
|
|
-{ |
355 |
|
|
- my $class = shift; |
356 |
|
|
- my $self = { |
357 |
|
|
- name => gettext("Restore from removable media"), |
358 |
|
|
- order => installOrder(), |
359 |
|
|
- }; |
360 |
|
|
- bless $self, $class; |
361 |
|
|
- return $self; |
362 |
|
|
-} |
363 |
|
|
- |
364 |
|
|
- |
365 |
|
|
-sub name |
366 |
|
|
-{ |
367 |
|
|
- return $_[0]->{name}; |
368 |
|
|
-} |
369 |
|
|
- |
370 |
|
|
-sub order |
371 |
|
|
-{ |
372 |
|
|
- return $_[0]->{order}; |
373 |
|
|
-} |
374 |
|
|
- |
375 |
|
|
-sub doit |
376 |
|
|
-{ |
377 |
|
|
- my ($self, $console, $db) = @_; |
378 |
|
|
- if ($db->get_prop('bootstrap-console', 'Run') eq 'yes') # called from bootstrap console |
379 |
|
|
- { |
380 |
|
|
- return if ($db->get_value('PasswordSet') eq 'yes'); # too late |
381 |
|
|
- } |
382 |
|
|
- return if ($db->get_prop('bootstrap-console', 'Restore') eq 'disabled'); |
383 |
|
|
- my ($rc, $choice) = $console->yesno_page |
384 |
|
|
- ( |
385 |
|
|
- title => gettext("Restore From Backup"), |
386 |
|
|
- defaultno => 1, |
387 |
|
|
- text => |
388 |
|
|
- gettext("Do you wish to restore from backup?"), |
389 |
|
|
- ); |
390 |
|
|
- return unless $rc == 0; |
391 |
|
|
- mkdir("/mnt/bootstrap-console-backup"); |
392 |
|
|
- system("/etc/init.d/messagebus", "start"); |
393 |
|
|
- system("/etc/init.d/haldaemon", "start"); |
394 |
|
|
- INITIATE_RESTORE: |
395 |
|
|
- ($rc, $choice) = $console->yesno_page |
396 |
|
|
- ( |
397 |
|
|
- title => gettext("Insert media containing backup"), |
398 |
|
|
- left => gettext("Next"), |
399 |
|
|
- right => gettext("Cancel"), |
400 |
|
|
- text => |
401 |
|
|
- gettext("Insert removable media containing your backup file, then hit the enter key."), |
402 |
|
|
- ); |
403 |
|
|
- unless ($rc == 0) { |
404 |
|
|
- system("/etc/init.d/haldaemon", "stop"); |
405 |
|
|
- system("/etc/init.d/messagebus", "stop"); |
406 |
|
|
- rmdir("/mnt/bootstrap-console-backup"); |
407 |
|
|
- return; |
408 |
|
|
- } |
409 |
|
|
- sleep(3); |
410 |
|
|
- my @dirs; |
411 |
|
|
- @dirs = (); |
412 |
|
|
- foreach my $udi (qx(hal-find-by-property --key volume.fsusage --string filesystem)) { |
413 |
|
|
- $udi =~ m/^(\S+)/; |
414 |
|
|
- my $is_mounted = qx(hal-get-property --udi $1 --key volume.is_mounted); |
415 |
|
|
- |
416 |
|
|
- if ($is_mounted eq "false\n") { |
417 |
|
|
- my $blkdev = qx(hal-get-property --udi $1 --key block.device); |
418 |
|
|
- $blkdev =~ m/^(\S+)/; |
419 |
|
|
- push @dirs, $1; |
420 |
|
|
- } |
421 |
|
|
- } |
422 |
|
|
- unless ($dirs[0]) |
423 |
|
|
- { |
424 |
|
|
- ($rc, $choice) = $console->message_page |
425 |
|
|
- ( |
426 |
|
|
- title => gettext("Backup medium not found"), |
427 |
|
|
- right => "Try again", |
428 |
|
|
- text => |
429 |
|
|
- gettext("No removable media or device found"), |
430 |
|
|
- ); |
431 |
|
|
- goto INITIATE_RESTORE; |
432 |
|
|
- } |
433 |
|
|
- my $device = $dirs[0]; |
434 |
|
|
- if (defined $dirs[1]) |
435 |
|
|
- { |
436 |
|
|
- my $count=1; |
437 |
|
|
- # FIXME use better regexp |
438 |
|
|
- my @args = map { /(.*)/; $count++ . '.' => $1 } @dirs; |
439 |
|
|
- |
440 |
|
|
- my ($rc, $choice) = $console->menu_page |
441 |
|
|
- ( |
442 |
|
|
- title => gettext("Choose device to restore from"), |
443 |
|
|
- text => gettext("Please select which device contains the backup file you wish to restore from."), |
444 |
|
|
- argsref => \@args, |
445 |
|
|
- left => gettext("Cancel"), |
446 |
|
|
- right => gettext("OK"), |
447 |
|
|
- ); |
448 |
|
|
- goto INITIATE_RESTORE unless ($rc == 0); |
449 |
|
|
- my %args_hash = ( @args ); |
450 |
|
|
- $device = $args_hash{$choice}; |
451 |
|
|
- } |
452 |
|
|
- system("/bin/mount", "$device", "/mnt/bootstrap-console-backup"); |
453 |
|
|
- sleep(1); |
454 |
|
|
- |
455 |
|
|
- unless (-f "/mnt/bootstrap-console-backup/smeserver.tgz") |
456 |
|
|
- { |
457 |
|
|
- system("/bin/umount", "$device"); |
458 |
|
|
- ($rc, $choice) = $console->message_page |
459 |
|
|
- ( |
460 |
|
|
- title => gettext("Backup file not found"), |
461 |
|
|
- right => "Try again", |
462 |
|
|
- text => |
463 |
|
|
- gettext("No backup file found"), |
464 |
|
|
- ); |
465 |
|
|
- goto INITIATE_RESTORE; |
466 |
|
|
- } |
467 |
|
|
- use File::stat; |
468 |
|
|
- my $st = stat("/mnt/bootstrap-console-backup/smeserver.tgz"); |
469 |
|
|
- my $size = $st->size; |
470 |
|
|
- |
471 |
|
|
- ($rc, $choice) = $console->yesno_page |
472 |
|
|
- ( |
473 |
|
|
- title => gettext("Start restore from backup"), |
474 |
|
|
- text => |
475 |
|
|
- gettext("Backup file found:") . " smeserver.tgz ($device) " . |
476 |
|
|
- gettext("size") . " $size " . gettext("bytes") . |
477 |
|
|
- "\n\n" . |
478 |
|
|
- gettext("Do you wish to restore from this file?"), |
479 |
|
|
- ); |
480 |
|
|
- unless ($rc == 0) { |
481 |
|
|
- system("/bin/umount", "$device"); |
482 |
|
|
- goto INITIATE_RESTORE; |
483 |
|
|
- } |
484 |
|
|
- system("/sbin/e-smith/signal-event", "pre-restore"); |
485 |
|
|
- system("(cd / ; cat /mnt/bootstrap-console-backup/smeserver.tgz | |
486 |
|
|
- pv -n -s $size | |
487 |
|
|
- gunzip | |
488 |
|
|
- tar xf - > /dev/null ) 2>&1 | |
489 |
|
|
- dialog --backtitle 'Restoring data' --guage 'Progress' 7 70"); |
490 |
|
|
- system("/bin/umount", "$device"); |
491 |
|
|
- system("/etc/init.d/haldaemon", "stop"); |
492 |
|
|
- system("/etc/init.d/messagebus", "stop"); |
493 |
|
|
- rmdir("/mnt/bootstrap-console-backup"); |
494 |
|
|
- system("/sbin/e-smith/signal-event", "post-upgrade"); |
495 |
|
|
- |
496 |
|
|
- unless ( $self->{bootstrap} ) |
497 |
|
|
- { |
498 |
|
|
- $db->set_prop("bootstrap-console", "Run", "yes"); |
499 |
|
|
- $db->set_prop("bootstrap-console", "ForceSave", "yes"); |
500 |
|
|
- $db->set_prop("bootstrap-console", "Restore", "disabled"); |
501 |
|
|
- |
502 |
|
|
- system("/usr/bin/tput", "clear"); |
503 |
|
|
- system("/sbin/e-smith/signal-event", "reboot"); |
504 |
|
|
- |
505 |
|
|
- # A bit of a hack to avoid the console restarting before the |
506 |
|
|
- # reboot takes effect. |
507 |
|
|
- |
508 |
|
|
- sleep(600); |
509 |
|
|
- } |
510 |
|
|
- return; |
511 |
|
|
-} |
512 |
|
|
- |
513 |
|
|
-# Determine if this server is a fresh install for restore from backup |
514 |
|
|
-# Earlier the expression used was ($db->get_value('PasswordSet') eq 'yes') |
515 |
|
|
-# To prevent a restore return a negative number |
516 |
|
|
-# To allow a restore choose an appropiate sort order, eg 90 |
517 |
|
|
-sub installOrder |
518 |
|
|
-{ |
519 |
|
|
- my $order = (`grep :x:5...: /etc/group`) ? -1 : 90; |
520 |
|
|
- return $order; |
521 |
|
|
-} |
522 |
|
|
- |
523 |
|
|
-#use esmith::console; |
524 |
|
|
-#esmith::console::perform_restore->new->doit(esmith::console->new, |
525 |
|
|
-# esmith::ConfigDB->open); |
526 |
|
|
-1; |
527 |
|
|
- |