/[smeserver]/rpms/e-smith-backup/sme9/e-smith-backup-2.4.0-workstation-allowMounted3.patch
ViewVC logotype

Annotation of /rpms/e-smith-backup/sme9/e-smith-backup-2.4.0-workstation-allowMounted3.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (hide annotations) (download)
Mon Apr 21 05:25:48 2014 UTC (10 years, 1 month ago) by wellsi
Branch: MAIN
CVS Tags: e-smith-backup-2_4_0-42_el6_sme, e-smith-backup-2_4_0-38_el6_sme, e-smith-backup-2_4_0-46_el6_sme, e-smith-backup-2_4_0-34_el6_sme, e-smith-backup-2_4_0-35_el6_sme, e-smith-backup-2_4_0-36_el6_sme, e-smith-backup-2_4_0-44_el6_sme, e-smith-backup-2_4_0-37_el6_sme, e-smith-backup-2_4_0-41_el6_sme, e-smith-backup-2_4_0-39_el6_sme, e-smith-backup-2_4_0-45_el6_sme, e-smith-backup-2_4_0-40_el6_sme, e-smith-backup-2_4_0-43_el6_sme, HEAD
* Sun Apr 20 2014 Ian Wells <esmith@wellsi.com> 2.4.0-34.sme
- Implement panel and restore for backup to mounted drive [SME: 8144]

