diff options
-rw-r--r-- | debian/README.debian | 7 | ||||
-rw-r--r-- | debian/changelog | 45 | ||||
-rw-r--r-- | debian/control | 15 | ||||
-rw-r--r-- | debian/copyright | 28 | ||||
-rw-r--r-- | debian/dirs | 1 | ||||
-rw-r--r-- | debian/mtx.8 | 38 | ||||
-rwxr-xr-x | debian/rules | 55 | ||||
-rw-r--r-- | mtx-changer | 224 |
8 files changed, 413 insertions, 0 deletions
diff --git a/debian/README.debian b/debian/README.debian new file mode 100644 index 0000000..1dbfde8 --- /dev/null +++ b/debian/README.debian @@ -0,0 +1,7 @@ +mtx for DEBIAN +---------------------- + +This is the "missing glue" to allow use of a tape autochanger like the HP +Surestore 12000e on Linux with backup tools like Amanda. + +Bdale Garbee <bdale@gag.com>, Sun, 10 Aug 1997 03:05:18 -0600 diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..701a438 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,45 @@ +mtx (1.0-6) unstable; urgency=low + + * put mtx in group backup, setuid root, perms set so that only members of + group backup can run mtx. This makes mtx compatible with amanda. + + -- Bdale Garbee <bdale@gag.com> Tue, 27 Jan 1998 15:06:13 -0700 + +mtx (1.0-5) unstable; urgency=low + + * explicit include path to find <scsi/scsi_ioctl.h> in the + /usr/src/linux/include tree. closes bug 16877 + + -- Bdale Garbee <bdale@gag.com> Sun, 25 Jan 1998 23:02:46 -0700 + +mtx (1.0-4) unstable; urgency=low + + * actually install the mtx.doc file that's referenced in the man page /o\ + + -- Bdale Garbee <bdale@gag.com> Sun, 21 Sep 1997 02:38:50 -0600 + +mtx (1.0-3) unstable; urgency=low + + * libc6 + + -- Bdale Garbee <bdale@gag.com> Thu, 4 Sep 1997 02:56:39 -0600 + +mtx (1.0-2) unstable; urgency=low + + * Add an 'mtx-changer' wrapper script from the amanda-users mailing list + to make this more useful with Amanda. + * Hack mtx-changer to report 6 slots instead of 4, since I have an HP + SureStore 12000e. Should make it configurable, someday. + + -- Bdale Garbee <bdale@gag.com> Sun, 10 Aug 1997 03:50:42 -0600 + +mtx (1.0-1) unstable; urgency=low + + * Initial Release. + + -- Bdale Garbee <bdale@gag.com> Sun, 10 Aug 1997 03:05:18 -0600 + +Local variables: +mode: debian-changelog +add-log-mailing-address: "bdale@gag.com" +End: diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..50747ec --- /dev/null +++ b/debian/control @@ -0,0 +1,15 @@ +Source: mtx +Section: admin +Priority: extra +Maintainer: Bdale Garbee <bdale@gag.com> +Standards-Version: 2.1.2.2 + +Package: mtx +Architecture: any +Depends: ${shlibs:Depends} +Description: controls tape autochangers + MTX can be used to manipulate tape autochangers, also known as "jukeboxes", + such that backup software can make use of the multiple tape capabilities of + the autochanger. In particular, this is necessary glue for using a backup + system like Amanda with a DDS autochanger like the HP Surestore 12000e. + diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..138221e --- /dev/null +++ b/debian/copyright @@ -0,0 +1,28 @@ +This package was debianized by Bdale Garbee bdale@gag.com on +Sun, 10 Aug 1997 03:05:18 -0600. + +mtx was downloaded from http://www.dandelion.com/Linux/mtx-1.0.tar.gz + +Copyright: + + Copyright 1997 by Leonard N. Zubkoff <lnz@dandelion.com> + + This program is free software; you may redistribute and/or modify it under + the terms of the GNU General Public License Version 2 as published by the + Free Software Foundation. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for complete details. + + The author respectfully requests that any modifications to this software be + sent directly to him for evaluation and testing. + + Thanks to Philip A. Prindeville <philipp@enteka.com> of Enteka Enterprise + Technology Service for porting MTX to Solaris/SPARC. + + +The mtx-changer script was posted to the amanda-users mailing list by Zach +Beane, without copyright. + diff --git a/debian/dirs b/debian/dirs new file mode 100644 index 0000000..236670a --- /dev/null +++ b/debian/dirs @@ -0,0 +1 @@ +usr/sbin diff --git a/debian/mtx.8 b/debian/mtx.8 new file mode 100644 index 0000000..942006d --- /dev/null +++ b/debian/mtx.8 @@ -0,0 +1,38 @@ +.TH MTX 8 +.SH NAME +mtx \- control tape autochanger +mtx-changer \- wrapper for use with the Amanda backup system +.SH SYNOPSIS +.B mtx +.I "[ -f <tape-device> ] <command> [ <command args> ]" +.br +.B mtx-changer +.I "<command> [ <command args> ]" +.br +.SH "DESCRIPTION" +This manual page documents briefly the +.BR mtx +command. +This manual page was written for the Debian GNU/Linux distribution +(but may be used by others), because the original program did not +have a manual page. +.PP +.B mtx +is a program that controls the tape manipulator in a tape autochanger, +such as the HP SureStore 12000e. With +.B mtx, +it is possible to load and unload tapes, and perform other operations on the +autochanger. +.PP +The +.B mtx-changer +wrapper script implements the commands required by the Amanda backup system. +More information on Amanda is available from +http://ftp.cs.umd.edu/projects/amanda/amanda.html +.SH "SEE ALSO" +The program is documented fully by +.IR "mtx.doc" , +which can be found in the directory /usr/doc/mtx. +.SH AUTHOR +This manual page was written by Bdale Garbee <bdale@gag.com>, +for the Debian GNU/Linux system. diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..cfa89a8 --- /dev/null +++ b/debian/rules @@ -0,0 +1,55 @@ +#!/usr/bin/make -f +# Made with the aid of debmake, by Christoph Lameter, +# based on the sample debian/rules file for GNU hello by Ian Jackson. + +package=mtx + +build: + $(checkdir) + + cc -I/usr/src/linux/include -O2 -g -Wall -o mtx mtx.c + + touch build + +clean: + $(checkdir) + -rm -f build + -rm -f mtx.o mtx + -rm -f `find . -name "*~"` + -rm -rf debian/tmp debian/files* core debian/substvars + +binary-indep: checkroot build + $(checkdir) + +binary-arch: checkroot build + $(checkdir) + -rm -rf debian/tmp + install -d debian/tmp + cd debian/tmp && install -d `cat ../dirs` + install -o root -g backup -m 4750 mtx \ + debian/tmp/usr/sbin/mtx + install -o root -g backup -m 0750 mtx-changer \ + debian/tmp/usr/sbin/mtx-changer +# Must have debmake installed for this to work. Otherwise please copy +# /usr/bin/debstd into the debian directory and change debstd to debian/debstd + debstd mtx.doc + ln debian/tmp/usr/man/man8/mtx.8.gz \ + debian/tmp/usr/man/man8/mtx-changer.8.gz + dpkg-gencontrol + chown -R root.root debian/tmp + chmod -R go=rX debian/tmp + dpkg --build debian/tmp .. + +define checkdir + test -f debian/rules +endef + +# Below here is fairly generic really + +binary: binary-indep binary-arch + +checkroot: + $(checkdir) + test root = "`whoami`" + +.PHONY: binary binary-arch binary-indep clean checkroot diff --git a/mtx-changer b/mtx-changer new file mode 100644 index 0000000..4ca88ee --- /dev/null +++ b/mtx-changer @@ -0,0 +1,224 @@ +#!/usr/bin/perl + +$debug = 0; +&debug_init; + +$MTX = "/usr/sbin/mtx"; + +if(!$ENV{TAPE}){ + &debug("setting TAPE to /dev/tape"); + $ENV{TAPE} = "/dev/tape"; +} + +# initialize the state + +@slots = (1..6); +$current_slot = 0; +$tape_device = "/dev/tape"; + +&changer_init(); + +&debug("main::current slot: $current_slot"); + +if($ARGV[0] eq "-eject"){ + &debug("main::got eject request"); + # eject is a no-op right now... +} + +if($ARGV[0] eq "-info"){ + &debug("main::got info request"); + &print_info(); + exit(1); +} + +if($ARGV[0] eq "-reset"){ + &debug("main::got changer reset request"); + &reset_changer(); +} + +if($ARGV[0] =~ /-slot/){ + $slot = $ARGV[1]; + + if($slot =~ /^(next|prev|current|first|last)$/){ + &debug("main::got relative position request ($slot)"); + $slot = &get_slot_number($slot); + &debug("main::translated slot number: $slot"); + } + + if($slot !~ /^[0-9]$/){ + &fatal_error("bogus slot number: $slot"); + } + + &change_to_slot($slot); +} + +&print_status(); + + +##### subs ######################################## + +sub debug { + my $message = shift; + print DEBUG "$message\n" if $debug; +} + +sub changer_init { + &debug("changer_init::start"); + if(!(@response = `$MTX status`)){ + &fatal_error("couldn't run mtx: $!"); + } + + &debug("changer_init:: @response"); + + if($response[0] =~ /full .storage element ([1-6]) loaded/i){ + $current_slot = $1; + &debug("changer_init::tape loaded: $current_slot"); + return(); + } + + if($response[0] =~ /empty/i) { + &debug("changer_init::no tape loaded, checking for other tapes..."); + foreach $slot (@response) { + if($slot =~ /full/i) { + $tape_in_changer = 1; + break; + } + } + if(!$tape_in_changer) { + &debug("changer_init::no tapes in the changer"); + &fatal_error("no tapes in changer"); + } else { + &debug("changer_init::loading tape 1"); + &run_command("$MTX load 1"); + $current_slot = 1; + } + } +} + + + +sub print_status { + &debug("print_status::start"); + print "$current_slot $tape_device\n"; + exit(0); +} + + + +sub run_command { + my $command = shift; + + &debug("run_command:: $command"); + system("$command 2> /dev/null"); + if($? != 0) { + &fatal_error("[$command] returned non zero ($?)"); + } +} + + + +sub print_info { + print "$current_slot 6 1\n"; + exit(0); +} + + + +sub fatal_error { + my $error = shift; + + print "$current_slot $error\n"; + exit(2); +} + + + +sub reset_changer { + &debug("reset_changer:: start"); + &change_to_slot(1); +} + + + +sub change_to_slot { + my $slot = shift; + + &debug("change_to_slot:: $slot"); + if(!&in_range($slot)) { + &non_fatal_error("slot $slot out of range"); + } + + if($slot == $current_slot){ + return; + } else { + &run_command("$MTX unload"); + &run_command("$MTX load $slot"); + } + + $current_slot = $slot; +} + + + +sub get_slot_number { + my $description = shift; + + &debug("get_slot_number: $description"); + if($description eq "first"){ + return(1); + } + + if($description eq "last"){ + return(6); + } + + if($description eq "current"){ + return($current_slot); + } + + # we don't want to destroy $current_slot with post/preincrement + $slot_index = $current_slot; + + if($description eq "prev"){ + if(&in_range($current_slot)){ + return((6,1..6,1)[--$slot_index]); + } else { + &non_fatal_error("current slot number out of range: $current_slot"); + } + } + + if($description eq "next"){ + if(&in_range($current_slot)){ + return((6,1..6,1)[++$slot_index]); + } else { + &non_fatal_error("current slot number out of range: $current_slot"); + } + } + + return(0); +} + +sub in_range { + my $slot_num = shift; + + &debug("in_range:: $slot_num"); + return(($slot_num <= 6) && ($slot_num >= 1)); +} + +sub non_fatal_error { + my $message = shift; + + print "$current_slot $message\n"; + exit 1; +} + +sub debug_init { + return unless $debug; + open(DEBUG, ">/tmp/x-changer.debug.$$"); + $today = localtime(); + print DEBUG "Date: $today\n"; + print DEBUG "UID: $<\n"; + print DEBUG "EUID: $>\n"; + print DEBUG "PATH: $ENV{PATH}\n"; +} + |