/[smeserver]/rpms/e-smith-backup/sme10/e-smith-backup-2.6.0-replacehal.patch
ViewVC logotype

Annotation of /rpms/e-smith-backup/sme10/e-smith-backup-2.6.0-replacehal.patch

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


Revision 1.2 - (hide annotations) (download)
Tue Feb 9 21:41:18 2021 UTC (3 years, 8 months ago) by chrissn
Branch: MAIN
CVS Tags: e-smith-backup-2_6_0-21_el7_sme
Changes since 1.1: +7 -60 lines
Tweak replacehal backup patch to remove RM requirement [SME: 11319]

1 chrissn 1.1 diff -urN e-smith-backup-2.6.0.old/root/etc/e-smith/events/actions/workstation-backup-dar e-smith-backup-2.6.0/root/etc/e-smith/events/actions/workstation-backup-dar
2 chrissn 1.2 --- e-smith-backup-2.6.0.old/root/etc/e-smith/events/actions/workstation-backup-dar 2021-02-09 21:26:24.961634134 +0000
3     +++ e-smith-backup-2.6.0/root/etc/e-smith/events/actions/workstation-backup-dar 2021-02-09 21:29:49.256523741 +0000
4 chrissn 1.1 @@ -31,6 +31,7 @@
5     use File::Glob qw(bsd_glob);
6     use esmith::ConfigDB;
7     use esmith::Backup;
8     +use esmith::BlockDevices;
9    
10     sub ldie;
11     sub start_dar_killer;
12     @@ -312,77 +313,61 @@
13     return $code;
14     }
15    
16     -
17     +# Copied from /etc/e-smith/web/functions/backup
18     +# TODO: Move to a shared module
19     sub checkMount
20     {
21     # check if $mountdir is mounted
22     my $mountdir = shift;
23     $|=1; # Auto-flush
24     -
25     - # copy STDOUT to another filehandle
26     - open (my $STDOLD, '>&', STDOUT);
27     -
28     - open(STDOUT, ">/dev/null");
29     - if ( open(MOUNTDIR, "|-", "/bin/findmnt", $mountdir)){;}
30    
31     - # restore STDOUT
32     - open (STDOUT, '>&', $STDOLD);
33     -
34     - return (!close(MOUNTDIR));
35     + my @res = qx( findmnt $mountdir );
36     + return ( !@res );
37     }
38    
39    
40     -# dmount is copied from /etc/e-smith/web/functions/backup
41     -# it could become a common function later
42     +# Copied from /etc/e-smith/web/functions/backup
43     +# TODO: Move to a shared module
44     sub dmount
45     {
46     # mount dar unit according to dar-workstation configuration
47     # return nothing if mount successfull
48    
49     my ($host,$share,$mountdir,$login,$password,$VFSType) = @_;
50     -
51     +
52     if ($VFSType eq 'cifs')
53     {
54     - return ( qx(/bin/mount -t cifs "//$host/$share" $mountdir -o credentials=/etc/dar/CIFScredentials,nounix 2>&1) );
55     + return ( qx(/bin/mount -t cifs "//$host/$share" $mountdir -o credentials=/etc/dar/CIFScredentials,nounix 2>&1) );
56     }
57     elsif ($VFSType eq 'nfs')
58     {
59     - return ( qx(/bin/mount -t nfs -o nolock "$host:/$share" $mountdir 2>&1) );
60     + return ( qx(/bin/mount -t nfs -o nolock "$host:/$share" $mountdir 2>&1) );
61     }
62     elsif ($VFSType eq 'usb')
63     {
64     my $device = "";
65     - my $blkdev = "";
66     my $vollbl = "";
67     - foreach my $udi (qx(hal-find-by-property --key volume.fsusage --string filesystem))
68     - {
69     - $udi =~ m/^(\S+)/;
70     - my $is_mounted = qx(hal-get-property --udi $1 --key volume.is_mounted);
71    
72     - if ($is_mounted eq "false\n")
73     - {
74     - $blkdev = qx(hal-get-property --udi $1 --key block.device);
75     - if ($blkdev =~ m/^(\S+)/) {$blkdev = $1;}
76     - }
77     - if ($is_mounted eq "false\n")
78     - {
79     - $vollbl = qx(hal-get-property --udi $1 --key volume.label);
80     - $vollbl =~ m/^(\S+)/;
81     - if ($vollbl =~ /^\s/) {$vollbl = 'nolabel';}
82     - }
83     + my $devices = esmith::BlockDevices->new ('allowmount' => 'disabled');
84 chrissn 1.2 + my ($valid, $invalid) = $devices->checkBackupDrives(0);
85 chrissn 1.1
86     - chomp $vollbl;
87     - chomp $blkdev;
88     - $vollbl = "media/$vollbl";
89     - if ($vollbl eq $share) {$device = $blkdev;}
90     + if ( ${$valid}[0] ) {
91     + foreach ( @{$valid} ) {
92     + warn $_;
93     + $vollbl = $devices->label($_);
94     + if ( $share eq "media/$vollbl" ) {
95     + $device = "/dev/$_";
96     + }
97     + }
98     }
99     - return ( qx(/bin/mount $device "/$share" 2>&1) );
100     + $devices->destroy;
101     + return ( qx (mount $device /$share 2>&1) );
102     }
103     else
104     {
105     - return ("Mount of type $VFSType not supported.\n");
106     + return ("Error while mounting $host/$share : $VFSType not supported.\n");
107     }
108     -}
109     +}
110    
111    
112     sub removeTree
113     diff -urN e-smith-backup-2.6.0.old/root/etc/e-smith/web/functions/backup e-smith-backup-2.6.0/root/etc/e-smith/web/functions/backup
114 chrissn 1.2 --- e-smith-backup-2.6.0.old/root/etc/e-smith/web/functions/backup 2021-02-09 21:26:24.926635870 +0000
115     +++ e-smith-backup-2.6.0/root/etc/e-smith/web/functions/backup 2021-02-09 21:29:21.581890670 +0000
116 chrissn 1.1 @@ -27,6 +27,7 @@
117     use esmith::ConfigDB;
118     use esmith::Backup;
119     use esmith::BackupHistoryDB;
120     +use esmith::BlockDevices;
121     use esmith::AccountsDB;
122     use esmith::cgi;
123     use esmith::util;
124     @@ -697,9 +698,9 @@
125     if (defined $status && $status eq "on")
126     {
127    
128     - #--------------------------------------------------
129     - # Untaint parameters and check for validity
130     - #--------------------------------------------------
131     + #--------------------------------------------------
132     + # Untaint parameters and check for validity
133     + #--------------------------------------------------
134    
135     my $backupHour = $q->param ('backupHour');
136     if ($backupHour =~ /^(.*)$/) {
137     @@ -1237,23 +1238,20 @@
138     $q, undef, $fm->localise('CONFIGURE_WORKSTN_BACKUP'));
139    
140     if ( $VFSType eq 'usb' ) {
141     - foreach my $udi (qx(hal-find-by-property --key volume.fsusage --string filesystem)) {
142     - $udi =~ m/^(\S+)/;
143     + my $devices = esmith::BlockDevices->new ('allowmount' => 'disabled');
144 chrissn 1.2 + my ($valid, $invalid) = $devices->checkBackupDrives(0);
145 chrissn 1.1
146     - my $is_mounted = qx(hal-get-property --udi $1 --key volume.is_mounted);
147     -
148     - if ($is_mounted eq "false\n") {
149     - my $vollbl = qx(hal-get-property --udi $1 --key volume.label);
150     - $vollbl =~ m/^(\S+)/;
151     - if ($vollbl =~ /^\s/) {$vollbl = 'nolabel';}
152     - chomp $vollbl;
153     - push @usbdisks, $vollbl;
154     + if ( ${$valid}[0] ) {
155     + foreach ( @{$valid} ) {
156     + push @usbdisks, $devices->label($_);
157     }
158     }
159     - unless ($usbdisks[0]){
160     + else
161     + {
162     push @usbdisks, $fm->localise('ERR_NO_USB_DISK');
163     $error='nousb';
164     }
165     + $devices->destroy;
166     }
167     if ( $VFSType eq 'mnt' )
168     {
169     @@ -1509,9 +1507,9 @@
170     return;
171     }
172    
173     - #--------------------------------------------------
174     - # Untaint parameters and check for validity
175     - #--------------------------------------------------
176     + #--------------------------------------------------
177     + # Untaint parameters and check for validity
178     + #--------------------------------------------------
179    
180     my $VFSType = $q->param ('VFSType');
181     if ( $VFSType eq 'nousb')
182     @@ -3007,7 +3005,7 @@
183     my $dumpsize = 0;
184    
185     open(DF, "-|")
186     - or exec '/bin/df', '-P', '-t', 'ext3', '-t', 'ext4';
187     + or exec '/bin/df', '-P', '-t', 'ext3', '-t', 'ext4', '-t', 'xfs';
188    
189     while (<DF>)
190     {
191     @@ -3034,7 +3032,7 @@
192     my $halffree = 0;
193    
194     open(DF, "-|")
195     - or exec '/bin/df', '-P', '-t', 'ext3', '-t', 'ext4', '/tmp';
196     + or exec '/bin/df', '-P', '-t', 'ext3', '-t', 'ext4', '-t', 'xfs', '/tmp';
197    
198     while (<DF>)
199     {
200     @@ -3106,30 +3104,21 @@
201     elsif ($VFSType eq 'usb')
202     {
203     my $device = "";
204     - my $blkdev = "";
205     my $vollbl = "";
206     - foreach my $udi (qx(hal-find-by-property --key volume.fsusage --string filesystem)) {
207     - $udi =~ m/^(\S+)/;
208     - my $is_mounted = qx(hal-get-property --udi $1 --key volume.is_mounted);
209     -
210     - if ($is_mounted eq "false\n") {
211     - $blkdev = qx(hal-get-property --udi $1 --key block.device);
212     - if ($blkdev =~ m/^(\S+)/) {$blkdev = $1;}
213     - }
214     - if ($is_mounted eq "false\n") {
215     - $vollbl = qx(hal-get-property --udi $1 --key volume.label);
216     - $vollbl =~ m/^(\S+)/;
217     - if ($vollbl =~ /^\s/) {$vollbl = 'nolabel';}
218     - }
219     -
220     - chomp $vollbl;
221     - chomp $blkdev;
222     - $vollbl = "media/$vollbl";
223     - if ($vollbl eq $share) {
224     - $device = $blkdev;
225     - }
226     +
227     + my $devices = esmith::BlockDevices->new ('allowmount' => 'disabled');
228 chrissn 1.2 + my ($valid, $invalid) = $devices->checkBackupDrives(0);
229 chrissn 1.1 +
230     + if ( ${$valid}[0] ) {
231     + foreach ( @{$valid} ) {
232     + $vollbl = $devices->label($_);
233     + if ( $share eq "media/$vollbl" ) {
234     + $device = "/dev/$_";
235     + }
236     + }
237     }
238     - return ( qx(/bin/mount $device "/$share" 2>&1) );
239     + $devices->destroy;
240     + return ( qx (mount $device /$share 2>&1) );
241     }
242     else
243     {
244     @@ -3142,17 +3131,9 @@
245     # check if $mountdir is mounted
246     my $mountdir = shift;
247     $|=1; # Auto-flush
248     -
249     - # copy STDOUT to another filehandle
250     - open (my $STDOLD, '>&', STDOUT);
251     -
252     - open(STDOUT, ">/dev/null");
253     - if ( open(MOUNTDIR, "|-", "/bin/findmnt", $mountdir)){;}
254     -
255     - # restore STDOUT
256     - open (STDOUT, '>&', $STDOLD);
257     -
258     - return (!close(MOUNTDIR));
259     +
260     + my @res = qx( findmnt $mountdir );
261     + return ( !@res );
262     }
263    
264     sub bmount

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