/[smecontribs]/rpms/smeserver-arkeia/contribs7/smeserver-arkeia-1.0-rotate.patch
ViewVC logotype

Contents of /rpms/smeserver-arkeia/contribs7/smeserver-arkeia-1.0-rotate.patch

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


Revision 1.2 - (show annotations) (download)
Sun Nov 23 04:57:55 2008 UTC (16 years ago) by slords
Branch: MAIN
Changes since 1.1: +0 -0 lines
FILE REMOVED
Part of epel

1 diff -Nur -x '*.orig' -x '*.rej' smeserver-arkeia-1.0/createlinks mezzanine_patched_smeserver-arkeia-1.0/createlinks
2 --- smeserver-arkeia-1.0/createlinks 2007-07-10 09:31:38.000000000 -0600
3 +++ mezzanine_patched_smeserver-arkeia-1.0/createlinks 2007-07-10 09:19:59.000000000 -0600
4 @@ -13,6 +13,7 @@
5
6 foreach my $event (qw(pre-backup))
7 {
8 + event_link("rotate-tape", $event, "05");
9 event_link("arkeia-delete-dumped-catalog", $event, "11");
10 event_link("arkeia-dump-catalog", $event, "21");
11 event_link("arkeia-recycle-tape", $event, "60");
12 diff -Nur -x '*.orig' -x '*.rej' smeserver-arkeia-1.0/root/etc/e-smith/events/actions/rotate-tape mezzanine_patched_smeserver-arkeia-1.0/root/etc/e-smith/events/actions/rotate-tape
13 --- smeserver-arkeia-1.0/root/etc/e-smith/events/actions/rotate-tape 1969-12-31 17:00:00.000000000 -0700
14 +++ mezzanine_patched_smeserver-arkeia-1.0/root/etc/e-smith/events/actions/rotate-tape 2007-07-10 09:31:34.000000000 -0600
15 @@ -0,0 +1,56 @@
16 +#!/usr/bin/perl -w
17 +
18 +package esmith;
19 +
20 +use strict;
21 +use esmith::ConfigDB;
22 +use POSIX qw(floor);
23 +
24 +sub max ($$) { $_[$_[0] < $_[1]] };
25 +
26 +my $event = shift;
27 +my $cause = shift;
28 +exit 0 if not defined $cause or $cause ne "tape";
29 +
30 +my $confdb = esmith::ConfigDB->open;
31 +my $arkeia = $confdb->get('arkeia') or die "No arkeia db entry found\n";
32 +my $rotate = $arkeia->prop('Rotate') || 'no';
33 +my $changer = $arkeia->prop('Changer') || '/dev/changer';
34 +
35 +exit 0 unless $rotate eq 'yes';
36 +exit 0 unless -c $changer;
37 +
38 +my $daily = $arkeia->prop("Daily") || 0;
39 +my $weekly = $arkeia->prop("Weekly") || 0;
40 +my $monthly = $arkeia->prop("Monthly") || 0;
41 +my $quarterly = $arkeia->prop("Quarterly") || 0;
42 +my $yearly = $arkeia->prop("Yearly") || 0;
43 +
44 +my $base = int(time()/86400);
45 +my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime($base*86400);
46 +my $y = $yearly ? max(($year-69) - ($yday <= $wday ? 1 : 0), 0) : 0;
47 +my $q = $quarterly ? max(($year-70)*4 + int($mon/3) - ($mon % 3 == 0 && $mday <= $wday ? 1 : 0) + 1 - $y, 0) : 0;
48 +my $m = $monthly ? max(($year-70)*12 + $mon - ($mday <= $wday ? 1 : 0) + 1 - $y - $q, 0) : 0;
49 +my $w = $weekly ? max(floor(($base-3)/7) + 1 - $y - $q - $m, 0) : 0;
50 +my $d = $daily ? max($base - 2 - $y - $q - $m - $w, 0) : 0;
51 +
52 +my $slot = 0;
53 +if ( $wday ) {
54 + $slot = ($d - 1) % $daily + 1;
55 +} else {
56 + if ( $yearly && $yday <= 7 ) {
57 + $slot = $daily + $weekly + $monthly + $quarterly + ($y - 1) % $yearly + 1;
58 + } elsif ( $quarterly && $mon % 3 == 0 && $mday <= 7 ) {
59 + $slot = $daily + $weekly + $monthly + ($q - 1) % $quarterly + 1;
60 + } elsif ( $monthly && $mday <= 7 ) {
61 + $slot = $daily + $weekly + ($m - 1) % $monthly + 1;
62 + } elsif ( $weekly ) {
63 + $slot = $daily + ($w - 1) % $weekly + 1;
64 + } else {
65 + $slot = ($d - 1) % $daily + 1;
66 + }
67 +}
68 +exit 0 unless $slot;
69 +
70 +system("/usr/sbin/mtx -f $changer unload &> /dev/null");
71 +system("/usr/sbin/mtx -f $changer load $slot") && die("A problem occurred execing mtx\n");

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