1 wellsi 1.1 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
2     --- 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
3     +++ 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
4     @@ -809,6 +809,10 @@
5     <trans>Backup is made on local removable disk</trans>
6     </entry>
7     <entry>
8     + <base>WORKSTN_BACKUP_MNT</base>
9     + <trans>Backup is made on mounted disk</trans>
10     + </entry>
11     + <entry>
12     <base>WORKSTN_BACKUP_HOST</base>
13     <trans>Backup is made on LAN workstation </trans>
14     </entry>
15     @@ -870,7 +874,11 @@
16     </entry>
17     <entry>
18     <base>ERR_NO_USB_DISK</base>
19     - <trans>Error : No removable disk available. Please connect an removable disk or select another type of backup share.</trans>
20     + <trans>Error : No removable disk available. Please connect a removable disk or select another type of workstation backup.</trans>
21     + </entry>
22     + <entry>
23     + <base>ERR_NO_MOUNTED_DISK</base>
24     + <trans>Error : No mounted disk available. Please mount a disk or select another type of workstation backup.</trans>
25     </entry>
26     <entry>
27     <base>HOURS</base>
28     @@ -914,7 +922,11 @@
29     </entry>
30     <entry>
31     <base>local removable disk</base>
32     - <trans>local removable disk</trans>
33     + <trans>Local removable disk</trans>
34     + </entry>
35     + <entry>
36     + <base>Mounted disk</base>
37     + <trans>Mounted disk</trans>
38     </entry>
39     </lexicon>
40    
41     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
42     --- e-smith-backup-2.4.0.p34/root/etc/e-smith/web/functions/backup 2014-04-20 15:59:00.000000000 -0700
43     +++ e-smith-backup-2.4.0/root/etc/e-smith/web/functions/backup 2014-04-20 22:09:47.000000000 -0700
44     @@ -1032,6 +1032,7 @@
45     my $backupwkPassword = 'backup';
46     my $backupwkStation = 'host';
47     my $backupwkFolder = 'share';
48     + my $backupwkMount = '/mnt/smb';
49     my $setsNumber;
50     my $filesinset;
51     my $backupwkTime;
52     @@ -1041,8 +1042,8 @@
53     my $VFSType;
54     my $dof;
55     my @dlabels = split(' ', $fm->localise('DOW'));
56     - my @VFST = ('cifs', 'nfs', 'usb');
57     - my %VFST = ('cifs', $fm->localise('cifs'), 'nfs', $fm->localise('nfs'), 'usb', $fm->localise('local removable disk'));
58     + my @VFST = ('cifs', 'nfs', 'usb','mnt');
59     + my %VFST = ('cifs', $fm->localise('cifs'), 'nfs', $fm->localise('nfs'), 'usb', $fm->localise('local removable disk'), 'mnt', $fm->localise('Mounted disk'));
60    
61     # Obtain backup informations from configuration
62     my $rec = $conf->get('backupwk');
63     @@ -1053,6 +1054,7 @@
64     $backupwkPassword = $rec->prop('Password') || 'backup';
65     $backupwkStation = $rec->prop('SmbHost') || 'host';
66     $backupwkFolder = $rec->prop('SmbShare') || 'share';
67     + $backupwkMount = $rec->prop('Mount') || '/mnt/smb';
68     $setsNumber = $rec->prop('SetsMax') || '1';
69     $filesinset = $rec->prop('DaysInSet') || '1';
70     $backupwkTimeout = $rec->prop('Timeout') || '12';
71     @@ -1063,39 +1065,50 @@
72     $backupwk_status = $rec->prop('status');
73     }
74    
75     - esmith::cgi::genHeaderNonCacheable(
76     - $q, undef, $fm->localise('CONFIGURE_WORKSTN_BACKUP'));
77     + esmith::cgi::genHeaderNonCacheable($q, undef, $fm->localise('CONFIGURE_WORKSTN_BACKUP'));
78    
79     - if ($rec) {
80     - print $fm->localise('WORKSTN_BACKUP_DESC');
81     - print $fm->localise('WORKSTN_BACKUP_ENABLED'),
82     - $q->b(' '.$fm->localise(uc($backupwk_status))), '.<br/>';
83     - if ($VFSType eq 'usb') {
84     - print $fm->localise('WORKSTN_BACKUP_USB'), '<br/>';
85     - }
86     - else {
87     - print $fm->localise('WORKSTN_BACKUP_HOST'), ' ', $backupwkStation;
88     - print ' ', $fm->localise('WORKSTN_BACKUP_VFSTYPE'), ' ', $VFSType, '<br/>';
89     - }
90     - print $fm->localise('WORKSTN_BACKUP_SHARE'), ' ', $backupwkFolder, '<br/>';
91     - if ($VFSType eq 'cifs') {
92     - print $fm->localise('LOGIN'), ' ', $backupwkLogin, '<br/>';
93     - print $fm->localise('PASSWORD'), ' ********<br/>';
94     - }
95     - print $fm->localise('WORKSTN_BACKUP_SETSNUM'), ' ', $setsNumber, '<br/>';
96     - print $fm->localise('WORKSTN_BACKUP_DAYSINSET'), ' ', $filesinset, '<br/>';
97     - print $fm->localise('WORKSTN_BACKUP_COMPRESSION'), ' ', $compression, '<br/>';
98     - print $fm->localise('WORKSTN_BACKUP_TOD'), ' ', $backupwkTime, '<br/>';
99     + if ($rec)
100     + {
101     + print $fm->localise('WORKSTN_BACKUP_DESC');
102     + print $fm->localise('WORKSTN_BACKUP_ENABLED'), $q->b(' '.$fm->localise(uc($backupwk_status))), '.<br/>';
103     + if ($VFSType eq 'usb')
104     + {
105     + print $fm->localise('WORKSTN_BACKUP_USB'), ' ', $backupwkFolder, '<br/>';
106     + }
107     + elsif ($VFSType eq 'mnt')
108     + {
109     + print $fm->localise('WORKSTN_BACKUP_MNT'), ' ', $backupwkMount, '<br/>';
110     + }
111     + else
112     + {
113     + print $fm->localise('WORKSTN_BACKUP_HOST'), ' ', $backupwkStation;
114     + print ' ', $fm->localise('WORKSTN_BACKUP_VFSTYPE'), ' ', $VFSType, '<br/>';
115     + print $fm->localise('WORKSTN_BACKUP_SHARE'), ' ', $backupwkFolder, '<br/>';
116     + }
117     + if ($VFSType eq 'cifs')
118     + {
119     + print $fm->localise('LOGIN'), ' ', $backupwkLogin, '<br/>';
120     + print $fm->localise('PASSWORD'), ' ********<br/>';
121     + }
122     + print $fm->localise('WORKSTN_BACKUP_SETSNUM'), ' ', $setsNumber, '<br/>';
123     + print $fm->localise('WORKSTN_BACKUP_DAYSINSET'), ' ', $filesinset, '<br/>';
124     + print $fm->localise('WORKSTN_BACKUP_COMPRESSION'), ' ', $compression, '<br/>';
125     + print $fm->localise('WORKSTN_BACKUP_TOD'), ' ', $backupwkTime, '<br/>';
126     print $fm->localise('WORKSTN_BACKUP_TIMEOUT'), ' ', $backupwkTimeout, ' ', $fm->localise('HOURS');
127     - if ( $backupwkIncOnlyTimeout eq 'yes' ) {print $fm->localise('WORKSTN_BACKUP_INCONLY_TIMEOUT')}
128     - print '<br/>';
129     - if ( $dof eq '7' ) {
130     - print $fm->localise('WORKSTN_FULL_BACKUP_EVERYDAY', '<br/>');
131     - }
132     - else {
133     - print $fm->localise('WORKSTN_FULL_BACKUP_DAY'), ' ', $dlabels[$dof], '<br/>';
134     - }
135     - }
136     + if ( $backupwkIncOnlyTimeout eq 'yes' )
137     + {
138     + print $fm->localise('WORKSTN_BACKUP_INCONLY_TIMEOUT')
139     + }
140     + print '<br/>';
141     + if ( $dof eq '7' )
142     + {
143     + print $fm->localise('WORKSTN_FULL_BACKUP_EVERYDAY', '<br/>');
144     + }
145     + else
146     + {
147     + print $fm->localise('WORKSTN_FULL_BACKUP_DAY'), ' ', $dlabels[$dof], '<br/>';
148     + }
149     + }
150     else { print $fm->localise('WORKSTN_BACKUP_NOT_CONFIGURED'), '<br/>' }
151    
152     print $q->startform(
153     @@ -1155,6 +1168,7 @@
154     my $backupwkPassword = 'backup';
155     my $backupwkStation = 'host';
156     my $backupwkFolder = 'share';
157     + my $backupwkMount = '';
158     my $setsNumber;
159     my $filesinset;
160     my $backupwkTimeout;
161     @@ -1182,6 +1196,7 @@
162     $backupwkPassword = $rec->prop('Password') || 'backup';
163     $backupwkStation = $rec->prop('SmbHost') || 'host';
164     $backupwkFolder = $rec->prop('SmbShare') || 'share';
165     + $backupwkMount = $rec->prop('Mount') || '';
166     $setsNumber = $rec->prop('SetsMax') || '1';
167     $filesinset = $rec->prop('DaysInSet') || '1';
168     $backupwkTimeout = $rec->prop('Timeout') || '12';
169     @@ -1236,6 +1251,15 @@
170     $error='nousb';
171     }
172     }
173     + if ( $VFSType eq 'mnt' )
174     + {
175     + @usbdisks = findmnt ();
176     + unless ($usbdisks[0]){
177     + push @usbdisks, $fm->localise('ERR_NO_MOUNTED_DISK');
178     + $error='nomnt';
179     + }
180     + }
181     +
182    
183     print $q->startform(
184     -method => 'POST',
185     @@ -1258,55 +1282,41 @@
186    
187     print $q->Tr($q->td($q->h3 ($fm->localise('WORKSTATION_BACKUP_DEST'))));
188    
189     - if ( $VFSType eq 'usb' ) {
190     - print $q->Tr(
191     - esmith::cgi::genCell(
192     - $q,
193     - $fm->localise('WORKSTN_NAME')
194     - ),
195     -
196     - esmith::cgi::genCell ($q, 'localhost'),
197     - );
198     - }
199     - else {
200     - print $q->Tr(
201     - esmith::cgi::genCell(
202     - $q,
203     - $fm->localise('WORKSTN_NAME')
204     - ),
205     -
206     - esmith::cgi::genCell ($q, $q->textfield (-name => 'backupwkStation',
207     - -override => 1,
208     - -default => $backupwkStation,
209     - -size => 20)),
210     - );
211     - }
212     + if ( $VFSType =~ m/cifs|nfs/s )
213     + {
214     + print $q->Tr(esmith::cgi::genCell($q,$fm->localise('WORKSTN_NAME')),
215     + esmith::cgi::genCell ($q, $q->textfield (-name => 'backupwkStation',
216     + -override => 1,
217     + -default => $backupwkStation,
218     + -size => 20)),
219     + );
220     + }
221    
222     - if ( $VFSType eq 'usb' ) {
223     - print $q->Tr(
224     - esmith::cgi::genCell(
225     - $q,
226     - $fm->localise('SHARED_FOLDER_NAME')
227     - ),
228     -
229     + if ( $VFSType eq 'usb' )
230     + {
231     + print $q->Tr(esmith::cgi::genCell($q,$fm->localise('local removable disk')),
232     esmith::cgi::genCell ($q, $q->popup_menu (-name => 'backupwkFolder',
233     - -values => [ @usbdisks ],
234     - -default => $backupwkFolder,)),
235     - );
236     - }
237     - else {
238     - print $q->Tr(
239     - esmith::cgi::genCell(
240     - $q,
241     - $fm->localise('SHARED_FOLDER_NAME')
242     - ),
243     -
244     - esmith::cgi::genCell ($q, $q->textfield (-name => 'backupwkFolder',
245     - -override => 1,
246     - -default => $backupwkFolder,
247     - -size => 20)),
248     - );
249     - }
250     + -values => [ @usbdisks ],
251     + -default => $backupwkFolder,)),
252     + );
253     + }
254     + elsif ($VFSType eq 'mnt')
255     + {
256     + print $q->Tr(esmith::cgi::genCell($q,$fm->localise('Mounted disk')),
257     + esmith::cgi::genCell ($q, $q->popup_menu (-name => 'backupwkFolder',
258     + -values => [ @usbdisks ],
259     + -default => $backupwkMount,)),
260     + );
261     + }
262     + else
263     + {
264     + print $q->Tr(esmith::cgi::genCell($q,$fm->localise('SHARED_FOLDER_NAME')),
265     + esmith::cgi::genCell ($q, $q->textfield (-name => 'backupwkFolder',
266     + -override => 1,
267     + -default => $backupwkFolder,
268     + -size => 20)),
269     + );
270     + }
271    
272     if ( $VFSType eq 'cifs' ) {
273     print $q->Tr(
274     @@ -1430,7 +1440,7 @@
275    
276     print "</table>\n";
277    
278     - if ($error eq 'nousb') {$VFSType = "nousb";}
279     + if ($error =~ m/nousb|nomnt/s) {$VFSType = $error;}
280     print $q->start_table ({width => "100%", -class => "sme-noborders"});
281     print $q->Tr($q->th({-class => "sme-layout"},
282     $q->submit(
283     @@ -1478,7 +1488,8 @@
284     {
285     $rec = $conf->new_record('backupwk', {type=>'service'});
286     }
287     -
288     + my $backupwkMount = $rec->prop('Mount') || '/mnt/smb';
289     +
290     unless ( $status eq 'on')
291     {
292     # set service to disabled
293     @@ -1504,9 +1515,14 @@
294     esmith::cgi::genResult($q, $fm->localise('ERR_NO_USB_DISK'));
295     return;
296     }
297     + if ( $VFSType eq 'nomnt')
298     + {
299     + esmith::cgi::genResult($q, $fm->localise('ERR_NO_MOUNTED_DISK'));
300     + return;
301     + }
302    
303     my $backupwkStation = $q->param ('backupwkStation');
304     - if ( $VFSType eq 'usb') { $backupwkStation = 'localhost' }
305     + if ( $VFSType =~ m/usb|mnt/s) { $backupwkStation = 'localhost' }
306     if ($backupwkStation =~ /^\s*(\S+)\s*$/) {
307     $backupwkStation = $1;
308     } else {
309     @@ -1521,21 +1537,31 @@
310     }
311    
312     my $backupwkFolder = $q->param ('backupwkFolder');
313     - if ( $VFSType eq 'usb' ) {
314     - $backupwkFolder = 'media/' . $backupwkFolder;
315     - }
316     - if ($backupwkFolder =~ /^(.*)$/) {
317     + if ($backupwkFolder =~ /^(.*)$/)
318     + {
319     $backupwkFolder = $1;
320     - mkdir "/$backupwkFolder";
321     - $backupwkFolder =~ s/^\///; # remove leading /
322     - } else {
323     - $backupwkFolder = "";
324     }
325     - if ( $backupwkFolder eq "" )
326     + else
327     {
328     - esmith::cgi::genResult(
329     - $q, $fm->localise('ERR_INVALID_FOLDER')
330     - );
331     + $backupwkFolder = '';
332     + }
333     + if ( $VFSType eq 'usb' )
334     + {
335     + $backupwkFolder = 'media/' . $backupwkFolder;
336     + }
337     + if ( $VFSType eq 'mnt' )
338     + {
339     + $backupwkMount = $backupwkFolder;
340     + if (checkMount ($backupwkMount)){$backupwkFolder = '';}
341     + }
342     + else
343     + {
344     + mkdir "/$backupwkFolder";
345     + $backupwkFolder =~ s/^\///; # remove leading /
346     + }
347     + if ( $backupwkFolder eq '')
348     + {
349     + esmith::cgi::genResult($q, $fm->localise('ERR_INVALID_FOLDER'));
350     return;
351     }
352    
353     @@ -1615,6 +1641,7 @@
354    
355     $rec->set_prop('SmbHost', $backupwkStation);
356     $rec->set_prop('SmbShare', $backupwkFolder);
357     + $rec->set_prop('Mount', $backupwkMount);
358     $rec->set_prop('Login', $backupwkLogin);
359     $rec->set_prop('Password', $backupwkPassword);
360     $rec->set_prop('SetsMax', $setsNumber);
361     @@ -2088,9 +2115,8 @@
362     return;
363     }
364    
365     - my $mntdir = $rec->prop('MountDir') || '/mnt/smb';
366     + my $mntdir = $rec->prop('Mount') || '/mnt/smb';
367     my $mntbkdir;
368     - my $mounted;
369     my %backupfiles = ();
370     my $key;
371     my $id = $rec->prop('Id') ||
372     @@ -2115,34 +2141,21 @@
373     };
374    
375     # Mounting backup shared folder
376     - unless (-d $mntdir)
377     + my $error_message = bmount($mntdir,$smbhost,$smbshare,$VFSType);
378     + if ($error_message)
379     {
380     - mkdir -p $mntdir;
381     - }
382     -
383     - my $login = $rec->prop('Login') || 'backup';
384     - my $password = $rec->prop('Password') || 'backup';
385     -
386     - if ($err = dmount($smbhost,$smbshare,$mntdir,$login,$password,$VFSType))
387     - {
388     - esmith::cgi::genResult($q,
389     - $fm->localise('ERR_MOUNTING_SMBSHARE') . "\n" . $err);
390     - return;
391     + esmith::cgi::genResult($q, $error_message, $id);
392     + return;
393     }
394     - else {$mounted = 1}
395    
396     # Test if backup subdirectory for our server
397     -
398     $mntbkdir = $mntdir . "/$id";
399     - unless ( -d $mntbkdir)
400     - {
401     - if ($mounted)
402     - {
403     - system("/bin/umount", "$mntdir") == 0
404     - or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n");
405     - }
406     - esmith::cgi::genResult($q, $fm->localise('ERR_NO_HOST_DIR'), $id);
407     - return;
408     + unless (-d $mntbkdir)
409     + {
410     + $error_message = $fm->localise('ERR_NO_HOST_DIR')."\n";
411     + $error_message .= bunmount($mntdir,$VFSType);
412     + esmith::cgi::genResult($q, $error_message, $id);
413     + return;
414     }
415    
416     # Finding existing backups
417     @@ -2160,11 +2173,8 @@
418     $backups = push @blabels, $labkey;
419     }
420    
421     - if ($mounted)
422     - {
423     - system("/bin/umount", "$mntdir") == 0
424     - or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n");
425     - }
426     + $error_message = bunmount($mntdir,$VFSType);
427     + die($error_message) if $error_message;
428    
429     if ( $backups == 0 )
430     {
431     @@ -2255,51 +2265,34 @@
432     return;
433     }
434    
435     - # mounting backup shared folder
436     -
437     my $backupwkrec = $conf->get('backupwk');
438     - my $login = $backupwkrec->prop('Login');
439     - my $password = $backupwkrec->prop('Password');
440     my $id = $backupwkrec->prop('Id')
441     || $conf->get('SystemName')->value . "." . $conf->get('DomainName')->value;
442     - my $mntdir = $backupwkrec->prop('MountDir') || '/mnt/smb';
443     - my $mounted;
444     + my $mntdir = $backupwkrec->prop('Mount') || '/mnt/smb';
445     my $VFSType = $backupwkrec->prop('VFSType') || 'cifs';
446     my $smbhost = $backupwkrec->prop('SmbHost');
447     my $smbshare = $backupwkrec->prop('SmbShare');
448     my $err;
449     -
450     - if ($err = dmount($smbhost,$smbshare,$mntdir,$login,$password,$VFSType))
451     - {
452     - esmith::cgi::genHeaderNonCacheable(
453     - $q,
454     - undef, $fm->localise('RESTORE_CANNOT_PROCEED')
455     - );
456     - esmith::cgi::genResult(
457     - $q, $fm->localise('ERR_MOUNTING_SMBSHARE') . "\n" . $err
458     - );
459     - return;
460     + my $error_message;
461     +
462     + # Mounting backup shared folder
463     + $error_message = bmount($mntdir,$smbhost,$smbshare,$VFSType);
464     + if ($error_message)
465     + {
466     + esmith::cgi::genHeaderNonCacheable($q,undef, $fm->localise('RESTORE_CANNOT_PROCEED'));
467     + esmith::cgi::genResult($q, $error_message, $id);
468     + return;
469     }
470     - else {$mounted = 1}
471    
472     # Test if backup subdirectory for our server
473     -
474     my $mntbkdir = $mntdir . "/$id";
475     - unless ( -d $mntbkdir)
476     - {
477     - if ($mounted)
478     - {
479     - system("/bin/umount", "$mntdir") == 0
480     - or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n");
481     - }
482     - esmith::cgi::genHeaderNonCacheable(
483     - $q,
484     - undef, $fm->localise('RESTORE_CANNOT_PROCEED')
485     - );
486     - esmith::cgi::genResult(
487     - $q, $fm->localise('ERR_NO_HOST_DIR') . $id
488     - );
489     - return;
490     + unless (-d $mntbkdir)
491     + {
492     + $error_message = $fm->localise('ERR_NO_HOST_DIR')."\n";
493     + $error_message .= bunmount($mntdir,$VFSType);
494     + esmith::cgi::genHeaderNonCacheable($q,undef, $fm->localise('RESTORE_CANNOT_PROCEED'));
495     + esmith::cgi::genResult($q, $error_message, $id);
496     + return;
497     }
498    
499     # finding list of available backups
500     @@ -2466,21 +2459,15 @@
501     }
502     else
503     {
504     - if ($mounted)
505     - {
506     - system("/bin/umount", "$mntdir") == 0
507     - or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n");
508     - }
509     - die('Unsecure data : ' . $file);
510     + $error_message = "Unsecure data : $file\n";
511     + $error_message .= bunmount($mntdir,$VFSType);
512     + die ($error_message);
513     }
514     system ("/usr/bin/dar", "-Q", "-x", "$file", "-v", "-N", "-R", "/", "-wa");
515     }
516    
517     - if ($mounted)
518     - {
519     - system("/bin/umount", "$mntdir") == 0
520     - or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n");
521     - }
522     + $error_message = bunmount($mntdir,$VFSType);
523     + die($error_message) if $error_message;
524    
525     exit(0);
526     }
527     @@ -2502,9 +2489,8 @@
528     }
529    
530     my %backupfiles = ();
531     - my $mntdir = $rec->prop('MountDir') || '/mnt/smb';
532     + my $mntdir = $rec->prop('Mount') || '/mnt/smb';
533     my $mntbkdir;
534     - my $mounted;
535     my $key;
536     my $id = $rec->prop('Id') ||
537     $conf->get('SystemName')->value . '.' . $conf->get('DomainName')->value;
538     @@ -2516,6 +2502,7 @@
539     my $smbhost = $rec->prop('SmbHost');
540     my $smbshare = $rec->prop('SmbShare');
541     my $err;
542     + my $error_message;
543    
544     my $setbackuplist = sub {
545     if ( $_ =~ /\.dar/ )
546     @@ -2530,40 +2517,23 @@
547     @{$backupfiles{$_}}[1] = $backupref;
548     }
549     };
550     -
551     - # Mounting backups smb shared folder
552     -
553     - unless (-d $mntdir)
554     - {
555     - mkdir -p $mntdir;
556     - }
557     -
558     - my $login = $rec->prop('Login') || 'backup';
559     - my $password = $rec->prop('Password') || 'backup';
560    
561     - if ($err = dmount($smbhost,$smbshare,$mntdir,$login,$password,$VFSType))
562     - {
563     - esmith::cgi::genResult(
564     - $q, $fm->localise('ERR_MOUNTING_SMBSHARE') . "\n" . $err
565     - );
566     - return;
567     + # Mounting backup shared folder
568     + $error_message = bmount($mntdir,$smbhost,$smbshare,$VFSType);
569     + if ($error_message)
570     + {
571     + esmith::cgi::genResult($q, $error_message, $id);
572     + return;
573     }
574     - else {$mounted = 1}
575    
576     # Test if backup subdirectory for our server
577     -
578     - $mntbkdir = $mntdir . '/' . $id;
579     - unless ( -d $mntbkdir)
580     - {
581     - if ($mounted)
582     - {
583     - system("/bin/umount", "$mntdir") == 0
584     - or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n");
585     - }
586     - esmith::cgi::genResult(
587     - $q, $fm->localise('ERR_NO_HOST_DIR'), $id
588     - );
589     - return;
590     + $mntbkdir = $mntdir . "/$id";
591     + unless (-d $mntbkdir)
592     + {
593     + $error_message = $fm->localise('ERR_NO_HOST_DIR')."\n";
594     + $error_message .= bunmount($mntdir,$VFSType);
595     + esmith::cgi::genResult($q, $error_message, $id);
596     + return;
597     }
598    
599     my $catalog = "$mntbkdir/dar-catalog";
600     @@ -2651,11 +2621,8 @@
601    
602     esmith::cgi::genFooter ($q);
603    
604     - if ($mounted)
605     - {
606     - system("/bin/umount", "$mntdir") == 0
607     - or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n");
608     - }
609     + $error_message = bunmount($mntdir,$VFSType);
610     + die($error_message) if $error_message;
611     }
612    
613     sub performWorkstnSelRestore
614     @@ -2681,11 +2648,7 @@
615     my $backupwkrec = $conf->get('backupwk');
616     my $smbhost = $backupwkrec->prop('SmbHost');
617     my $smbshare = $backupwkrec->prop('SmbShare');
618     - my $login = $backupwkrec->prop('Login');
619     - my $password = $backupwkrec->prop('Password');
620     - my $mntdir = $backupwkrec->prop('MountDir') || '/mnt/smb';
621     - my $mntbkdir;
622     - my $mounted;
623     + my $mntdir = $backupwkrec->prop('Mount') || '/mnt/smb';
624     my $key;
625     my $id = $backupwkrec->prop('Id') ||
626     $conf->get('SystemName')->value . "." . $conf->get('DomainName')->value;
627     @@ -2693,6 +2656,7 @@
628     my %flabels = ();
629     my $VFSType = $backupwkrec->prop('VFSType') || 'cifs';
630     my $err;
631     + my $error_message;
632    
633     my $backupkey = $q->param ('backupset');
634     if ($backupkey =~ /^(.*)$/)
635     @@ -2705,32 +2669,23 @@
636     }
637    
638     # Mounting backup shared folder
639     -
640     - if ($err = dmount($smbhost,$smbshare,$mntdir,$login,$password,$VFSType))
641     - {
642     - esmith::cgi::genResult(
643     - $q, $fm->localise('ERR_MOUNTING_SMBSHARE') . "\n" . $err
644     - );
645     - return;
646     + $error_message = bmount($mntdir,$smbhost,$smbshare,$VFSType);
647     + if ($error_message)
648     + {
649     + esmith::cgi::genResult($q, $error_message, $id);
650     + return;
651     }
652     - else {$mounted = 1}
653    
654     # Test if backup subdirectory for our server
655     -
656     - $mntbkdir = $mntdir . "/$id";
657     + my $mntbkdir = $mntdir . "/$id";
658     unless (-d $mntbkdir)
659     - {
660     - if ($mounted)
661     - {
662     - system("/bin/umount", "$mntdir") == 0
663     - or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n");
664     - }
665     - esmith::cgi::genResult(
666     - $q, $fm->localise('ERR_NO_HOST_DIR'), $id
667     - );
668     - return;
669     + {
670     + $error_message = $fm->localise('ERR_NO_HOST_DIR')."\n";
671     + $error_message .= bunmount($mntdir,$VFSType);
672     + esmith::cgi::genResult($q, $error_message, $id);
673     + return;
674     }
675     -
676     +
677     # Read wanted file list from selected backup
678    
679     if (open(RD, "-|"))
680     @@ -2752,18 +2707,15 @@
681     }
682     else
683     {
684     - select(STDOUT);
685     - $| = 1;
686     + select(STDOUT);
687     + $| = 1;
688    
689     system ("/usr/bin/dar_manager", "-B", "$mntbkdir/dar-catalog", "-u", "$backupkey") == 0
690     - or die ($fm->localise('ERR_EXTRACT')." : ".$!);
691     + or die ($fm->localise('ERR_EXTRACT')." : ".$!);
692    
693     - if ($mounted)
694     - {
695     - system("/bin/umount", "$mntdir") == 0
696     - or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n");
697     - }
698     - exit(0);
699     + $error_message = bunmount($mntdir,$VFSType);
700     + die($error_message) if $error_message;
701     + exit(0);
702     }
703    
704     print $q->start_multipart_form(
705     @@ -2859,43 +2811,32 @@
706     }
707     }
708    
709     - # mounting backup shared folder
710     -
711     my $backupwkrec = $conf->get('backupwk');
712     - my $login = $backupwkrec->prop('Login');
713     - my $password = $backupwkrec->prop('Password');
714     my $id = $backupwkrec->prop('Id') ||
715     $conf->get('SystemName')->value . "." . $conf->get('DomainName')->value;
716     - my $mntdir = $backupwkrec->prop('MountDir') || '/mnt/smb';
717     - my $mounted;
718     + my $mntdir = $backupwkrec->prop('Mount') || '/mnt/smb';
719     my $VFSType = $backupwkrec->prop('VFSType') || 'cifs';
720     my $smbhost = $backupwkrec->prop('SmbHost');
721     my $smbshare = $backupwkrec->prop('SmbShare');
722     my $err;
723     -
724     - if ($err = dmount($smbhost,$smbshare,$mntdir,$login,$password,$VFSType))
725     - {
726     - esmith::cgi::genResult(
727     - $q, $fm->localise('ERR_MOUNTING_SMBSHARE') . "\n" . $err
728     - );
729     - return;
730     + my $error_message;
731     +
732     + # Mounting backup shared folder
733     + $error_message = bmount($mntdir,$smbhost,$smbshare,$VFSType);
734     + if ($error_message)
735     + {
736     + esmith::cgi::genResult($q, $error_message, $id);
737     + return;
738     }
739     - else {$mounted = 1}
740    
741     # Test if backup subdirectory for our server
742     -
743     my $mntbkdir = $mntdir . "/$id";
744     unless (-d $mntbkdir)
745     - {
746     - if ($mounted)
747     - {
748     - system("/bin/umount", "$mntdir") == 0
749     - or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n");
750     - }
751     - esmith::cgi::genResult(
752     - $q, $fm->localise('ERR_NO_HOST_DIR'), $id
753     - );
754     - return;
755     + {
756     + $error_message = $fm->localise('ERR_NO_HOST_DIR')."\n";
757     + $error_message .= bunmount($mntdir,$VFSType);
758     + esmith::cgi::genResult($q, $error_message, $id);
759     + return;
760     }
761    
762     # backup is online, restoring now
763     @@ -2953,14 +2894,10 @@
764     {
765     $restorerr = system ("/usr/bin/dar_manager -B \"$mntbkdir/dar-catalog\" -Q -k -e '-v -N -R / -w' -r @restorelist");
766     }
767     -
768     - if ($mounted)
769     - {
770     - system("/bin/umount", "$mntdir") == 0
771     - or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n");
772     - }
773    
774     - exit(0);
775     + $error_message = bunmount($mntdir,$VFSType);
776     + die($error_message) if $error_message;
777     + exit(0);
778     }
779     return;
780     }
781     @@ -3235,6 +3172,21 @@
782     return;
783     }
784    
785     +sub findmnt
786     +{
787     + my @mntin = qx( findmnt -n -l -o TARGET );
788     + my @mntout;
789     +
790     + foreach my $mount (@mntin)
791     + {
792     + next if ($mount =~ m/^\/proc|^\/dev|^\/sys|^\/boot/s);
793     + chomp $mount;
794     + next if ($mount eq '/');
795     + push @mntout, $mount;
796     + }
797     +
798     + return @mntout;
799     +}
800    
801     __DATA__
802     <form>

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed