#!/bin/sh
#
-# Cleanup left over files -- both before and after test run
+# Cleanup left over files, then load $SLOT1 into drive and
+# write an EOF on it.
#
-rm -rf /tmp/TestVolume001 /tmp/bacula-restores /tmp/Small*
-rm -rf tmp/original tmp/bacula-restores tmp/Small* tmp/TestVolume*
-rm -rf tmp/restored tmp/largefile tmp/bscan.bsr tmp/log*.out
-#
-# If we have an autochanger always load tape in slot 1
-#
-if ! test x@autochanger@ = x/dev/null; then
- drive=`bin/mtx-changer @autochanger@ loaded`
- if ! test x$drive = x1; then
- bin/mtx-changer @autochanger@ unload
- bin/mtx-changer @autochanger@ load 1
- fi
+. scripts/functions
+
+scripts/cleanup
+
+# init slot for vtape driver
+init_slot @tape_drive@ $SLOT1
+
+if test x@autochanger@ != x/dev/null; then
+ slot=`$scripts/@changer_script@ @autochanger@ loaded 0 @tape_drive@ $DRIVE1`
+ case $slot in
+ 0)
+ $scripts/@changer_script@ @autochanger@ load $SLOT1 @tape_drive@ $DRIVE1
+ ;;
+ $SLOT1)
+ ;;
+ *)
+ $scripts/@changer_script@ @autochanger@ unload $slot @tape_drive@ $DRIVE1
+ $scripts/@changer_script@ @autochanger@ load $SLOT1 @tape_drive@ $DRIVE1
+ ;;
+ esac
fi
-mt -f @tape_drive@ rewind
-mt -f @tape_drive@ weof
+init_drive @tape_drive@