1 ################################################################################
2 # You may want to customize these values
3 ################################################################################
5 # These are the defaults discovered by configure when Amanda was installed.
6 # They can be overridden here, or by by 'mt_binary' and 'mtx_binary',
7 # respectively, in the changerfile (currently only for chg-zd-mtx.sh and
13 # This is the flag used to specify a device filename to 'mt', usually '-f'
16 ################################################################################
17 # No user-level customization should be required beyond this point.
18 ################################################################################
21 exec_prefix="@exec_prefix@"
23 libexecdir="@libexecdir@"
24 amlibexecdir="@amlibexecdir@"
25 . "${amlibexecdir}/amanda-sh-lib.sh"
28 # Eponymous functions to access various amanda apps
29 # TODO: move to amanda-sh-lib.sh
31 if test "@USE_VERSION_SUFFIXES@" = "yes"; then
33 "${sbindir}/amgetconf-@VERSION@" "${@}"
36 "${sbindir}/amdevcheck-@VERSION@" "${@}"
40 "${sbindir}/amgetconf" "${@}"
43 "${sbindir}/amdevcheck" "${@}"
47 # This function tries to find a useable mt binary. If a fully-qualified path
48 # was provided at configure time or via a config file, we check that it
49 # exists and is executable. If an incomplete path was specified (e.g., "mt"),
50 # we ask the shell to search the path. Returns 0 on success, 1 on failure.
54 if test -n $mt_found; then
62 if "`echo $MT | dd bs=1 count=1`" = "/"; then
63 if ! test -f "${MT}"; then
64 echo `_ "mt binary at '%s' not found" "$MTX"`
67 if ! test -x "${MT}"; then
68 echo `_ "mt binary at '%s' is not executable" "$MTX"`
72 # try running it to see if the shell can find it
73 "$MT" >/dev/null 2>/dev/null
74 if test $? -eq 127 -o $? -eq 126; then
75 echo `_ "Could not run mt binary at '%s'" "$MTX"`
84 # This function strips the tape: from the front of device names.
85 # Capture its output with ``.
86 tape_device_filename() {
87 # Easy (?) to express this in Perl.
88 perl -e '$ARGV[0] =~ /^(?:([^:]+):)?(.*)$/;
89 print $2 if ($1 || "tape") eq "tape"' "$1"
92 # Runs amdevcheck to find out if a particular device is usable. Finds the
93 # config name based on pwd, so run it from the config directory. The sole
94 # argument should be the device name to check. Note that amdevcheck can FP
95 # on device status, since some devices can't differentiate between device
96 # problems and an unlabeled volume.
98 amdevcheck_config_dir=`pwd`
99 amdevcheck_config_name=`basename $amdevcheck_config_dir`
100 amdevcheck_output=`amdevcheck $amdevcheck_config_name $@`
102 if test $? -eq 0 || \
103 echo $amdevcheck_output | grep UNLABELED > /dev/null; then
110 # This attempts to eject a device using whatever system tools are available.
111 # At the moment, that means mt for tapes, and nothing otherwise, but might
112 # be extended at some later time.
115 if echo "$1" | grep -e '^tape:' > /dev/null; then
116 try_eject_device_tape="`echo \"$1\" | cut -b6-`"
117 elif echo "$1" | grep -v : > /dev/null; then
118 try_eject_device_tape="$1"
120 try_eject_device_tape=
123 if test -n "$try_eject_device_tape"; then
125 $MT $MTF "$try_eject_device_tape" eject
128 # Technically we failed to eject the device, but we presume that's
129 # because it doesn't require ejection.