/[smeserver]/rpms/e-smith-samba/sme8/e-smith-samba-1.14.0-shadowcopy.patch
ViewVC logotype

Annotation of /rpms/e-smith-samba/sme8/e-smith-samba-1.14.0-shadowcopy.patch

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


Revision 1.2 - (hide annotations) (download)
Sat Dec 15 16:03:54 2007 UTC (16 years, 11 months ago) by slords
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +0 -0 lines
FILE REMOVED
Import on branch sme8 of package e-smith-samba-1.14.1-1.el5.sme.src.rpm

1 slords 1.1 diff -Nur -x '*.orig' -x '*.rej' e-smith-samba-1.14.0/root/etc/e-smith/events/actions/shadow-copy-rotate mezzanine_patched_e-smith-samba-1.14.0/root/etc/e-smith/events/actions/shadow-copy-rotate
2     --- e-smith-samba-1.14.0/root/etc/e-smith/events/actions/shadow-copy-rotate 1969-12-31 17:00:00.000000000 -0700
3     +++ mezzanine_patched_e-smith-samba-1.14.0/root/etc/e-smith/events/actions/shadow-copy-rotate 2007-01-10 14:03:38.000000000 -0700
4     @@ -0,0 +1,106 @@
5     +#!/usr/bin/perl
6     +
7     +use strict;
8     +use warnings;
9     +use POSIX qw(strftime);
10     +use File::Path;
11     +use esmith::ConfigDB;
12     +use esmith::AccountsDB;
13     +
14     +# Routines taken from powershift of rlbackup
15     +sub stagger;
16     +sub powershift;
17     +sub shadowdir;
18     +
19     +my $cdb = esmith::ConfigDB->open_ro;
20     +my $adb = esmith::AccountsDB->open_ro();
21     +
22     +my $smb = $cdb->get('smb') or die "No smb db entry found\n";
23     +my $shadowdir = $smb->prop('ShadowDir') || '/home/e-smith/files/.shadow';
24     +my $shadowcopy = $smb->prop('ShadowCopy') || 'disabled';
25     +my $offset = ($smb->prop('ShadowCount') || 2) - 2;
26     +$offset = 0 if $offset < 0;
27     +
28     +exit unless -d $shadowdir;
29     +exit if $shadowcopy eq 'disabled';
30     +
31     +my $filesdir = '/home/e-smith/files';
32     +my $snapfmt = '@GMT-%Y.%m.%d-%H.%M.%S';
33     +
34     +# Create list of ibays and users to shadow
35     +my $ibays = join ',', map { $_->key } grep { ($_->prop('ShadowCopy') || 'enabled') ne 'disabled' } $adb->ibays();
36     +my $users = join ',', map { $_->key } grep { ($_->prop('ShadowCopy') || 'enabled') ne 'disabled' } $adb->users();
37     +
38     +# Sync directories to shadow directory
39     +system("rsync -aHmR --partial --exclude '\@GMT-*' --link-dest ../1 " .
40     + "$filesdir/./ibays/{$ibays}/ $filesdir/./users/{$users}/home/ $shadowdir/0/") == 0 || die "Couldn't sync directories";
41     +
42     +# Shift directories using geometric roll-off (only if different)
43     +if ( -d "$shadowdir/1" ) {
44     + if (system("diff -qr $shadowdir/0 $shadowdir/1 > /dev/null") == 0) {
45     + rmtree "$shadowdir/0";
46     + } else {
47     + powershift(2) if -d shadowdir(-$offset);
48     + for (my $i=2; $i >= -$offset; $i--) {
49     + rename shadowdir($i), shadowdir($i+1)
50     + }
51     + }
52     +} else {
53     + rename "$shadowdir/0", "$shadowdir/1";
54     +}
55     +
56     +opendir(SHADOW, $shadowdir);
57     +my %snaps = map { my @stat = stat("$shadowdir/$_"); $_ => strftime($snapfmt, gmtime($stat[9])) }
58     + grep { -d "$shadowdir/$_" && ! /^\./ } readdir SHADOW;
59     +closedir(SHADOW);
60     +
61     +foreach my $ibay ($adb->ibays()) {
62     + my $ibaydir = 'ibays/' . $ibay->key . ( $ibay->prop('PublicAccess') eq 'none' ? '/files' : '' );
63     +
64     + opendir(IBAY, "$filesdir/$ibaydir") || next;
65     + unlink "$filesdir/$ibaydir/$_" foreach (grep /^\@GMT-/, readdir(IBAY));
66     + closedir(IBAY);
67     +
68     + next if ($ibay->prop('ShadowCopy') || 'enabled') eq 'disabled';
69     +
70     + foreach my $snap (keys %snaps) {
71     + symlink "$shadowdir/$snap/$ibaydir", "$filesdir/$ibaydir/$snaps{$snap}" if -d "$shadowdir/$snap/$ibaydir";
72     + }
73     +}
74     +
75     +foreach my $user ($adb->users()) {
76     + my $userdir = 'users/' . $user->key . '/home';
77     +
78     + opendir(USER, "$filesdir/$userdir") || next;
79     + unlink "$filesdir/$userdir/$_" foreach (grep /^\@GMT-/, readdir(USER));
80     + closedir(USER);
81     +
82     + next if ($user->prop('ShadowCopy') || 'enabled') eq 'disabled';
83     +
84     + foreach my $snap (keys %snaps) {
85     + symlink "$shadowdir/$snap/$userdir", "$filesdir/$userdir/$snaps{$snap}" if -d "$shadowdir/$snap/$userdir";
86     + }
87     +}
88     +
89     +sub shadowdir {
90     + my $i = shift;
91     + return "$shadowdir/".($i+$offset);
92     +}
93     +
94     +sub stagger {
95     + my $i = shift;
96     + return $i + ($i >> 1);
97     +}
98     +
99     +sub powershift {
100     + my $i = shift;
101     + if ( -d shadowdir(stagger($i)) ) {
102     + my $n = powershift($i << 1);
103     + $i = $n >> 1;
104     + rename shadowdir(stagger($i)), shadowdir($n) if -d shadowdir(stagger($i));
105     + rmtree shadowdir($i) if -d shadowdir($i);
106     + } else {
107     + rename shadowdir($i), shadowdir(stagger($i)) if -d shadowdir($i);
108     + }
109     + return $i;
110     +}
111     diff -Nur -x '*.orig' -x '*.rej' e-smith-samba-1.14.0/root/etc/e-smith/db/configuration/defaults/smb/ShadowCount mezzanine_patched_e-smith-samba-1.14.0/root/etc/e-smith/db/configuration/defaults/smb/ShadowCount
112     --- e-smith-samba-1.14.0/root/etc/e-smith/db/configuration/defaults/smb/ShadowCount 1969-12-31 17:00:00.000000000 -0700
113     +++ mezzanine_patched_e-smith-samba-1.14.0/root/etc/e-smith/db/configuration/defaults/smb/ShadowCount 2007-01-10 14:07:29.000000000 -0700
114     @@ -0,0 +1 @@
115     +10
116     diff -Nur -x '*.orig' -x '*.rej' e-smith-samba-1.14.0/root/etc/e-smith/db/configuration/defaults/smb/ShadowDir mezzanine_patched_e-smith-samba-1.14.0/root/etc/e-smith/db/configuration/defaults/smb/ShadowDir
117     --- e-smith-samba-1.14.0/root/etc/e-smith/db/configuration/defaults/smb/ShadowDir 1969-12-31 17:00:00.000000000 -0700
118     +++ mezzanine_patched_e-smith-samba-1.14.0/root/etc/e-smith/db/configuration/defaults/smb/ShadowDir 2007-01-10 14:07:15.000000000 -0700
119     @@ -0,0 +1 @@
120     +/home/e-smith/files/.shadow

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