]> git.sur5r.net Git - bacula/bacula/blob - bacula/examples/autochangers/mtx-changer.Sony-TSL-SA300C
Fix scripts/bacula.in to have awk on an environment variable
[bacula/bacula] / bacula / examples / autochangers / mtx-changer.Sony-TSL-SA300C
1 #!/bin/sh
2 #
3 # Bacula interface to mtx autoloader
4 #
5 #  This mtx-changer script was contributed by Fryderyk Wlostowski.
6 #    It works with a Sony TLS-11000 changer, which needs
7 #     the slot number to do an unload
8 #
9 #  mtx-changer "changer-device" "command" "slot"
10 #
11 #
12 MTX=/opt/mtx1.2.17/sbin/mtx
13 case "$2" in 
14    unload)
15 #     echo "Doing mtx -f $1 $2"
16       NR_KASETY=`$MTX -f $1 status | grep "Empty" | tr " "  "~" | tr ":"  "~" | cut -d "~" -f 9`
17       $MTX -f $1 $2 $NR_KASETY
18       ;;
19
20    load)
21 #     echo "Doing mtx -f $1 $2 $3"
22       $MTX -f $1 $2 $3
23       ;;
24
25    list) 
26 #     echo "Requested list"
27       $MTX -f $1 status | grep "^[     ]*Storage Element [0-9]*:.*Full" | awk "{print \$3}" | sed "s/:.*$/ /g" | tr -d "[\r\n]"
28       ;;
29
30    loaded)
31 #     echo "Request loaded"
32       $MTX -f $1 status | grep "Empty" | tr " " "~" | tr ":" "~" | cut -d "~" -f 9
33       echo 0
34       ;;
35
36    slots)
37 #     echo "Request slots"
38       $MTX -f $1 status | grep "[  ]Storage Changer" | awk "{print \$5}"
39       ;;
40 esac