]> git.sur5r.net Git - bacula/bacula/blob - regress/scripts/prepare-two-tapes.in
Update two-tape-prepare for Debian
[bacula/bacula] / regress / scripts / prepare-two-tapes.in
1 #!/bin/sh
2 #
3 # Create two blank tapes
4 #
5
6 # mt status output
7 # SunOS     No Additional Sense
8 # FreeBSD   Current Driver State: at rest.
9 # Linux     ONLINE
10 #  Note Debian has messed up their mt. When no tape is in the
11 #    drive it waits 2 minutes.  When a tape is in the drive, it
12 #    prints user unfriendly output.
13 #
14
15 OS=`uname`
16 case ${OS} in
17   SunOS)
18     ready="No Additional Sense"
19     ;;
20   FreeBSD)
21     ready="Current Driver State: at rest."
22     ;;
23   Linux)
24     if test -e /etc/debian_version ; then
25        ready="drive status"
26     else
27        ready="ONLINE"
28     fi
29   ;;
30 esac
31
32 wait_for_drive() {
33   i=0 
34   while [ $i -le 300 ]; do  # Wait max 300 seconds
35     if mt -f $1 status 2>&1 | grep "${ready}" >/dev/null 2>&1; then
36       break
37     fi
38 #   debug "Device $1 - not ready, retrying..."
39     sleep 1
40     i=`expr $i + 1`
41   done
42 }
43
44 #
45 # mt -f @tape_drive@ offline
46 @changer_path@ -f @autochanger@ unload
47 @changer_path@ -f @autochanger@ load 1
48 wait_for_drive @tape_drive@
49 mt -f @tape_drive@ rewind
50 mt -f @tape_drive@ weof
51 @changer_path@ -f @autochanger@ unload
52 @changer_path@ -f @autochanger@ load 2
53 wait_for_drive @tape_drive@
54 mt -f @tape_drive@ rewind
55 mt -f @tape_drive@ weof
56 #@changer_path@ -f @autochanger@ unload