1 |
bytegw |
1.1 |
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 |
2 |
|
|
--- e-smith-backup-1.15.0/root/etc/e-smith/events/actions/workstation-backup-dar 2007-11-08 23:17:03.000000000 +0100 |
3 |
|
|
+++ 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 |
4 |
|
|
@@ -1,7 +1,7 @@ |
5 |
|
|
#!/usr/bin/perl -w |
6 |
|
|
|
7 |
|
|
#---------------------------------------------------------------------- |
8 |
|
|
-# copyright (C) 2006 Jean-Paul Leclere <jean-paul@leclere.org> |
9 |
|
|
+# copyright (C) 2006-2007 Jean-Paul Leclere <jean-paul@leclere.org> |
10 |
|
|
# copyright (C) 2007 Charlie Brady <charlieb@e-smith.com> |
11 |
|
|
# |
12 |
|
|
# This program is free software; you can redistribute it and/or modify |
13 |
|
|
@@ -84,48 +84,78 @@ |
14 |
|
|
|
15 |
|
|
# verify backup directory not already mounted |
16 |
|
|
|
17 |
|
|
+open FD, '/proc/mounts'; |
18 |
|
|
if ( $VFSType eq 'usb' ) |
19 |
|
|
{ |
20 |
|
|
- $mntdir = "/$smbshare"; |
21 |
|
|
-} |
22 |
|
|
-else |
23 |
|
|
-{ |
24 |
|
|
- open FD, '/proc/mounts'; |
25 |
|
|
while (<FD>) |
26 |
|
|
{ |
27 |
|
|
- next unless /$smbhost(.*)\/$smbshare/; |
28 |
|
|
- next unless /$mntdir/; |
29 |
|
|
- $err++ |
30 |
|
|
- } |
31 |
|
|
- close FD; |
32 |
|
|
- if ($err) |
33 |
|
|
- { |
34 |
|
|
- ldie("Seems backup directory is already mounted. " . |
35 |
|
|
- "It should not happen and maybe there is a zombie process " . |
36 |
|
|
- "you must kill, or another backup in progress. \n"); |
37 |
|
|
- } |
38 |
|
|
- if ($VFSType eq 'cifs') |
39 |
|
|
- { |
40 |
|
|
- $err = qx(/bin/mount -t cifs $smbhost:$smbshare $mntdir -o user=$login,pass=$password 2>&1); |
41 |
|
|
- ldie("Error while mounting $smbhost:$smbshare : \n" . $err) if $err; |
42 |
|
|
- } |
43 |
|
|
- elsif ($VFSType eq 'smbfs') |
44 |
|
|
- { |
45 |
|
|
- $err = qx(/bin/mount -t smbfs //$smbhost/$smbshare $mntdir -o username=$login,password=$password,dmask=777,fmask=777,ip=$smbhost 2>&1); |
46 |
|
|
- ldie("Error while mounting //$smbhost/$smbshare : \n" . $err) if $err; |
47 |
|
|
+ next unless /\s\/$smbhost(.*)\/$smbshare\s/; |
48 |
|
|
+ next unless /\s\/$mntdir\s/; |
49 |
|
|
+ $err++ |
50 |
|
|
} |
51 |
|
|
- elsif ($VFSType eq 'nfs') |
52 |
|
|
- { |
53 |
|
|
- $err = qx(/bin/mount -t nfs -o nolock $smbhost:/$smbshare $mntdir 2>&1); |
54 |
|
|
- ldie("Error while mounting $smbhost:/$smbshare : \n" . $err) if $err; |
55 |
|
|
- } |
56 |
|
|
- else |
57 |
|
|
+} |
58 |
|
|
+else |
59 |
|
|
+{ |
60 |
|
|
+ while (<FD>) |
61 |
|
|
{ |
62 |
|
|
- ldie("Error while mounting $smbhost/$smbshare : $VFSType not supported.\n"); |
63 |
|
|
+ next unless /\s\/$smbshare\s/; |
64 |
|
|
+ $err++; |
65 |
|
|
} |
66 |
|
|
- $mntdone = 1; |
67 |
|
|
+} |
68 |
|
|
+close FD; |
69 |
|
|
+if ($err) |
70 |
|
|
+{ |
71 |
|
|
+ ldie("Seems backup directory is already mounted. " . |
72 |
|
|
+ "It should not happen and maybe there is a zombie process " . |
73 |
|
|
+ "you must kill, or another backup in progress. \n"); |
74 |
|
|
+} |
75 |
|
|
+ |
76 |
|
|
+# mount the backup dir |
77 |
|
|
+ |
78 |
|
|
+if ($VFSType eq 'cifs') |
79 |
|
|
+{ |
80 |
|
|
+ $err = qx(/bin/mount -t cifs $smbhost:$smbshare $mntdir -o user=$login,pass=$password 2>&1); |
81 |
|
|
+ ldie("Error while mounting $smbhost:$smbshare : \n" . $err) if $err; |
82 |
|
|
+} |
83 |
|
|
+elsif ($VFSType eq 'smbfs') |
84 |
|
|
+{ |
85 |
|
|
+ $err = qx(/bin/mount -t smbfs //$smbhost/$smbshare $mntdir -o username=$login,password=$password,dmask=777,fmask=777,ip=$smbhost 2>&1); |
86 |
|
|
+ ldie("Error while mounting //$smbhost/$smbshare : \n" . $err) if $err; |
87 |
|
|
+} |
88 |
|
|
+elsif ($VFSType eq 'nfs') |
89 |
|
|
+{ |
90 |
|
|
+ $err = qx(/bin/mount -t nfs -o nolock $smbhost:/$smbshare $mntdir 2>&1); |
91 |
|
|
+ ldie("Error while mounting $smbhost:/$smbshare : \n" . $err) if $err; |
92 |
|
|
+} |
93 |
|
|
+elsif ($VFSType eq 'usb') |
94 |
|
|
+{ |
95 |
|
|
+ $err = qx(/bin/mount /$smbshare 2>&1); |
96 |
|
|
+ if ($err) {ldie("Error while mounting /$smbshare : \n" . $err)}; |
97 |
|
|
+ $mntdir = "/$smbshare"; |
98 |
|
|
+} |
99 |
|
|
+else |
100 |
|
|
+{ |
101 |
|
|
+ ldie("Error while mounting $smbhost/$smbshare : $VFSType not supported.\n"); |
102 |
|
|
+} |
103 |
|
|
+$mntdone = 1; |
104 |
|
|
+ |
105 |
|
|
+# verify $mntdir has an entry in /proc/mounts |
106 |
|
|
+ |
107 |
|
|
+$err = 0; |
108 |
|
|
+open FD, '/proc/mounts'; |
109 |
|
|
+while (<FD>) |
110 |
|
|
+{ |
111 |
|
|
+ next unless /\s$mntdir\s/; |
112 |
|
|
+ $err++; |
113 |
|
|
+} |
114 |
|
|
+close FD; |
115 |
|
|
+if ($err == 0) |
116 |
|
|
+{ |
117 |
|
|
+ ldie("Seems backup directory is not really mounted. It should not happen. \ |
118 |
|
|
+ Verify availability of your backup volume. Stopping the backup now.\n") |
119 |
|
|
} |
120 |
|
|
|
121 |
|
|
+$tmpdir = $mntdir . '/tmp_dir'; |
122 |
|
|
if (-d "$tmpdir/$id") |
123 |
|
|
{ |
124 |
|
|
eval {rmtree("$tmpdir/$id")}; |
125 |
|
|
@@ -271,7 +301,7 @@ |
126 |
|
|
} |
127 |
|
|
|
128 |
|
|
# unmount shared folder |
129 |
|
|
-system("/bin/umount -f $mntdir") unless ($VFSType ne 'usb'); |
130 |
|
|
+system("/bin/umount -f $mntdir"); |
131 |
|
|
|
132 |
|
|
# time now to update backup configuration |
133 |
|
|
|