#!/bin/sh # # Bacula interface to mtx autoloader # # Created JAN/23/02 by Ludwig Jaffe # # Works with the HP A4853 DLT Library # and the Storagetek Timberwolf 9730 DLT Library # #TAPEDRIVE0 holds the device/name of your 1st and only DLT drive (Bacula supports only 1 drive currently) # #Read TAPEDRIVE from command line parameters if [ -z "$4" ] ; then TAPEDRIVE0=/dev/st0 else TAPEDRIVE0=$4 fi #Delay in seconds the tape needs to load the tape. Needed to stop bacula from using the tape too early. TAPEDELAY=65 #The StorageTek Timberwolf 9730 with DLT7000 needs approx. 50 seconds to load. 65 sec gives safety MTXCHVERBOSE=1 if [ -z "$1" ] ; then echo "" echo "The mtx-changer script for bacula" echo "---------------------------------" echo "" echo "usage: mtx-changer [slot] [devicename of tapedrive]" echo " mtx-changer" echo "" echo "Valid commands:" echo "" echo "unload Unloads a tape into the slot" echo " from where it was loaded." echo "load Loads a tape from the slot " echo "list Lists full storage slots" echo "loaded Gives slot from where the tape was loaded." echo " 0 means the tape drive is empty." echo "slots Gives Number of aviable slots." echo "" echo "Example:" echo " mtx-changer /dev/changer load 1 loads a tape from slot1" echo "" exit fi case "$2" in unload) # At first do mt -f /dev/st0 offline to unload the tape because HP A4853 aka Timberwolf9730 # refuses to unload the tape from the drive if the DLT streamer did not unloaded it!!! # #Check if you want to fool me if [ $MTXCHVERBOSE -eq 1 ] ; then echo "mtx-changer: Checking if drive is loaded before we unload. I Request loaded" ; fi mtx -f $1 status >/tmp/mtx.$$ rm -f /tmp/mtxloaded cat /tmp/mtx.$$ | grep "^Data Transfer Element 0:Full" | awk "{print \$7}" > /tmp/mtxloaded rm -f /tmp/mtx.$$ read LOADEDVOL /tmp/mtx.$$ rm -f /tmp/mtxloaded cat /tmp/mtx.$$ | grep "^Data Transfer Element 0:Full" | awk "{print \$7}" > /tmp/mtxloaded rm -f /tmp/mtx.$$ read LOADEDVOL /tmp/mtx.$$ cat /tmp/mtx.$$ | grep "^Data Transfer Element 0:Full" | awk "{print \$7}" cat /tmp/mtx.$$ | grep "^Data Transfer Element 0:Empty" | awk "{print 0}" rm -f /tmp/mtx.$$ ;; slots) if [ $MTXCHVERBOSE -eq 1 ] ; then echo "mtx-changer: Request slots" ; fi mtx -f $1 status | grep "[ ]Storage Changer" | awk "{print \$5}" ;; esac