diff -ruN e-smith-backup-2.4.0.p34/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/backup e-smith-backup-2.4.0/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/backup --- e-smith-backup-2.4.0.p34/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/backup 2014-04-20 15:59:00.000000000 -0700 +++ e-smith-backup-2.4.0/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/backup 2014-04-20 22:21:41.000000000 -0700 @@ -809,6 +809,10 @@ Backup is made on local removable disk + WORKSTN_BACKUP_MNT + Backup is made on mounted disk + + WORKSTN_BACKUP_HOST Backup is made on LAN workstation @@ -870,7 +874,11 @@ ERR_NO_USB_DISK - Error : No removable disk available. Please connect an removable disk or select another type of backup share. + Error : No removable disk available. Please connect a removable disk or select another type of workstation backup. + + + ERR_NO_MOUNTED_DISK + Error : No mounted disk available. Please mount a disk or select another type of workstation backup. HOURS @@ -914,7 +922,11 @@ local removable disk - local removable disk + Local removable disk + + + Mounted disk + Mounted disk diff -ruN e-smith-backup-2.4.0.p34/root/etc/e-smith/web/functions/backup e-smith-backup-2.4.0/root/etc/e-smith/web/functions/backup --- e-smith-backup-2.4.0.p34/root/etc/e-smith/web/functions/backup 2014-04-20 15:59:00.000000000 -0700 +++ e-smith-backup-2.4.0/root/etc/e-smith/web/functions/backup 2014-04-20 22:09:47.000000000 -0700 @@ -1032,6 +1032,7 @@ my $backupwkPassword = 'backup'; my $backupwkStation = 'host'; my $backupwkFolder = 'share'; + my $backupwkMount = '/mnt/smb'; my $setsNumber; my $filesinset; my $backupwkTime; @@ -1041,8 +1042,8 @@ my $VFSType; my $dof; my @dlabels = split(' ', $fm->localise('DOW')); - my @VFST = ('cifs', 'nfs', 'usb'); - my %VFST = ('cifs', $fm->localise('cifs'), 'nfs', $fm->localise('nfs'), 'usb', $fm->localise('local removable disk')); + my @VFST = ('cifs', 'nfs', 'usb','mnt'); + my %VFST = ('cifs', $fm->localise('cifs'), 'nfs', $fm->localise('nfs'), 'usb', $fm->localise('local removable disk'), 'mnt', $fm->localise('Mounted disk')); # Obtain backup informations from configuration my $rec = $conf->get('backupwk'); @@ -1053,6 +1054,7 @@ $backupwkPassword = $rec->prop('Password') || 'backup'; $backupwkStation = $rec->prop('SmbHost') || 'host'; $backupwkFolder = $rec->prop('SmbShare') || 'share'; + $backupwkMount = $rec->prop('Mount') || '/mnt/smb'; $setsNumber = $rec->prop('SetsMax') || '1'; $filesinset = $rec->prop('DaysInSet') || '1'; $backupwkTimeout = $rec->prop('Timeout') || '12'; @@ -1063,39 +1065,50 @@ $backupwk_status = $rec->prop('status'); } - esmith::cgi::genHeaderNonCacheable( - $q, undef, $fm->localise('CONFIGURE_WORKSTN_BACKUP')); + esmith::cgi::genHeaderNonCacheable($q, undef, $fm->localise('CONFIGURE_WORKSTN_BACKUP')); - if ($rec) { - print $fm->localise('WORKSTN_BACKUP_DESC'); - print $fm->localise('WORKSTN_BACKUP_ENABLED'), - $q->b(' '.$fm->localise(uc($backupwk_status))), '.
'; - if ($VFSType eq 'usb') { - print $fm->localise('WORKSTN_BACKUP_USB'), '
'; - } - else { - print $fm->localise('WORKSTN_BACKUP_HOST'), ' ', $backupwkStation; - print ' ', $fm->localise('WORKSTN_BACKUP_VFSTYPE'), ' ', $VFSType, '
'; - } - print $fm->localise('WORKSTN_BACKUP_SHARE'), ' ', $backupwkFolder, '
'; - if ($VFSType eq 'cifs') { - print $fm->localise('LOGIN'), ' ', $backupwkLogin, '
'; - print $fm->localise('PASSWORD'), ' ********
'; - } - print $fm->localise('WORKSTN_BACKUP_SETSNUM'), ' ', $setsNumber, '
'; - print $fm->localise('WORKSTN_BACKUP_DAYSINSET'), ' ', $filesinset, '
'; - print $fm->localise('WORKSTN_BACKUP_COMPRESSION'), ' ', $compression, '
'; - print $fm->localise('WORKSTN_BACKUP_TOD'), ' ', $backupwkTime, '
'; + if ($rec) + { + print $fm->localise('WORKSTN_BACKUP_DESC'); + print $fm->localise('WORKSTN_BACKUP_ENABLED'), $q->b(' '.$fm->localise(uc($backupwk_status))), '.
'; + if ($VFSType eq 'usb') + { + print $fm->localise('WORKSTN_BACKUP_USB'), ' ', $backupwkFolder, '
'; + } + elsif ($VFSType eq 'mnt') + { + print $fm->localise('WORKSTN_BACKUP_MNT'), ' ', $backupwkMount, '
'; + } + else + { + print $fm->localise('WORKSTN_BACKUP_HOST'), ' ', $backupwkStation; + print ' ', $fm->localise('WORKSTN_BACKUP_VFSTYPE'), ' ', $VFSType, '
'; + print $fm->localise('WORKSTN_BACKUP_SHARE'), ' ', $backupwkFolder, '
'; + } + if ($VFSType eq 'cifs') + { + print $fm->localise('LOGIN'), ' ', $backupwkLogin, '
'; + print $fm->localise('PASSWORD'), ' ********
'; + } + print $fm->localise('WORKSTN_BACKUP_SETSNUM'), ' ', $setsNumber, '
'; + print $fm->localise('WORKSTN_BACKUP_DAYSINSET'), ' ', $filesinset, '
'; + print $fm->localise('WORKSTN_BACKUP_COMPRESSION'), ' ', $compression, '
'; + print $fm->localise('WORKSTN_BACKUP_TOD'), ' ', $backupwkTime, '
'; print $fm->localise('WORKSTN_BACKUP_TIMEOUT'), ' ', $backupwkTimeout, ' ', $fm->localise('HOURS'); - if ( $backupwkIncOnlyTimeout eq 'yes' ) {print $fm->localise('WORKSTN_BACKUP_INCONLY_TIMEOUT')} - print '
'; - if ( $dof eq '7' ) { - print $fm->localise('WORKSTN_FULL_BACKUP_EVERYDAY', '
'); - } - else { - print $fm->localise('WORKSTN_FULL_BACKUP_DAY'), ' ', $dlabels[$dof], '
'; - } - } + if ( $backupwkIncOnlyTimeout eq 'yes' ) + { + print $fm->localise('WORKSTN_BACKUP_INCONLY_TIMEOUT') + } + print '
'; + if ( $dof eq '7' ) + { + print $fm->localise('WORKSTN_FULL_BACKUP_EVERYDAY', '
'); + } + else + { + print $fm->localise('WORKSTN_FULL_BACKUP_DAY'), ' ', $dlabels[$dof], '
'; + } + } else { print $fm->localise('WORKSTN_BACKUP_NOT_CONFIGURED'), '
' } print $q->startform( @@ -1155,6 +1168,7 @@ my $backupwkPassword = 'backup'; my $backupwkStation = 'host'; my $backupwkFolder = 'share'; + my $backupwkMount = ''; my $setsNumber; my $filesinset; my $backupwkTimeout; @@ -1182,6 +1196,7 @@ $backupwkPassword = $rec->prop('Password') || 'backup'; $backupwkStation = $rec->prop('SmbHost') || 'host'; $backupwkFolder = $rec->prop('SmbShare') || 'share'; + $backupwkMount = $rec->prop('Mount') || ''; $setsNumber = $rec->prop('SetsMax') || '1'; $filesinset = $rec->prop('DaysInSet') || '1'; $backupwkTimeout = $rec->prop('Timeout') || '12'; @@ -1236,6 +1251,15 @@ $error='nousb'; } } + if ( $VFSType eq 'mnt' ) + { + @usbdisks = findmnt (); + unless ($usbdisks[0]){ + push @usbdisks, $fm->localise('ERR_NO_MOUNTED_DISK'); + $error='nomnt'; + } + } + print $q->startform( -method => 'POST', @@ -1258,55 +1282,41 @@ print $q->Tr($q->td($q->h3 ($fm->localise('WORKSTATION_BACKUP_DEST')))); - if ( $VFSType eq 'usb' ) { - print $q->Tr( - esmith::cgi::genCell( - $q, - $fm->localise('WORKSTN_NAME') - ), - - esmith::cgi::genCell ($q, 'localhost'), - ); - } - else { - print $q->Tr( - esmith::cgi::genCell( - $q, - $fm->localise('WORKSTN_NAME') - ), - - esmith::cgi::genCell ($q, $q->textfield (-name => 'backupwkStation', - -override => 1, - -default => $backupwkStation, - -size => 20)), - ); - } + if ( $VFSType =~ m/cifs|nfs/s ) + { + print $q->Tr(esmith::cgi::genCell($q,$fm->localise('WORKSTN_NAME')), + esmith::cgi::genCell ($q, $q->textfield (-name => 'backupwkStation', + -override => 1, + -default => $backupwkStation, + -size => 20)), + ); + } - if ( $VFSType eq 'usb' ) { - print $q->Tr( - esmith::cgi::genCell( - $q, - $fm->localise('SHARED_FOLDER_NAME') - ), - + if ( $VFSType eq 'usb' ) + { + print $q->Tr(esmith::cgi::genCell($q,$fm->localise('local removable disk')), esmith::cgi::genCell ($q, $q->popup_menu (-name => 'backupwkFolder', - -values => [ @usbdisks ], - -default => $backupwkFolder,)), - ); - } - else { - print $q->Tr( - esmith::cgi::genCell( - $q, - $fm->localise('SHARED_FOLDER_NAME') - ), - - esmith::cgi::genCell ($q, $q->textfield (-name => 'backupwkFolder', - -override => 1, - -default => $backupwkFolder, - -size => 20)), - ); - } + -values => [ @usbdisks ], + -default => $backupwkFolder,)), + ); + } + elsif ($VFSType eq 'mnt') + { + print $q->Tr(esmith::cgi::genCell($q,$fm->localise('Mounted disk')), + esmith::cgi::genCell ($q, $q->popup_menu (-name => 'backupwkFolder', + -values => [ @usbdisks ], + -default => $backupwkMount,)), + ); + } + else + { + print $q->Tr(esmith::cgi::genCell($q,$fm->localise('SHARED_FOLDER_NAME')), + esmith::cgi::genCell ($q, $q->textfield (-name => 'backupwkFolder', + -override => 1, + -default => $backupwkFolder, + -size => 20)), + ); + } if ( $VFSType eq 'cifs' ) { print $q->Tr( @@ -1430,7 +1440,7 @@ print "\n"; - if ($error eq 'nousb') {$VFSType = "nousb";} + if ($error =~ m/nousb|nomnt/s) {$VFSType = $error;} print $q->start_table ({width => "100%", -class => "sme-noborders"}); print $q->Tr($q->th({-class => "sme-layout"}, $q->submit( @@ -1478,7 +1488,8 @@ { $rec = $conf->new_record('backupwk', {type=>'service'}); } - + my $backupwkMount = $rec->prop('Mount') || '/mnt/smb'; + unless ( $status eq 'on') { # set service to disabled @@ -1504,9 +1515,14 @@ esmith::cgi::genResult($q, $fm->localise('ERR_NO_USB_DISK')); return; } + if ( $VFSType eq 'nomnt') + { + esmith::cgi::genResult($q, $fm->localise('ERR_NO_MOUNTED_DISK')); + return; + } my $backupwkStation = $q->param ('backupwkStation'); - if ( $VFSType eq 'usb') { $backupwkStation = 'localhost' } + if ( $VFSType =~ m/usb|mnt/s) { $backupwkStation = 'localhost' } if ($backupwkStation =~ /^\s*(\S+)\s*$/) { $backupwkStation = $1; } else { @@ -1521,21 +1537,31 @@ } my $backupwkFolder = $q->param ('backupwkFolder'); - if ( $VFSType eq 'usb' ) { - $backupwkFolder = 'media/' . $backupwkFolder; - } - if ($backupwkFolder =~ /^(.*)$/) { + if ($backupwkFolder =~ /^(.*)$/) + { $backupwkFolder = $1; - mkdir "/$backupwkFolder"; - $backupwkFolder =~ s/^\///; # remove leading / - } else { - $backupwkFolder = ""; } - if ( $backupwkFolder eq "" ) + else { - esmith::cgi::genResult( - $q, $fm->localise('ERR_INVALID_FOLDER') - ); + $backupwkFolder = ''; + } + if ( $VFSType eq 'usb' ) + { + $backupwkFolder = 'media/' . $backupwkFolder; + } + if ( $VFSType eq 'mnt' ) + { + $backupwkMount = $backupwkFolder; + if (checkMount ($backupwkMount)){$backupwkFolder = '';} + } + else + { + mkdir "/$backupwkFolder"; + $backupwkFolder =~ s/^\///; # remove leading / + } + if ( $backupwkFolder eq '') + { + esmith::cgi::genResult($q, $fm->localise('ERR_INVALID_FOLDER')); return; } @@ -1615,6 +1641,7 @@ $rec->set_prop('SmbHost', $backupwkStation); $rec->set_prop('SmbShare', $backupwkFolder); + $rec->set_prop('Mount', $backupwkMount); $rec->set_prop('Login', $backupwkLogin); $rec->set_prop('Password', $backupwkPassword); $rec->set_prop('SetsMax', $setsNumber); @@ -2088,9 +2115,8 @@ return; } - my $mntdir = $rec->prop('MountDir') || '/mnt/smb'; + my $mntdir = $rec->prop('Mount') || '/mnt/smb'; my $mntbkdir; - my $mounted; my %backupfiles = (); my $key; my $id = $rec->prop('Id') || @@ -2115,34 +2141,21 @@ }; # Mounting backup shared folder - unless (-d $mntdir) + my $error_message = bmount($mntdir,$smbhost,$smbshare,$VFSType); + if ($error_message) { - mkdir -p $mntdir; - } - - my $login = $rec->prop('Login') || 'backup'; - my $password = $rec->prop('Password') || 'backup'; - - if ($err = dmount($smbhost,$smbshare,$mntdir,$login,$password,$VFSType)) - { - esmith::cgi::genResult($q, - $fm->localise('ERR_MOUNTING_SMBSHARE') . "\n" . $err); - return; + esmith::cgi::genResult($q, $error_message, $id); + return; } - else {$mounted = 1} # Test if backup subdirectory for our server - $mntbkdir = $mntdir . "/$id"; - unless ( -d $mntbkdir) - { - if ($mounted) - { - system("/bin/umount", "$mntdir") == 0 - or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n"); - } - esmith::cgi::genResult($q, $fm->localise('ERR_NO_HOST_DIR'), $id); - return; + unless (-d $mntbkdir) + { + $error_message = $fm->localise('ERR_NO_HOST_DIR')."\n"; + $error_message .= bunmount($mntdir,$VFSType); + esmith::cgi::genResult($q, $error_message, $id); + return; } # Finding existing backups @@ -2160,11 +2173,8 @@ $backups = push @blabels, $labkey; } - if ($mounted) - { - system("/bin/umount", "$mntdir") == 0 - or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n"); - } + $error_message = bunmount($mntdir,$VFSType); + die($error_message) if $error_message; if ( $backups == 0 ) { @@ -2255,51 +2265,34 @@ return; } - # mounting backup shared folder - my $backupwkrec = $conf->get('backupwk'); - my $login = $backupwkrec->prop('Login'); - my $password = $backupwkrec->prop('Password'); my $id = $backupwkrec->prop('Id') || $conf->get('SystemName')->value . "." . $conf->get('DomainName')->value; - my $mntdir = $backupwkrec->prop('MountDir') || '/mnt/smb'; - my $mounted; + my $mntdir = $backupwkrec->prop('Mount') || '/mnt/smb'; my $VFSType = $backupwkrec->prop('VFSType') || 'cifs'; my $smbhost = $backupwkrec->prop('SmbHost'); my $smbshare = $backupwkrec->prop('SmbShare'); my $err; - - if ($err = dmount($smbhost,$smbshare,$mntdir,$login,$password,$VFSType)) - { - esmith::cgi::genHeaderNonCacheable( - $q, - undef, $fm->localise('RESTORE_CANNOT_PROCEED') - ); - esmith::cgi::genResult( - $q, $fm->localise('ERR_MOUNTING_SMBSHARE') . "\n" . $err - ); - return; + my $error_message; + + # Mounting backup shared folder + $error_message = bmount($mntdir,$smbhost,$smbshare,$VFSType); + if ($error_message) + { + esmith::cgi::genHeaderNonCacheable($q,undef, $fm->localise('RESTORE_CANNOT_PROCEED')); + esmith::cgi::genResult($q, $error_message, $id); + return; } - else {$mounted = 1} # Test if backup subdirectory for our server - my $mntbkdir = $mntdir . "/$id"; - unless ( -d $mntbkdir) - { - if ($mounted) - { - system("/bin/umount", "$mntdir") == 0 - or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n"); - } - esmith::cgi::genHeaderNonCacheable( - $q, - undef, $fm->localise('RESTORE_CANNOT_PROCEED') - ); - esmith::cgi::genResult( - $q, $fm->localise('ERR_NO_HOST_DIR') . $id - ); - return; + unless (-d $mntbkdir) + { + $error_message = $fm->localise('ERR_NO_HOST_DIR')."\n"; + $error_message .= bunmount($mntdir,$VFSType); + esmith::cgi::genHeaderNonCacheable($q,undef, $fm->localise('RESTORE_CANNOT_PROCEED')); + esmith::cgi::genResult($q, $error_message, $id); + return; } # finding list of available backups @@ -2466,21 +2459,15 @@ } else { - if ($mounted) - { - system("/bin/umount", "$mntdir") == 0 - or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n"); - } - die('Unsecure data : ' . $file); + $error_message = "Unsecure data : $file\n"; + $error_message .= bunmount($mntdir,$VFSType); + die ($error_message); } system ("/usr/bin/dar", "-Q", "-x", "$file", "-v", "-N", "-R", "/", "-wa"); } - if ($mounted) - { - system("/bin/umount", "$mntdir") == 0 - or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n"); - } + $error_message = bunmount($mntdir,$VFSType); + die($error_message) if $error_message; exit(0); } @@ -2502,9 +2489,8 @@ } my %backupfiles = (); - my $mntdir = $rec->prop('MountDir') || '/mnt/smb'; + my $mntdir = $rec->prop('Mount') || '/mnt/smb'; my $mntbkdir; - my $mounted; my $key; my $id = $rec->prop('Id') || $conf->get('SystemName')->value . '.' . $conf->get('DomainName')->value; @@ -2516,6 +2502,7 @@ my $smbhost = $rec->prop('SmbHost'); my $smbshare = $rec->prop('SmbShare'); my $err; + my $error_message; my $setbackuplist = sub { if ( $_ =~ /\.dar/ ) @@ -2530,40 +2517,23 @@ @{$backupfiles{$_}}[1] = $backupref; } }; - - # Mounting backups smb shared folder - - unless (-d $mntdir) - { - mkdir -p $mntdir; - } - - my $login = $rec->prop('Login') || 'backup'; - my $password = $rec->prop('Password') || 'backup'; - if ($err = dmount($smbhost,$smbshare,$mntdir,$login,$password,$VFSType)) - { - esmith::cgi::genResult( - $q, $fm->localise('ERR_MOUNTING_SMBSHARE') . "\n" . $err - ); - return; + # Mounting backup shared folder + $error_message = bmount($mntdir,$smbhost,$smbshare,$VFSType); + if ($error_message) + { + esmith::cgi::genResult($q, $error_message, $id); + return; } - else {$mounted = 1} # Test if backup subdirectory for our server - - $mntbkdir = $mntdir . '/' . $id; - unless ( -d $mntbkdir) - { - if ($mounted) - { - system("/bin/umount", "$mntdir") == 0 - or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n"); - } - esmith::cgi::genResult( - $q, $fm->localise('ERR_NO_HOST_DIR'), $id - ); - return; + $mntbkdir = $mntdir . "/$id"; + unless (-d $mntbkdir) + { + $error_message = $fm->localise('ERR_NO_HOST_DIR')."\n"; + $error_message .= bunmount($mntdir,$VFSType); + esmith::cgi::genResult($q, $error_message, $id); + return; } my $catalog = "$mntbkdir/dar-catalog"; @@ -2651,11 +2621,8 @@ esmith::cgi::genFooter ($q); - if ($mounted) - { - system("/bin/umount", "$mntdir") == 0 - or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n"); - } + $error_message = bunmount($mntdir,$VFSType); + die($error_message) if $error_message; } sub performWorkstnSelRestore @@ -2681,11 +2648,7 @@ my $backupwkrec = $conf->get('backupwk'); my $smbhost = $backupwkrec->prop('SmbHost'); my $smbshare = $backupwkrec->prop('SmbShare'); - my $login = $backupwkrec->prop('Login'); - my $password = $backupwkrec->prop('Password'); - my $mntdir = $backupwkrec->prop('MountDir') || '/mnt/smb'; - my $mntbkdir; - my $mounted; + my $mntdir = $backupwkrec->prop('Mount') || '/mnt/smb'; my $key; my $id = $backupwkrec->prop('Id') || $conf->get('SystemName')->value . "." . $conf->get('DomainName')->value; @@ -2693,6 +2656,7 @@ my %flabels = (); my $VFSType = $backupwkrec->prop('VFSType') || 'cifs'; my $err; + my $error_message; my $backupkey = $q->param ('backupset'); if ($backupkey =~ /^(.*)$/) @@ -2705,32 +2669,23 @@ } # Mounting backup shared folder - - if ($err = dmount($smbhost,$smbshare,$mntdir,$login,$password,$VFSType)) - { - esmith::cgi::genResult( - $q, $fm->localise('ERR_MOUNTING_SMBSHARE') . "\n" . $err - ); - return; + $error_message = bmount($mntdir,$smbhost,$smbshare,$VFSType); + if ($error_message) + { + esmith::cgi::genResult($q, $error_message, $id); + return; } - else {$mounted = 1} # Test if backup subdirectory for our server - - $mntbkdir = $mntdir . "/$id"; + my $mntbkdir = $mntdir . "/$id"; unless (-d $mntbkdir) - { - if ($mounted) - { - system("/bin/umount", "$mntdir") == 0 - or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n"); - } - esmith::cgi::genResult( - $q, $fm->localise('ERR_NO_HOST_DIR'), $id - ); - return; + { + $error_message = $fm->localise('ERR_NO_HOST_DIR')."\n"; + $error_message .= bunmount($mntdir,$VFSType); + esmith::cgi::genResult($q, $error_message, $id); + return; } - + # Read wanted file list from selected backup if (open(RD, "-|")) @@ -2752,18 +2707,15 @@ } else { - select(STDOUT); - $| = 1; + select(STDOUT); + $| = 1; system ("/usr/bin/dar_manager", "-B", "$mntbkdir/dar-catalog", "-u", "$backupkey") == 0 - or die ($fm->localise('ERR_EXTRACT')." : ".$!); + or die ($fm->localise('ERR_EXTRACT')." : ".$!); - if ($mounted) - { - system("/bin/umount", "$mntdir") == 0 - or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n"); - } - exit(0); + $error_message = bunmount($mntdir,$VFSType); + die($error_message) if $error_message; + exit(0); } print $q->start_multipart_form( @@ -2859,43 +2811,32 @@ } } - # mounting backup shared folder - my $backupwkrec = $conf->get('backupwk'); - my $login = $backupwkrec->prop('Login'); - my $password = $backupwkrec->prop('Password'); my $id = $backupwkrec->prop('Id') || $conf->get('SystemName')->value . "." . $conf->get('DomainName')->value; - my $mntdir = $backupwkrec->prop('MountDir') || '/mnt/smb'; - my $mounted; + my $mntdir = $backupwkrec->prop('Mount') || '/mnt/smb'; my $VFSType = $backupwkrec->prop('VFSType') || 'cifs'; my $smbhost = $backupwkrec->prop('SmbHost'); my $smbshare = $backupwkrec->prop('SmbShare'); my $err; - - if ($err = dmount($smbhost,$smbshare,$mntdir,$login,$password,$VFSType)) - { - esmith::cgi::genResult( - $q, $fm->localise('ERR_MOUNTING_SMBSHARE') . "\n" . $err - ); - return; + my $error_message; + + # Mounting backup shared folder + $error_message = bmount($mntdir,$smbhost,$smbshare,$VFSType); + if ($error_message) + { + esmith::cgi::genResult($q, $error_message, $id); + return; } - else {$mounted = 1} # Test if backup subdirectory for our server - my $mntbkdir = $mntdir . "/$id"; unless (-d $mntbkdir) - { - if ($mounted) - { - system("/bin/umount", "$mntdir") == 0 - or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n"); - } - esmith::cgi::genResult( - $q, $fm->localise('ERR_NO_HOST_DIR'), $id - ); - return; + { + $error_message = $fm->localise('ERR_NO_HOST_DIR')."\n"; + $error_message .= bunmount($mntdir,$VFSType); + esmith::cgi::genResult($q, $error_message, $id); + return; } # backup is online, restoring now @@ -2953,14 +2894,10 @@ { $restorerr = system ("/usr/bin/dar_manager -B \"$mntbkdir/dar-catalog\" -Q -k -e '-v -N -R / -w' -r @restorelist"); } - - if ($mounted) - { - system("/bin/umount", "$mntdir") == 0 - or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n"); - } - exit(0); + $error_message = bunmount($mntdir,$VFSType); + die($error_message) if $error_message; + exit(0); } return; } @@ -3235,6 +3172,21 @@ return; } +sub findmnt +{ + my @mntin = qx( findmnt -n -l -o TARGET ); + my @mntout; + + foreach my $mount (@mntin) + { + next if ($mount =~ m/^\/proc|^\/dev|^\/sys|^\/boot/s); + chomp $mount; + next if ($mount eq '/'); + push @mntout, $mount; + } + + return @mntout; +} __DATA__