X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fscripts%2Fmtx-changer.in;h=82e85f970801824f066cd9e35542be36d1f8d959;hb=8447702aeae6988598fdff0ab22ee0ee81c8727a;hp=152bda5979b387e53ba8799cfcba5daa4ad9fe1c;hpb=2d6309754e7a3ef719e8e950d5677f29ff53d1e5;p=bacula%2Fbacula diff --git a/bacula/scripts/mtx-changer.in b/bacula/scripts/mtx-changer.in index 152bda5979..82e85f9708 100644 --- a/bacula/scripts/mtx-changer.in +++ b/bacula/scripts/mtx-changer.in @@ -36,6 +36,24 @@ MTX=@MTX@ +# mt status output +# SunOS No Additional Sense +# FreeBSD Current Driver State: at rest. +# Linux ONLINE + +OS=`uname` +case ${OS} in + SunOS) + ready="No Additional Sense" + ;; + FreeBSD) + ready="Current Driver State: at rest." + ;; + *) + ready="ONLINE" + ;; +esac + # # log whats done # @@ -54,7 +72,7 @@ debug() { # Create a temporary file # make_temp_file() { - TMPFILE=`mktemp -t mtx.XXXXXXXXXX` + TMPFILE=`mktemp @working_dir@/mtx.XXXXXXXXXX` if test x${TMPFILE} = x; then TMPFILE="@working_dir@/mtx.$$" if test -f ${TMPFILE}; then @@ -72,11 +90,13 @@ make_temp_file() { # Note, this is very system dependent, so if you are # not running on Linux, you will probably need to # re-write it, or at least change the grep target. +# We've attempted to get the appropriate OS grep targets +# in the code at the top of this script. # wait_for_drive() { i=0 while [ $i -le 300 ]; do # Wait max 300 seconds - if mt -f $1 status | grep ONLINE >/dev/null 2>&1; then + if mt -f $1 status | grep ${ready} >/dev/null 2>&1; then break fi debug "Device $1 - not ready, retrying..." @@ -153,7 +173,7 @@ case $cmd in debug "Doing mtx -f $ctl -- to list volumes" make_temp_file # Enable the following if you are using barcodes and need an inventory -# $(MTX) -f $ctl inventory +# ${MTX} -f $ctl inventory ${MTX} -f $ctl status >${TMPFILE} rtn=$? cat ${TMPFILE} | grep " *Storage Element [0-9]*:.*Full" | awk "{print \$3 \$4}" | sed "s/Full *\(:VolumeTag=\)*//"