diff -Nur -x '*.orig' -x '*.rej' smeserver-arkeia-1.0/createlinks mezzanine_patched_smeserver-arkeia-1.0/createlinks --- smeserver-arkeia-1.0/createlinks 2007-07-10 09:31:38.000000000 -0600 +++ mezzanine_patched_smeserver-arkeia-1.0/createlinks 2007-07-10 09:19:59.000000000 -0600 @@ -13,6 +13,7 @@ foreach my $event (qw(pre-backup)) { + event_link("rotate-tape", $event, "05"); event_link("arkeia-delete-dumped-catalog", $event, "11"); event_link("arkeia-dump-catalog", $event, "21"); event_link("arkeia-recycle-tape", $event, "60"); 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 --- smeserver-arkeia-1.0/root/etc/e-smith/events/actions/rotate-tape 1969-12-31 17:00:00.000000000 -0700 +++ mezzanine_patched_smeserver-arkeia-1.0/root/etc/e-smith/events/actions/rotate-tape 2007-07-10 09:31:34.000000000 -0600 @@ -0,0 +1,56 @@ +#!/usr/bin/perl -w + +package esmith; + +use strict; +use esmith::ConfigDB; +use POSIX qw(floor); + +sub max ($$) { $_[$_[0] < $_[1]] }; + +my $event = shift; +my $cause = shift; +exit 0 if not defined $cause or $cause ne "tape"; + +my $confdb = esmith::ConfigDB->open; +my $arkeia = $confdb->get('arkeia') or die "No arkeia db entry found\n"; +my $rotate = $arkeia->prop('Rotate') || 'no'; +my $changer = $arkeia->prop('Changer') || '/dev/changer'; + +exit 0 unless $rotate eq 'yes'; +exit 0 unless -c $changer; + +my $daily = $arkeia->prop("Daily") || 0; +my $weekly = $arkeia->prop("Weekly") || 0; +my $monthly = $arkeia->prop("Monthly") || 0; +my $quarterly = $arkeia->prop("Quarterly") || 0; +my $yearly = $arkeia->prop("Yearly") || 0; + +my $base = int(time()/86400); +my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime($base*86400); +my $y = $yearly ? max(($year-69) - ($yday <= $wday ? 1 : 0), 0) : 0; +my $q = $quarterly ? max(($year-70)*4 + int($mon/3) - ($mon % 3 == 0 && $mday <= $wday ? 1 : 0) + 1 - $y, 0) : 0; +my $m = $monthly ? max(($year-70)*12 + $mon - ($mday <= $wday ? 1 : 0) + 1 - $y - $q, 0) : 0; +my $w = $weekly ? max(floor(($base-3)/7) + 1 - $y - $q - $m, 0) : 0; +my $d = $daily ? max($base - 2 - $y - $q - $m - $w, 0) : 0; + +my $slot = 0; +if ( $wday ) { + $slot = ($d - 1) % $daily + 1; +} else { + if ( $yearly && $yday <= 7 ) { + $slot = $daily + $weekly + $monthly + $quarterly + ($y - 1) % $yearly + 1; + } elsif ( $quarterly && $mon % 3 == 0 && $mday <= 7 ) { + $slot = $daily + $weekly + $monthly + ($q - 1) % $quarterly + 1; + } elsif ( $monthly && $mday <= 7 ) { + $slot = $daily + $weekly + ($m - 1) % $monthly + 1; + } elsif ( $weekly ) { + $slot = $daily + ($w - 1) % $weekly + 1; + } else { + $slot = ($d - 1) % $daily + 1; + } +} +exit 0 unless $slot; + +system("/usr/sbin/mtx -f $changer unload &> /dev/null"); +system("/usr/sbin/mtx -f $changer load $slot") && die("A problem occurred execing mtx\n");