]> git.sur5r.net Git - bacula/bacula/blobdiff - regress/scripts/prepare-two-tapes.in
Add missing copy-plugin-confs for regress
[bacula/bacula] / regress / scripts / prepare-two-tapes.in
index 1da184650929e832e42940a065dc4d95e83b0b44..c91864a7d891e13f0ea4c5a6276a2420ed71ca0c 100755 (executable)
@@ -1,37 +1,61 @@
 #!/bin/sh
+#
+# Copyright (C) 2000-2015 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+
 #
 # Cleanup left over files -- both before and after test run
 #
+# Write an EOF on tape in slot $SLOT1  and  on tape in $SLOT2
 
 . scripts/functions
 
 scripts/cleanup
 
-if test x@autochanger@ != x/dev/null; then
-   slot=`bin/mtx-changer @autochanger@ loaded 0 dummy $DRIVE1`
-   if test "x${slot}" != "x$SLOT2"; then
-      bin/mtx-changer @autochanger@ unload $slot @tape_drive@ $DRIVE1
-      bin/mtx-changer @autochanger@ load $SLOT2 @tape_drive@ $DRIVE1
-   fi
-   mt -f @tape_drive@ rewind
-   mt -f @tape_drive@ weof
-fi
 
+# with disk-changer, we have to initialize slots
+init_slot @tape_drive@ $SLOT1
+init_slot @tape_drive@ $SLOT2
 
 #
-# If we have an autochanger always load tape in slot 1
+# init first of two slots
+# optimize so we don't unnecessarily unload and load slots
 #
 if test x@autochanger@ != x/dev/null; then
-   slot=`bin/mtx-changer @autochanger@ loaded 0 dummy $DRIVE1`
-   if test "x${slot}" != "x$SLOT1"; then
-      bin/mtx-changer @autochanger@ unload $slot @tape_drive@ $DRIVE1
-      bin/mtx-changer @autochanger@ load $SLOT1 @tape_drive@ $DRIVE1
-   fi
-fi
+   slot=`$scripts/@changer_script@ @autochanger@ loaded 0 @tape_drive@ $DRIVE1`
+   case $slot in
+   0)
+      $scripts/@changer_script@ @autochanger@ load $SLOT1 @tape_drive@ $DRIVE1
+      slot=$SLOT1
+      ;;
+   $SLOT1)
+      slot=$SLOT1
+      ;;
+   $SLOT2)
+      slot=$SLOT2
+      ;;
+   *)
+      $scripts/@changer_script@ @autochanger@ unload $slot @tape_drive@ $DRIVE1
+      $scripts/@changer_script@ @autochanger@ load $SLOT1 @tape_drive@ $DRIVE1
+      slot=$SLOT1
+      ;;
+  esac
+  init_drive @tape_drive@
+  $scripts/@changer_script@ @autochanger@ unload $slot @tape_drive@ $DRIVE1
+
 
-if test a$USE_FAKETAPE = a; then
-   mt -f @tape_drive@ rewind
-   mt -f @tape_drive@ weof
-else
-   cp /dev/null @tape_drive@
+# init the other slot
+  case $slot in
+   $SLOT1)
+      $scripts/@changer_script@ @autochanger@ load $SLOT2 @tape_drive@ $DRIVE1
+      ;;
+   $SLOT2)
+      $scripts/@changer_script@ @autochanger@ load $SLOT1 @tape_drive@ $DRIVE1
+      ;;
+   *)
+      echo "Something went wrong. Expected $SLOT1 or $SLOT2, got $slot"
+      exit 1
+   esac
+   init_drive @tape_drive@
 fi