try using --without-ipv6
[debian/amanda] / changer-src / chg-chio.pl.in
index bb9d5a07b4d653608f7aefac75102a7e4a4ac631..56bb35875f2b7a4d15fe0ad822235780abbbe331 100644 (file)
@@ -41,6 +41,9 @@ require 5.001;
 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@") {
@@ -68,11 +71,13 @@ if ( "@USE_VERSION_SUFFIXES@" eq "yes" ) {
 
 chomp ($tapeDevice = `$sbindir/amgetconf$SUF tapedev 2>&1`);
 die "tapedev not found in amanda.conf"
-       if !$tapeDevice or $tapeDevice =~ m/no such parameter/;
+       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 =~ m/no such parameter/;
+       if !$changerDevice or $changerDevice eq "" or
+           $changerDevice =~ m/no such parameter/;
 
 #
 # Initialise a few global variables
@@ -281,6 +286,16 @@ sub Load {
                print "$progname: cannot '@CHIO@ -f $changerDevice move' tape $tape into drive 0\n";
                exit(2);
        }
+
+       # wait for tape to load
+       $count = 1800;
+       while ( $count > 0 &&
+               system("$MT $MTF $tapeDevice status > /dev/null 2>&1" ) ) {
+               print LOG &do_time(), ": waiting for tape to load\n";
+               sleep 30;
+               $count -= 30;
+       }
+
        print LOG &do_time(), ": leave: Load\n";
 }
 
@@ -302,8 +317,8 @@ sub Unload {
        # firmware rev but for now it's safest to just explicitly eject
        # the tape before moving the cartridge.
        #
-       if ( system ("@MT@ @MT_FILE_FLAG@ $tapeDevice offline") ) {
-               print "$progname: Warning, failed to eject the tape with '@MT@ @MT_FILE_FLAG@ $tapeDevice offline'\n";
+       if ( system ("$MT $MTF $tapeDevice offline") ) {
+               print "$progname: Warning, failed to eject the tape with '$MT $MTF $tapeDevice offline'\n";
                # NB: not fatal; let chio try it's thing
        }
 
@@ -370,7 +385,7 @@ if (-x "$sbindir/ammt$SUF") {
        print "<none> mt program not found\n";
        exit(1);
 }
-print LOG &do_time(), "MT -> $MT $MTF\n";
+print LOG &do_time(), "MT -> $MT $MTF\n";
 
 system ("$MT $MTF $tapeDevice rewind")
        unless $currentTape == 0;