diff -Nur -x '*.orig' -x '*.rej' e-smith-backup-1.15.0/root/etc/e-smith/events/actions/workstation-backup-dar mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/events/actions/workstation-backup-dar --- e-smith-backup-1.15.0/root/etc/e-smith/events/actions/workstation-backup-dar 2007-11-08 23:17:03.000000000 +0100 +++ mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/events/actions/workstation-backup-dar 2007-11-08 22:15:00.000000000 +0100 @@ -1,7 +1,7 @@ #!/usr/bin/perl -w #---------------------------------------------------------------------- -# copyright (C) 2006 Jean-Paul Leclere +# copyright (C) 2006-2007 Jean-Paul Leclere # copyright (C) 2007 Charlie Brady # # This program is free software; you can redistribute it and/or modify @@ -84,48 +84,78 @@ # verify backup directory not already mounted +open FD, '/proc/mounts'; if ( $VFSType eq 'usb' ) { - $mntdir = "/$smbshare"; -} -else -{ - open FD, '/proc/mounts'; while () { - next unless /$smbhost(.*)\/$smbshare/; - next unless /$mntdir/; - $err++ - } - close FD; - if ($err) - { - ldie("Seems backup directory is already mounted. " . - "It should not happen and maybe there is a zombie process " . - "you must kill, or another backup in progress. \n"); - } - if ($VFSType eq 'cifs') - { - $err = qx(/bin/mount -t cifs $smbhost:$smbshare $mntdir -o user=$login,pass=$password 2>&1); - ldie("Error while mounting $smbhost:$smbshare : \n" . $err) if $err; - } - elsif ($VFSType eq 'smbfs') - { - $err = qx(/bin/mount -t smbfs //$smbhost/$smbshare $mntdir -o username=$login,password=$password,dmask=777,fmask=777,ip=$smbhost 2>&1); - ldie("Error while mounting //$smbhost/$smbshare : \n" . $err) if $err; + next unless /\s\/$smbhost(.*)\/$smbshare\s/; + next unless /\s\/$mntdir\s/; + $err++ } - elsif ($VFSType eq 'nfs') - { - $err = qx(/bin/mount -t nfs -o nolock $smbhost:/$smbshare $mntdir 2>&1); - ldie("Error while mounting $smbhost:/$smbshare : \n" . $err) if $err; - } - else +} +else +{ + while () { - ldie("Error while mounting $smbhost/$smbshare : $VFSType not supported.\n"); + next unless /\s\/$smbshare\s/; + $err++; } - $mntdone = 1; +} +close FD; +if ($err) +{ + ldie("Seems backup directory is already mounted. " . + "It should not happen and maybe there is a zombie process " . + "you must kill, or another backup in progress. \n"); +} + +# mount the backup dir + +if ($VFSType eq 'cifs') +{ + $err = qx(/bin/mount -t cifs $smbhost:$smbshare $mntdir -o user=$login,pass=$password 2>&1); + ldie("Error while mounting $smbhost:$smbshare : \n" . $err) if $err; +} +elsif ($VFSType eq 'smbfs') +{ + $err = qx(/bin/mount -t smbfs //$smbhost/$smbshare $mntdir -o username=$login,password=$password,dmask=777,fmask=777,ip=$smbhost 2>&1); + ldie("Error while mounting //$smbhost/$smbshare : \n" . $err) if $err; +} +elsif ($VFSType eq 'nfs') +{ + $err = qx(/bin/mount -t nfs -o nolock $smbhost:/$smbshare $mntdir 2>&1); + ldie("Error while mounting $smbhost:/$smbshare : \n" . $err) if $err; +} +elsif ($VFSType eq 'usb') +{ + $err = qx(/bin/mount /$smbshare 2>&1); + if ($err) {ldie("Error while mounting /$smbshare : \n" . $err)}; + $mntdir = "/$smbshare"; +} +else +{ + ldie("Error while mounting $smbhost/$smbshare : $VFSType not supported.\n"); +} +$mntdone = 1; + +# verify $mntdir has an entry in /proc/mounts + +$err = 0; +open FD, '/proc/mounts'; +while () +{ + next unless /\s$mntdir\s/; + $err++; +} +close FD; +if ($err == 0) +{ + ldie("Seems backup directory is not really mounted. It should not happen. \ + Verify availability of your backup volume. Stopping the backup now.\n") } +$tmpdir = $mntdir . '/tmp_dir'; if (-d "$tmpdir/$id") { eval {rmtree("$tmpdir/$id")}; @@ -271,7 +301,7 @@ } # unmount shared folder -system("/bin/umount -f $mntdir") unless ($VFSType ne 'usb'); +system("/bin/umount -f $mntdir"); # time now to update backup configuration