]> git.sur5r.net Git - bacula/bacula/blob - bacula/scripts/mtx-changer.in
Move btraceback.gdb to scriptdir on install + hammer DB Version update
[bacula/bacula] / bacula / scripts / mtx-changer.in
1 #!/bin/sh
2 #
3 # Bacula interface to mtx autoloader
4 #
5 #  $Id$
6 #
7 #  If you set in your Device resource
8 #
9 #  Changer Command = "path-to-this-script/mtx-changer" %c %o %S %a
10 #    you will have the following input to this script:
11 #
12 #  mtx-changer "changer-device" "command" "slot" "archive-device"
13 #
14 #  for example:
15 #
16 #  mtx-changer /dev/sg0 load 1 /dev/nst0 (on a Linux system)
17 #
18 #  If you need to to an offline, refer to the drive as $4
19 #    e.g.   mt -f $f offline
20 #
21 #  Many changers need an offline after the unload. Also many
22 #   changers need a sleep 60 after the mtx load.
23 #
24 #  N.B. If you change the script, take care to return either 
25 #   the mtx exit code or a 0. If the script exits with a non-zero
26 #   exit code, Bacula will assume the request failed.
27 #
28
29 MTX=@MTX@
30
31 case "$2" in 
32    unload)
33 #     echo "Doing mtx -f $1 unload"
34 #
35 # enable the following line if you need to eject the cartridge
36 #     mt -f $4 offline
37       ${MTX} -f $1 unload
38       ;;
39
40    load)
41 #     echo "Doing mtx -f $1 load $3"
42       ${MTX} -f $1 load $3
43       rtn=$?
44 #
45 # Increase the sleep time if you have a slow device
46       sleep 15
47       exit $rtn
48       ;;
49
50    list) 
51 #     echo "Requested list"
52       ${MTX} -f $1 status | grep " *Storage Element [0-9]*:.*Full" | awk "{print \$3 \$4}" | sed "s/Full *\(:VolumeTag=\)*//"
53       ;;
54
55    loaded)
56 #     echo "Request loaded"
57       ${MTX} -f $1 status >/tmp/mtx.$$
58       rtn=$?
59       cat /tmp/mtx.$$ | grep "^Data Transfer Element 0:Full" | awk "{print \$7}"
60       cat /tmp/mtx.$$ | grep "^Data Transfer Element 0:Empty" | awk "{print 0}"
61       rm -f /tmp/mtx.$$
62       exit $rtn
63       ;;
64
65    slots)
66 #     echo "Request slots"
67       ${MTX} -f $1 status | grep " *Storage Changer" | awk "{print \$5}"
68       ;;
69 esac