#! @PERL@ -w # Catch for sh/csh on systems without #! ability. eval '(exit $?0)' && eval 'exec @PERL@ -S $0 ${1+"$@"}' & eval 'exec @PERL@ -S $0 $argv:q' if 0; # # This changer script is designed for IOMEGA or JAZZ disks of various sizes # as well as any other removable disk media. # # This is a PURELY MANUAL changer. It requests insertion of disk media via # messages on /dev/tty. So it cannot be used via crontab. # # Make sure you comply with any of the following. # - Add statements # tpchanger "chg-iomega" # tapedev "file:" # # (e.g. tapedev "file:/mnt/iomega" ) # tapetype IOMEGA # # # define tapetype IOMEGA { # comment "IOMega 250 MB floppys" # length 250 mbytes # filemark 100 kbytes # speed 1 mbytes # } # to your /etc/amanda//amanda.conf file # - Add entry to /etc/fstab to specify mount point of removable disk # and make this disk mountable by any user. # - Format all disks, add a "data" sub directory and label all disks # by a call to amlabel. # - Be aware that as of version 2.4.4p1, amanda can't handle backups that are # larger than the size of the removable disk media. So make sure # /etc/amanda//disklist specifies chunks smaller than the # disk size. # # This script is built up out of bits and pieces of other scripts, in # particular chg-chio.pl. That script was written by # Nick Hibma - nick.hibma@jrc.it # # Permission to freely use and distribute is granted (by me and was granted by # the original authors). # # Christoph Pospiech # require 5.001; ($progname = $0) =~ s#/.*/##; use English; use Getopt::Long; delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV', 'PATH'}; $ENV{'PATH'} = "/usr/bin:/usr/sbin:/sbin:/bin"; $| = 1; if (-d "@AMANDA_DBGDIR@") { $logfile = "@AMANDA_DBGDIR@/changer.debug"; } else { $logfile = "/dev/null"; } die "$progname: cannot open $logfile: $ERRNO\n" unless (open (LOG, ">> $logfile")); # # get the information from the configuration file # $prefix="@prefix@"; $prefix=$prefix; # avoid warnings about possible typo $exec_prefix="@exec_prefix@"; $exec_prefix=$exec_prefix; # Ditto $sbindir="@sbindir@"; if ( "@USE_VERSION_SUFFIXES@" eq "yes" ) { $SUF = "-@VERSION@"; } else { $SUF = ""; } chomp ($tapeDevice = `$sbindir/amgetconf$SUF tapedev 2>&1`); die "tapedev not found in amanda.conf" if !$tapeDevice or $tapeDevice eq "" or $tapeDevice =~ m/no such parameter/; chomp ($changerDevice = `$sbindir/amgetconf$SUF changerdev 2>&1`); chomp $changerDevice; die "changerdev not found in amanda.conf" if !$changerDevice or $changerDevice eq "" or $changerDevice =~ m/no such parameter/; # # Initialise a few global variables # $current_label = ""; #$current_slot = 0; $max_slot = 1; @dow = ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"); @moy = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); sub do_time { my (@t); my ($r); ### # Get the local time for the value. ### @t = localtime (time ()); ### # Return the result. ### $r = sprintf "%s %s %2d %2d:%02d:%02d %4d", $dow[$t[6]], $moy[$t[4]], $t[3], $t[2], $t[1], $t[0], 1900 + $t[5]; return $r; } sub is_mounted { my $device = shift @_; my ($directory) = ($device =~ m/file\:(.*)$/); if ( -d "$directory/data" ) { return 1;} else {return 0;} } sub request { my $label = shift @_; my $answer; open (TTY, "+= 5) { print LOG &do_time(), ": disk not found\n"; print "disk not found\n"; exit 1; } else { print LOG &do_time(), ": 1 $tapeDevice\n"; print "1 $tapeDevice\n"; exit 0; } } if ( $opt_label ) { print LOG &do_time(), ": label $opt_label requested\n"; # no operation print LOG &do_time(), ": 1 $tapeDevice\n"; print "1 $tapeDevice\n"; exit 0; } print "$progname: No command was received. Exiting.\n"; exit 1;