]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/scripts/mtx-changer.in
- Tweak install chapter of French manual to add new paragraph
[bacula/bacula] / bacula / scripts / mtx-changer.in
index 3e59e869079d46b7092d4f32fe410819c15d9ec9..37b7cc63706c4871d0fce183ff39a973c1da108e 100644 (file)
 
 MTX=@MTX@
 
+#
+# The purpose of this function to wait a maximum 
+#   time for the drive. It will
+#   return as soon as the drive is ready, or after
+#   waiting a maximum of 180 seconds.
+# Note, this is very system dependent, so if you are
+#   not running on Linux, you will probably need to
+#   re-write it.
+#
+# If you have a FreeBSD system, you might want to change
+#  the $(seq 180) to $(jot 180) -- tip from Brian McDonald
+#
+wait_for_drive() {
+  for i in $(seq 180); do   # Wait max 180 seconds
+    if mt -f $1 status >/dev/null 2>&1; then
+      break
+    fi
+#   echo "Device $1 - not ready, retrying..."
+    sleep 1
+  done
+}
+
+
 if test $# -lt 2 ; then
   echo "usage: mtx-changer ctl-device command slot archive-device drive"
   echo "  Insufficient number of arguments arguments given."
@@ -90,13 +113,21 @@ case $cmd in
       rtn=$?
 #
 # Increase the sleep time if you have a slow device
+# or remove the sleep and add the following:
+#     wait_for_drive $device
       sleep 15
       exit $rtn
       ;;
 
    list) 
 #     echo "Requested list"
-      ${MTX} -f $ctl status | grep " *Storage Element [0-9]*:.*Full" | awk "{print \$slot \$device}" | sed "s/Full *\(:VolumeTag=\)*//"
+      ${MTX} -f $ctl status | grep " *Storage Element [0-9]*:.*Full" | awk "{print \$3 \$4}" | sed "s/Full *\(:VolumeTag=\)*//"
+# Comment out the previous line and add a line here
+# to print "fake" barcodes.
+#
+# If you have a VXA PacketLoader and the above does not work, try
+#  turning it off and enabling the following line.
+#     ${MTX} -f $ctl status | grep " *Storage Element [0-9]*:.*Full" | sed "s/*Storage Element //" | sed "s/Full :VolumeTag=//"
       ;;
 
    loaded)
@@ -110,6 +141,6 @@ case $cmd in
 
    slots)
 #     echo "Request slots"
-      ${MTX} -f $ctl status | grep " *Storage Changer" | awk "{print \$drive}"
+      ${MTX} -f $ctl status | grep " *Storage Changer" | awk "{print \$5}"
       ;;
 esac