diff --git a/root/usr/share/smanager/lib/SrvMngr/Controller/Backup.pm b/root/usr/share/smanager/lib/SrvMngr/Controller/Backup.pm index fea76c7..30328ec 100644 --- a/root/usr/share/smanager/lib/SrvMngr/Controller/Backup.pm +++ b/root/usr/share/smanager/lib/SrvMngr/Controller/Backup.pm @@ -37,6 +37,8 @@ use esmith::BackupHistoryDB; use esmith::util; use esmith::lockfile; +use esmith::BlockDevices; + use constant DEBUG => $ENV{MOJO_SMANAGER_DEBUG} || 0; our $cdb = esmith::ConfigDB->open || die "Couldn't open config db"; @@ -1576,19 +1578,33 @@ sub get_BackupwkDest_options { my @usbdisks = (); if ( $VFSType eq 'usb' ) { - foreach my $udi (qx(hal-find-by-property --key volume.fsusage --string filesystem)) { - $udi =~ m/^(\S+)/; + my $devices = esmith::BlockDevices->new ('allowmount' => 'disabled'); + my ($valid, $invalid) = $devices->checkBackupDrives(0); - my $is_mounted = qx(hal-get-property --udi $1 --key volume.is_mounted); - - if ($is_mounted eq "false\n") { - my $vollbl = qx(hal-get-property --udi $1 --key volume.label); - $vollbl =~ m/^(\S+)/; - if ($vollbl =~ /^\s/) {$vollbl = 'nolabel';} - chomp $vollbl; - push @usbdisks, $vollbl; + if ( ${$valid}[0] ) { + foreach ( @{$valid} ) { + push @usbdisks, $devices->label($_); } } + + if (!$usbdisks[0]){ + push (@usbdisks,$c->l('bac_No suitable local devices found')); + } + $devices->destroy; + + #foreach my $udi (qx(hal-find-by-property --key volume.fsusage --string filesystem)) { + #$udi =~ m/^(\S+)/; + + #my $is_mounted = qx(hal-get-property --udi $1 --key volume.is_mounted); + + #if ($is_mounted eq "false\n") { + #my $vollbl = qx(hal-get-property --udi $1 --key volume.label); + #$vollbl =~ m/^(\S+)/; + #if ($vollbl =~ /^\s/) {$vollbl = 'nolabel';} + #chomp $vollbl; + #push @usbdisks, $vollbl; + #} + #} # return undef unless ($usbdisks[0]); } @@ -1985,31 +2001,50 @@ sub dmount { return ( qx(/bin/mount -t nfs -o nolock "$host:/$share" $mountdir 2>&1) ); } elsif ($VFSType eq 'usb') { - my $device = ""; - my $blkdev = ""; + my $device = ""; my $vollbl = ""; - foreach my $udi (qx(hal-find-by-property --key volume.fsusage --string filesystem)) { - $udi =~ m/^(\S+)/; - my $is_mounted = qx(hal-get-property --udi $1 --key volume.is_mounted); - if ($is_mounted eq "false\n") { - $blkdev = qx(hal-get-property --udi $1 --key block.device); - if ($blkdev =~ m/^(\S+)/) {$blkdev = $1;} - } - if ($is_mounted eq "false\n") { - $vollbl = qx(hal-get-property --udi $1 --key volume.label); - $vollbl =~ m/^(\S+)/; - if ($vollbl =~ /^\s/) {$vollbl = 'nolabel';} - } + my $devices = esmith::BlockDevices->new ('allowmount' => 'disabled'); + my ($valid, $invalid) = $devices->checkBackupDrives(0); - chomp $vollbl; - chomp $blkdev; - $vollbl = "media/$vollbl"; - if ($vollbl eq $share) { - $device = $blkdev; - } + if ( ${$valid}[0] ) { + foreach ( @{$valid} ) { + $vollbl = $devices->label($_); + if ( $share eq "media/$vollbl" ) { + $device = "/dev/$_"; + } + } } - return ( qx(/bin/mount $device "/$share" 2>&1) ); + $devices->destroy; + return ( qx (mount $device /$share 2>&1) ); + +#------------------------------------------------------------------------------------------------------- + #my $device = ""; + #my $blkdev = ""; + #my $vollbl = ""; + #foreach my $udi (qx(hal-find-by-property --key volume.fsusage --string filesystem)) { + #$udi =~ m/^(\S+)/; + #my $is_mounted = qx(hal-get-property --udi $1 --key volume.is_mounted); + + #if ($is_mounted eq "false\n") { + #$blkdev = qx(hal-get-property --udi $1 --key block.device); + #if ($blkdev =~ m/^(\S+)/) {$blkdev = $1;} + #} + #if ($is_mounted eq "false\n") { + #$vollbl = qx(hal-get-property --udi $1 --key volume.label); + #$vollbl =~ m/^(\S+)/; + #if ($vollbl =~ /^\s/) {$vollbl = 'nolabel';} + #} + + #chomp $vollbl; + #chomp $blkdev; + #$vollbl = "media/$vollbl"; + #if ($vollbl eq $share) { + #$device = $blkdev; + #} + #} + #return ( qx(/bin/mount $device "/$share" 2>&1) ); +#------------------------------------------------------------------------------------------------------- } else { return ("Error while mounting $host/$share : $VFSType not supported.\n"); } diff --git a/root/usr/share/smanager/lib/SrvMngr/I18N/Modules/Backup/backup_en.lex b/root/usr/share/smanager/lib/SrvMngr/I18N/Modules/Backup/backup_en.lex index 3bfe55e..aea1343 100644 --- a/root/usr/share/smanager/lib/SrvMngr/I18N/Modules/Backup/backup_en.lex +++ b/root/usr/share/smanager/lib/SrvMngr/I18N/Modules/Backup/backup_en.lex @@ -1,3 +1,4 @@ +'bac_No suitable local devices found' => 'No suitable local devices found', 'bac_BACKUP_TITLE' => 'Backup or restore server data', 'bac_BACKUP_DESC' => '
The server provides two ways to back up and restore your server: using your local desktop or a tape drive.
diff --git a/smeserver-manager.spec b/smeserver-manager.spec index bc60330..d7309c1 100644 --- a/smeserver-manager.spec +++ b/smeserver-manager.spec @@ -2,7 +2,7 @@ Summary: Sme server navigation module : manager 2 %define name smeserver-manager Name: %{name} %define version 11.0.0 -%define release 6 +%define release 7 Version: %{version} Release: %{release}%{?dist} License: GPL @@ -108,6 +108,9 @@ true %defattr(-,root,root) %changelog +* Tue Apr 30 2024 Brian Read