]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/scripts/mtx-changer.in
Check for existence of mtx-changer.conf in mtx-changer script
[bacula/bacula] / bacula / scripts / mtx-changer.in
index a40e13769cf845cd3dd5be6a2601df9a9e74562f..3f5aadd624543354d7187449e5f5ec7751f61795 100644 (file)
@@ -2,8 +2,6 @@
 #
 # Bacula interface to mtx autoloader
 #
-#  $Id$
-#
 #  If you set in your Device resource
 #
 #  Changer Command = "path-to-this-script/mtx-changer %c %o %S %a %d"
@@ -30,6 +28,8 @@
 #      loaded            which slot is loaded?
 #      list              list Volume names (requires barcode reader)
 #      slots             how many slots total?
+#      listall           list all info
+#      transfer
 #
 #  Slots are numbered from 1 ...
 #  Drives are numbered from 0 ...
 #
 
 # source our conf file
+if test ! -f @scriptdir@/mtx-changer.conf ; then
+  echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
+  echo "ERROR: @scriptdir@/mtx-changer.conf file not found!!!!"
+  echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
+  exit 1
+fi
 . @scriptdir@/mtx-changer.conf
 
 MTX=@MTX@
@@ -120,12 +126,15 @@ check_parm_count() {
 #  all others are a minimum of 5
 #
 case $2 in
-    list)
+    list|listall)
        check_parm_count $# 2
        ;;
     slots)
        check_parm_count $# 2
        ;;
+    transfer)
+       check_parm_count $# 4
+       ;;
     *)
        check_parm_count $# 5
        ;;
@@ -183,6 +192,49 @@ case $cmd in
       exit $rtn
       ;;
 
+   listall)
+#  Drive content:        D:Drive num:F:Slot loaded:Volume Name
+#  D:0:F:2:vol2        or D:Drive num:E
+#  D:1:F:42:vol42   
+#  D:3:E
+# 
+#  Slot content:
+#  S:1:F:vol1            S:Slot num:F:Volume Name
+#  S:2:E              or S:Slot num:E
+#  S:3:F:vol4
+# 
+#  Import/Export tray slots:
+#  I:10:F:vol10          I:Slot num:F:Volume Name
+#  I:11:E             or I:Slot num:E
+#  I:12:F:vol40
+      debug "Doing mtx -f $ctl -- to list all"
+      make_temp_file
+      if test ${inventory} -ne 0 ; then
+       ${MTX} -f $ctl inventory
+      fi
+      ${MTX} -f $ctl status >${TMPFILE}
+      rtn=$?
+      # can be converted to awk+sed+cut, contributions are welcome
+      perl -ne '
+/Data Transfer Element (\d+):Empty/ && print "D:$1:E\n";
+/Data Transfer Element (\d+):Full \(Storage Element (\d+) Loaded\)(:VolumeTag =\s*(.+))?/ && print "D:$1:F:$2:$4\n";
+/Storage Element (\d+):Empty/ && print "S:$1:E\n";
+/Storage Element (\d+):Full( :VolumeTag=(.+))?/ && print "S:$1:F:$3\n";
+/Storage Element (\d+) IMPORT.EXPORT:Empty/ && print "I:$1:E\n";
+/Storage Element (\d+) IMPORT.EXPORT:Full( :VolumeTag=(.+))?/ && print "I:$1:F:$3\n";' ${TMPFILE}
+      rm -f ${TMPFILE} >/dev/null 2>&1
+      exit $rtn
+      ;;
+
+   transfer)
+      slotdest=$device
+      debug "Doing transfer from $slot to $slotdest"
+      ${MTX} -f $ctl transfer $slot $slotdest
+      rtn=$?
+      exit $rtn
+      ;;
+
    loaded)
       debug "Doing mtx -f $ctl $drive -- to find what is loaded"
       make_temp_file