* Tue Apr 30 2024 Brian Read <brianr@koozali.org> 11.0.0-7.sme

- Remove use of hel command and replace by call to BlockDevices lib [SME: 12644]
This commit is contained in:
Brian Read 2024-04-30 18:23:52 +01:00
parent e7d7b6afb8
commit 891fc73ce3
3 changed files with 71 additions and 32 deletions

View File

@ -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]);
}
@ -1986,30 +2002,49 @@ sub dmount {
}
elsif ($VFSType eq 'usb') {
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';}
}
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");
}

View File

@ -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' => '<P>The server provides two ways to back up and restore
your server: using your local desktop or a tape drive.</P>

View File

@ -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 <brianr@koozali.org> 11.0.0-7.sme
- Remove use of hel command and replace by call to BlockDevices lib [SME: 12644]
* Mon Apr 29 2024 Brian Read <brianr@koozali.org> 11.0.0-6.sme
- Update layout for table extras [SME: 12656]