diff -Nur -x '*.orig' -x '*.rej' e-smith-base-4.18.0/root/sbin/e-smith/console-menu-items/usbBackup.pl mezzanine_patched_e-smith-base-4.18.0/root/sbin/e-smith/console-menu-items/usbBackup.pl --- e-smith-base-4.18.0/root/sbin/e-smith/console-menu-items/usbBackup.pl 1969-12-31 17:00:00.000000000 -0700 +++ mezzanine_patched_e-smith-base-4.18.0/root/sbin/e-smith/console-menu-items/usbBackup.pl 2007-01-29 19:32:00.000000000 -0700 @@ -0,0 +1,3 @@ +package esmith::console::perform_backup; +use esmith::console::perform_backup; +return new esmith::console::perform_backup; diff -Nur -x '*.orig' -x '*.rej' e-smith-base-4.18.0/root/usr/lib/perl5/site_perl/esmith/console/perform_backup.pm mezzanine_patched_e-smith-base-4.18.0/root/usr/lib/perl5/site_perl/esmith/console/perform_backup.pm --- e-smith-base-4.18.0/root/usr/lib/perl5/site_perl/esmith/console/perform_backup.pm 1969-12-31 17:00:00.000000000 -0700 +++ mezzanine_patched_e-smith-base-4.18.0/root/usr/lib/perl5/site_perl/esmith/console/perform_backup.pm 2007-01-29 19:32:44.000000000 -0700 @@ -0,0 +1,149 @@ +package esmith::console::perform_backup; +use strict; +use warnings; +use esmith::ConfigDB; +use esmith::console; +use esmith::util; +use Locale::gettext; +use esmith::Backup; +#use Filesys::DiskFree; +#use Sys::Filesystem; + +sub new +{ + my $class = shift; + my $self = { + name => "Perform backup to USB device", + order => 80, + }; + bless $self, $class; + return $self; +} + +sub name +{ + return $_[0]->{name}; +} + +sub order +{ + return -1 if (defined $ARGV [0]); + + return $_[0]->{order}; +} + +sub backup_size +{ + my $self = shift; + +} + +sub doit +{ + my ($self, $console, $db) = @_; + my @backup_list = esmith::Backup->restore_list; + + $ENV{PATH} = "/bin:/usr/bin"; + + my ($rc, $choice) = $console->yesno_page + ( + title => gettext("Create Backup to USB disk"), + defaultno => 1, + text => + gettext("Do you wish to create backup on USB device?"), + ); + return unless $rc == 0; + INITIATE_BACKUP: + ($rc, $choice) = $console->message_page + ( + title => gettext("Insert media to use for backup"), + text => + gettext("Insert memory stick or USB disk, then hit the enter key."), + ); + sleep(3); + my @dirs = map { m:^(/media/usbdisk*):; $1 } glob '/media/usbdisk*'; + unless ($dirs[0]) + { + ($rc, $choice) = $console->message_page + ( + title => gettext("Backup medium not found"), + right => "Try again", + text => + gettext("No removable media or device found"), + ); + goto INITIATE_BACKUP; + } + my $device = $dirs[0]; + if (defined $dirs[1]) + { + my $count=1; + my @args = map { $count++ . '.' => $_ } @dirs; + + my ($rc, $choice) = $console->menu_page + ( + title => gettext("Choose device to use for backup"), + text => gettext("Please select which device should be used for the backup file."), + argsref => \@args, + left => gettext("Cancel"), + right => gettext("OK"), + ); + goto INITIATE_BACKUP unless ($rc == 0); + my %args_hash = ( @args ); + $device = $args_hash{$choice}; + } + system("/bin/mount", "$device"); + use File::stat; + my $st = stat("$device/smeserver.tgz"); + if ($st) + { +# TODO +# old backup exists - what do we want to do with it? + my $size = $st->size; + + } + +# XXX-FIXME +# We call dialog directly (rather than through the screen function) +# as we don't want the --clear parameter passed by screen(). +# Appropriate magic can clean this up. +system( + "/usr/bin/dialog", + "--backtitle", $console->backtitle, + "--title", gettext("Preparing for backup"), + "--infobox", gettext("Please standby while the system is " . + "prepared for backup ..."), + 8, esmith::console::SCREEN_COLUMNS, + ); + + my $backup_size = 0; + system("/sbin/e-smith/signal-event", "pre-backup"); + unless (open(DU, "-|")) + { + open(STDERR, ">/dev/null"); + exec qw(/usr/bin/du -sb), map { "/$_" } @backup_list; + } + while () + { + next unless (/^(\d+)/); + $backup_size += $1; + } + close DU; + + system("(cd / ; tar cf - " . join(' ', @backup_list) . " | + pv -i 0.2 -n -s $backup_size | + gzip -9 > /$device/smeserver.tgz ) 2>&1 | + dialog --backtitle 'Creating backup file' --guage 'Progress' 7 70"); + system("/bin/umount", "$device"); + system("/sbin/e-smith/signal-event", "post-backup"); + ($rc, $choice) = $console->message_page + ( + title => gettext("Backup complete"), + text => + gettext("Remove memory stick or USB disk, then hit the enter key."), + ); +} + +#use esmith::console; +#esmith::console::perform_backup->new->doit(esmith::console->new, +# esmith::ConfigDB->open); +1;