e-smith-backup/root/etc/e-smith/events/actions/eject-tape

23 lines
522 B
Plaintext
Raw Normal View History

#!/usr/bin/perl -w
package esmith;
use strict;
use esmith::ConfigDB;
my $event = shift;
my $cause = shift;
exit 0 if not defined $cause or $cause ne "tape";
my $confdb = esmith::ConfigDB->open_ro;
my $backup = $confdb->get('backup') or die "No backup db entry found\n";
my $device = $backup->prop('Device') || '/dev/st0';
my $eject = $backup->prop('Eject') || 'no';
exit 0 unless $device =~ /[sh]t/;
if (lc($eject) eq 'yes') {
exec("/bin/mt", "-f", $device, "eject");
die("A problem occurred execing mt");
}