1#!/bin/sh
2#
3# Cleanup left over files -- both before and after test run
4#
5# Write an EOF on tape in slot $SLOT1  and  on tape in $SLOT2
6
7. scripts/functions
8
9scripts/cleanup
10
11#
12# init first of two slots
13# optimize so we don't unnecessarily unload and load slots
14#
15if test x@autochanger@ != x/dev/null; then
16   slot=`$scripts/@changer_script@ @autochanger@ loaded 0 @tape_drive@ $DRIVE1`
17   case $slot in
18   0)
19      $scripts/@changer_script@ @autochanger@ load $SLOT1 @tape_drive@ $DRIVE1
20      slot=$SLOT1
21      ;;
22   $SLOT1)
23      slot=$SLOT1
24      ;;
25   $SLOT2)
26      slot=$SLOT2
27      ;;
28   *)
29      $scripts/@changer_script@ @autochanger@ unload $slot @tape_drive@ $DRIVE1
30      $scripts/@changer_script@ @autochanger@ load $SLOT1 @tape_drive@ $DRIVE1
31      slot=$SLOT1
32      ;;
33  esac
34  init_drive @tape_drive@
35  $scripts/@changer_script@ @autochanger@ unload $slot @tape_drive@ $DRIVE1
36
37
38# init the other slot
39  case $slot in
40   $SLOT1)
41      $scripts/@changer_script@ @autochanger@ load $SLOT2 @tape_drive@ $DRIVE1
42      ;;
43   $SLOT2)
44      $scripts/@changer_script@ @autochanger@ load $SLOT1 @tape_drive@ $DRIVE1
45      ;;
46   *)
47      echo "Something went wrong. Expected $SLOT1 or $SLOT2, got $slot"
48      exit 1
49   esac
50   init_drive @tape_drive@
51fi
52