* 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::util;
use esmith::lockfile; use esmith::lockfile;
use esmith::BlockDevices;
use constant DEBUG => $ENV{MOJO_SMANAGER_DEBUG} || 0; use constant DEBUG => $ENV{MOJO_SMANAGER_DEBUG} || 0;
our $cdb = esmith::ConfigDB->open || die "Couldn't open config db"; our $cdb = esmith::ConfigDB->open || die "Couldn't open config db";
@ -1576,19 +1578,33 @@ sub get_BackupwkDest_options {
my @usbdisks = (); my @usbdisks = ();
if ( $VFSType eq 'usb' ) { if ( $VFSType eq 'usb' ) {
foreach my $udi (qx(hal-find-by-property --key volume.fsusage --string filesystem)) { my $devices = esmith::BlockDevices->new ('allowmount' => 'disabled');
$udi =~ m/^(\S+)/; my ($valid, $invalid) = $devices->checkBackupDrives(0);
my $is_mounted = qx(hal-get-property --udi $1 --key volume.is_mounted); if ( ${$valid}[0] ) {
foreach ( @{$valid} ) {
if ($is_mounted eq "false\n") { push @usbdisks, $devices->label($_);
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 (!$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]); # return undef unless ($usbdisks[0]);
} }
@ -1985,31 +2001,50 @@ sub dmount {
return ( qx(/bin/mount -t nfs -o nolock "$host:/$share" $mountdir 2>&1) ); return ( qx(/bin/mount -t nfs -o nolock "$host:/$share" $mountdir 2>&1) );
} }
elsif ($VFSType eq 'usb') { elsif ($VFSType eq 'usb') {
my $device = ""; my $device = "";
my $blkdev = "";
my $vollbl = ""; 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") { my $devices = esmith::BlockDevices->new ('allowmount' => 'disabled');
$blkdev = qx(hal-get-property --udi $1 --key block.device); my ($valid, $invalid) = $devices->checkBackupDrives(0);
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; if ( ${$valid}[0] ) {
chomp $blkdev; foreach ( @{$valid} ) {
$vollbl = "media/$vollbl"; $vollbl = $devices->label($_);
if ($vollbl eq $share) { if ( $share eq "media/$vollbl" ) {
$device = $blkdev; $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 { } else {
return ("Error while mounting $host/$share : $VFSType not supported.\n"); 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_TITLE' => 'Backup or restore server data',
'bac_BACKUP_DESC' => '<P>The server provides two ways to back up and restore '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> 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 %define name smeserver-manager
Name: %{name} Name: %{name}
%define version 11.0.0 %define version 11.0.0
%define release 6 %define release 7
Version: %{version} Version: %{version}
Release: %{release}%{?dist} Release: %{release}%{?dist}
License: GPL License: GPL
@ -108,6 +108,9 @@ true
%defattr(-,root,root) %defattr(-,root,root)
%changelog %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 * Mon Apr 29 2024 Brian Read <brianr@koozali.org> 11.0.0-6.sme
- Update layout for table extras [SME: 12656] - Update layout for table extras [SME: 12656]