]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/scripts/mtx-changer.in
Implement SD code to check length of disk volume before appending
[bacula/bacula] / bacula / scripts / mtx-changer.in
index 152bda5979b387e53ba8799cfcba5daa4ad9fe1c..82e85f970801824f066cd9e35542be36d1f8d959 100644 (file)
 
 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=\)*//"