/[smeserver]/rpms/e-smith-samba/sme8/e-smith-samba-2.2.0-shadow_copy.patch
ViewVC logotype

Contents of /rpms/e-smith-samba/sme8/e-smith-samba-2.2.0-shadow_copy.patch

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


Revision 1.1 - (show annotations) (download)
Sat Oct 12 00:06:17 2013 UTC (11 years ago) by burnat
Branch: MAIN
CVS Tags: e-smith-samba-2_2_0-59_el5_sme, e-smith-samba-2_2_0-62_el5_sme, e-smith-samba-2_2_0-61_el5_sme, e-smith-samba-2_2_0-63_el5_sme, e-smith-samba-2_2_0-66_el5_sme, e-smith-samba-2_2_0-65_el5_sme, e-smith-samba-2_2_0-60_el5_sme, e-smith-samba-2_2_0-64_el5_sme, HEAD
Error occurred while calculating annotation data.
* Thu Oct 10 2013 Greg Zartman <gzartman@koozali.org> 2.2.0-59.sme
- Replace vfs_shadow_copy with vfs_shadow_copy2 for shadow snapshots [SME: 7739]

1 diff -urN e-smith-samba-2.2.0.old/root/etc/e-smith/events/actions/shadow-copy-rotate e-smith-samba-2.2.0/root/etc/e-smith/events/actions/shadow-copy-rotate
2 --- e-smith-samba-2.2.0.old/root/etc/e-smith/events/actions/shadow-copy-rotate 2013-10-10 23:02:51.344638596 -0600
3 +++ e-smith-samba-2.2.0/root/etc/e-smith/events/actions/shadow-copy-rotate 2013-10-10 23:10:40.160682162 -0600
4 @@ -4,6 +4,7 @@
5 use warnings;
6 use POSIX qw(strftime);
7 use File::Path;
8 +use File::Basename;
9 use esmith::ConfigDB;
10 use esmith::AccountsDB;
11
12 @@ -11,6 +12,7 @@
13 sub stagger;
14 sub powershift;
15 sub shadowdir;
16 +sub rmshadow;
17
18 my $cdb = esmith::ConfigDB->open_ro;
19 my $adb = esmith::AccountsDB->open_ro();
20 @@ -27,6 +29,43 @@
21 my $filesdir = '/home/e-smith/files';
22 my $snapfmt = '@GMT-%Y.%m.%d-%H.%M.%S';
23
24 +# Switch old shadow directories to new format
25 +opendir(SHADOW, $shadowdir);
26 +foreach my $s ( grep { /^\d/ && ! -l "$shadowdir/$_" && -d "$shadowdir/$_" } readdir SHADOW ) {
27 + my @stat = stat("$shadowdir/$s");
28 + rename "$shadowdir/$s", "$shadowdir/".strftime($snapfmt, gmtime($stat[9]));
29 + symlink strftime($snapfmt, gmtime($stat[9])), "$shadowdir/$s";
30 +}
31 +closedir(SHADOW);
32 +
33 +# remove old symlinks in ibays
34 +foreach my $ibay ($adb->ibays()) {
35 + my $ibaydir = 'ibays/' . $ibay->key . ( $ibay->prop('PublicAccess') eq 'none' ? '/files' : '' );
36 +
37 + opendir(IBAY, "$filesdir/$ibaydir") || next;
38 + unlink "$filesdir/$ibaydir/$_" foreach (grep /^\@GMT-/, readdir(IBAY));
39 + closedir(IBAY);
40 +}
41 +
42 +# remove old symlinks in ibays
43 +foreach my $user ($adb->users()) {
44 + my $userdir = 'users/' . $user->key . '/home';
45 +
46 + opendir(USER, "$filesdir/$userdir") || next;
47 + unlink "$filesdir/$userdir/$_" foreach (grep /^\@GMT-/, readdir(USER));
48 + closedir(USER);
49 +}
50 +
51 +# Create sync point if it doesn't already exist
52 +my $snapdir = strftime($snapfmt, gmtime(time));
53 +if ( -d "$shadowdir/0" ) {
54 + rename "$shadowdir/".readlink("$shadowdir/0"), "$shadowdir/$snapdir";
55 + unlink "$shadowdir/0";
56 +} else {
57 + mkdir "$shadowdir/$snapdir";
58 +}
59 +symlink "$snapdir", "$shadowdir/0";
60 +
61 # Create list of ibays and users to shadow
62 my ($ibays, $users, $link) = ('','','');
63 my @ibays = grep { ($_->prop('ShadowCopy') || 'enabled') ne 'disabled' } $adb->ibays();
64 @@ -39,76 +78,53 @@
65
66 # Sync directories to shadow directory
67 if ( $ibays || $users) {
68 - system("rsync -aHmR --partial --exclude '\@GMT-*' $link $ibays $users $shadowdir/0/") == 0
69 - or die "Couldn't sync directories";
70 + system("rsync -aHmR --partial --delete --delete-excluded --exclude 'aquota.*' $link $ibays $users $shadowdir/0/") == 0
71 + or die "Couldn't sync directories";
72 }
73
74 # Shift directories using geometric roll-off (only if different)
75 if ( -d "$shadowdir/1" ) {
76 - if (system("diff -qr $shadowdir/0 $shadowdir/1 > /dev/null") == 0) {
77 - rmtree "$shadowdir/0";
78 - } else {
79 - powershift(2) if -d shadowdir(-$offset);
80 - for (my $i=2; $i >= -$offset; $i--) {
81 - rename shadowdir($i), shadowdir($i+1)
82 - }
83 - }
84 + if (system("diff -qr $shadowdir/0 $shadowdir/1 &> /dev/null") == 0) {
85 + rmshadow("$shadowdir/0");
86 + } else {
87 + powershift(2) if -d shadowdir(-$offset);
88 + for (my $i=2; $i >= -$offset; $i--) {
89 + rename shadowdir($i), shadowdir($i+1)
90 + }
91 + }
92 } else {
93 - rename "$shadowdir/0", "$shadowdir/1";
94 -}
95 -
96 -opendir(SHADOW, $shadowdir);
97 -my %snaps = map { my @stat = stat("$shadowdir/$_"); $_ => strftime($snapfmt, gmtime($stat[9])) }
98 - grep { -d "$shadowdir/$_" && ! /^\./ } readdir SHADOW;
99 -closedir(SHADOW);
100 -
101 -foreach my $ibay ($adb->ibays()) {
102 - my $ibaydir = 'ibays/' . $ibay->key . ( $ibay->prop('PublicAccess') eq 'none' ? '/files' : '' );
103 -
104 - opendir(IBAY, "$filesdir/$ibaydir") || next;
105 - unlink "$filesdir/$ibaydir/$_" foreach (grep /^\@GMT-/, readdir(IBAY));
106 - closedir(IBAY);
107 -
108 - next if ($ibay->prop('ShadowCopy') || 'enabled') eq 'disabled';
109 -
110 - foreach my $snap (keys %snaps) {
111 - symlink "$shadowdir/$snap/$ibaydir", "$filesdir/$ibaydir/$snaps{$snap}" if -d "$shadowdir/$snap/$ibaydir";
112 - }
113 + rename "$shadowdir/0", "$shadowdir/1";
114 }
115
116 -foreach my $user ($adb->users()) {
117 - my $userdir = 'users/' . $user->key . '/home';
118 -
119 - opendir(USER, "$filesdir/$userdir") || next;
120 - unlink "$filesdir/$userdir/$_" foreach (grep /^\@GMT-/, readdir(USER));
121 - closedir(USER);
122 -
123 - next if ($user->prop('ShadowCopy') || 'enabled') eq 'disabled';
124 -
125 - foreach my $snap (keys %snaps) {
126 - symlink "$shadowdir/$snap/$userdir", "$filesdir/$userdir/$snaps{$snap}" if -d "$shadowdir/$snap/$userdir";
127 - }
128 +sub rmshadow {
129 + my $d = shift;
130 + if ( -l "$d" ) {
131 + rmtree dirname($d)."/".readlink($d);
132 + unlink "$d";
133 + } elsif ( -d "$d" ) {
134 + rmtree "$d"
135 + }
136 }
137
138 sub shadowdir {
139 - my $i = shift;
140 - return "$shadowdir/".($i+$offset);
141 + my $i = shift;
142 + return "$shadowdir/".($i+$offset);
143 }
144
145 sub stagger {
146 - my $i = shift;
147 - return $i + ($i >> 1);
148 + my $i = shift;
149 + return $i + ($i >> 1);
150 }
151
152 sub powershift {
153 - my $i = shift;
154 - if ( -d shadowdir(stagger($i)) ) {
155 - my $n = powershift($i << 1);
156 - $i = $n >> 1;
157 - rename shadowdir(stagger($i)), shadowdir($n) if -d shadowdir(stagger($i));
158 - rmtree shadowdir($i) if -d shadowdir($i);
159 - } else {
160 - rename shadowdir($i), shadowdir(stagger($i)) if -d shadowdir($i);
161 - }
162 - return $i;
163 + my $i = shift;
164 + if ( -d shadowdir(stagger($i)) ) {
165 + my $n = powershift($i << 1);
166 + $i = $n >> 1;
167 + rename shadowdir(stagger($i)), shadowdir($n) if -d shadowdir(stagger($i));
168 + rmshadow(shadowdir($i));
169 + } else {
170 + rename shadowdir($i), shadowdir(stagger($i)) if -d shadowdir($i);
171 + }
172 + return $i;
173 }
174 diff -urN e-smith-samba-2.2.0.old/root/etc/e-smith/templates/etc/smb.conf/10shadowcopy e-smith-samba-2.2.0/root/etc/e-smith/templates/etc/smb.conf/10shadowcopy
175 --- e-smith-samba-2.2.0.old/root/etc/e-smith/templates/etc/smb.conf/10shadowcopy 2013-10-10 23:02:51.355639734 -0600
176 +++ e-smith-samba-2.2.0/root/etc/e-smith/templates/etc/smb.conf/10shadowcopy 2013-10-10 23:08:38.211712503 -0600
177 @@ -1,4 +1,8 @@
178 {
179 - $vfs->{shadow_copy} = () if (($smb{'ShadowCopy'} || 'disabled') eq 'enabled');
180 $OUT = "";
181 + return unless (($smb{'ShadowCopy'} || 'disabled') eq 'enabled');
182 +
183 + $vfs->{shadow_copy2}->{snapdir} = $smb{ShadowDir} || '/home/e-smith/files/.shadow';
184 + $vfs->{shadow_copy2}->{basedir} = "/home/e-smith/files";
185 + $vfs->{shadow_copy2}->{fixinodes} = 'yes';
186 }
187 diff -urN e-smith-samba-2.2.0.old/root/etc/e-smith/templates/etc/smb.conf/50homesVFS e-smith-samba-2.2.0/root/etc/e-smith/templates/etc/smb.conf/50homesVFS
188 --- e-smith-samba-2.2.0.old/root/etc/e-smith/templates/etc/smb.conf/50homesVFS 2013-10-10 23:02:51.349639148 -0600
189 +++ e-smith-samba-2.2.0/root/etc/e-smith/templates/etc/smb.conf/50homesVFS 2013-10-10 23:08:38.211712503 -0600
190 @@ -3,8 +3,9 @@
191
192 $OUT = "vfs objects = " . (join " ", keys %$vfs) . "\n";
193 foreach $mod (keys %$vfs) {
194 + ($mod2) = $mod =~ m{^([^_]+)};
195 foreach $opt (keys %{$vfs->{$mod}}) {
196 - $OUT .= " $mod:$opt=$vfs->{$mod}->{$opt}\n";
197 + $OUT .= " $mod2:$opt=$vfs->{$mod}->{$opt}\n";
198 }
199 }
200 }
201 diff -urN e-smith-samba-2.2.0.old/root/etc/e-smith/templates/etc/smb.conf/ibays/10shadowcopy e-smith-samba-2.2.0/root/etc/e-smith/templates/etc/smb.conf/ibays/10shadowcopy
202 --- e-smith-samba-2.2.0.old/root/etc/e-smith/templates/etc/smb.conf/ibays/10shadowcopy 2013-10-10 23:02:51.352639452 -0600
203 +++ e-smith-samba-2.2.0/root/etc/e-smith/templates/etc/smb.conf/ibays/10shadowcopy 2013-10-10 23:09:05.903562870 -0600
204 @@ -3,5 +3,7 @@
205 return if (($smb{'ShadowCopy'} || 'disabled') eq 'disabled');
206 return if (($ibay->prop('ShadowCopy') || 'enabled') eq 'disabled');
207
208 - $ibay_vfs->{shadow_copy} = ();
209 + $ibay_vfs->{shadow_copy2}->{snapdir} = $smb{ShadowDir} || '/home/e-smith/files/.shadow';
210 + $ibay_vfs->{shadow_copy2}->{basedir} = "/home/e-smith/files";
211 + $ibay_vfs->{shadow_copy2}->{fixinodes} = 'yes';
212 }
213 diff -urN e-smith-samba-2.2.0.old/root/etc/e-smith/templates/etc/smb.conf/ibays/90vfs e-smith-samba-2.2.0/root/etc/e-smith/templates/etc/smb.conf/ibays/90vfs
214 --- e-smith-samba-2.2.0.old/root/etc/e-smith/templates/etc/smb.conf/ibays/90vfs 2013-10-10 23:02:51.351639352 -0600
215 +++ e-smith-samba-2.2.0/root/etc/e-smith/templates/etc/smb.conf/ibays/90vfs 2013-10-10 23:09:05.903562870 -0600
216 @@ -3,8 +3,9 @@
217
218 $OUT = "vfs objects = " . (join " ", keys %$ibay_vfs) . "\n";
219 foreach $mod (keys %$ibay_vfs) {
220 + ($mod2) = $mod =~ m{^([^_]+)};
221 foreach $opt (keys %{$ibay_vfs->{$mod}}) {
222 - $OUT .= " $mod:$opt=$ibay_vfs->{$mod}->{$opt}\n";
223 + $OUT .= " $mod2:$opt=$ibay_vfs->{$mod}->{$opt}\n";
224 }
225 }
226 }

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