-#!/bin/sh
+#!@SHELL@
#
# Exit Status:
# 0 Alles Ok
# Storage Element 7:Full :VolumeTag=SR0007
# Storage Element 8:Full :VolumeTag=SR0008
# Storage Element 9:Full :VolumeTag=SR0009
+# Storage Element 10 IMPORT/EXPORT:Full :VolumeTag=SR0009
#
# This says the first storage slot (element) is "1" and the last
# is "9". If you allocate the entire robot to Amanda, you do not need
# in amanda.conf. For example, if amanda.conf has:
#
# changerfile="/etc/amanda/Dailyset1/CHANGER"
+# or changerfile="/etc/amanda/Dailyset1/CHANGER.conf"
#
# the variables must be in "/etc/amanda/Dailyset1/CHANGER.conf".
+# The ".conf" is appended only if it's not there".
#
# If "changerfile" is a relative path, it is relative to the directory
# that contains amanda.conf. That also happens to be the directory Amanda
#
# initial_poll_delay=NN #### initial delay after load before polling for
# #### readiness
+#
####
####
# env DEBUG=yes .../chg-zd-mtx ...
################################################################################
-################################################################################
-# You may need to customize these things
-################################################################################
-
-MT=@MT@
-MTF=@MT_FILE_FLAG@
-MTX=@MTX@
-
-################################################################################
-# No user-level customization should be required beyond this point.
-################################################################################
+# source utility functions and values from configure
+exec_prefix=@exec_prefix@
+libexecdir=@libexecdir@
+. ${libexecdir}/chg-lib.sh
test -n "$DEBUG" && set -x
TMPDIR="@AMANDA_TMPDIR@"
exit_slot=$1
shift
exit_answer="$@"
- Log $call_type "($code)" "->" "$exit_slot" "$@"
+ Log $call_type "($code) -> $exit_slot $@"
echo "$exit_slot" "$@"
if [ $call_type = Return ]; then
return $code
###
Run() {
- Log Running: "$@"
+ Log `_ 'Running: %s' "$@"`
rm -f $stdout $stderr
"$@" > $stdout 2> $stderr
exitcode=$?
- Log Exit code: $exitcode
+ Log `_ 'Exit code: %s' "$exitcode"`
if [ -s $stdout ]
then
LogAppend Stdout:
get_mtx_status
set x `sed -n '
-/^Data Transfer Element:Empty/ {
+/^Data Transfer Element:Empty/ {
s/.*/-1/p
q
}
-/^Data Transfer Element '$driveslot':Empty/ {
+/^Data Transfer Element '$driveslot':Empty/ {
s/.*/-1/p
q
}
-/^Data Transfer Element:Full.*:VolumeTag/ {
- s/.*(Storage Element \([0-9][0-9]*\) Loaded):VolumeTag *= *\([^ ]*\)/\1 \2/p
+/^Data Transfer Element:Full (Storage Element \([0-9][0-9]*\) Loaded):VolumeTag *= *\([^ ]*\)/ {
+ s/.*(Storage Element \([0-9][0-9]*\) Loaded):VolumeTag *= *\([^ ]*\)/\1 \2/p
+ q
+}
+/^Data Transfer Element '$driveslot':Full (Storage Element \([0-9][0-9]*\) Loaded):VolumeTag *= *\([^ ]*\)/ {
+ s/.*(Storage Element \([0-9][0-9]*\) Loaded):VolumeTag *= *\([^ ]*\)/\1 \2/p
+ q
+}
+/^Data Transfer Element '$driveslot':Full (Unknown Storage Element Loaded):VolumeTag *= *\([^ ]*\)/ {
+ s/.*:VolumeTag *= *\([^ ]*\)/-2 \1/p
q
}
-/^Data Transfer Element '$driveslot':Full.*:VolumeTag/ {
- s/.*(Storage Element \([0-9][0-9]*\) Loaded):VolumeTag *= *\([^ ]*\)/\1 \2/p
+/^Data Transfer Element:Full (Storage Element \([0-9][0-9]*\) Loaded)/ {
+ s/.*(Storage Element \([0-9][0-9]*\) Loaded).*/\1/p
q
}
-/^Data Transfer Element:Full/ {
- s/.*(Storage Element \([0-9][0-9]*\) Loaded)\(.*\)/\1/p
+/^Data Transfer Element '$driveslot':Full (Storage Element \([0-9][0-9]*\) Loaded)/ {
+ s/.*Storage Element \([0-9][0-9]*\) Loaded.*/\1/p
q
}
-/^Data Transfer Element '$driveslot':Full/ {
- s/.*(Storage Element \([0-9][0-9]*\) Loaded)\(.*\)/\1/p
+/^Data Transfer Element '$driveslot':Full (Unknown Storage Element Loaded)/ {
+ s/.*/-2/p
q
}
' < $mtx_status 2>&1`
shift # get rid of the "x"
loadedslot=$1
loadedbarcode=$2
-
if [ -z "$loadedslot" ]; then
- Exit 2 "<none>" "could not determine current slot, are you sure your drive slot is $driveslot"
+ Exit 2 \
+ `_ '<none>'` \
+ "could not determine current slot, are you sure your drive slot is $driveslot"
return $? # in case we are internal
fi
+
+ #Use the current slot if it's empty and we don't know which slot is loaded'
+ if [ $loadedslot -eq -2 ]; then
+ set x `sed -n '
+{
+ /^.*Storage Element '$currentslot':Empty/ {
+ s/.*Storage Element \([0-9][0-9]*\):Empty/\1/p
+ q
+ }
+ /^.*Storage Element '$currentslot':Full/ {
+ s/.*Storage Element \([0-9][0-9]*\):Full/-2/p
+ q
+ }
+ /^.*Storage Element '$currentslot' IMPORT\/EXPORT:Empty/ {
+ s/.*Storage Element \([0-9][0-9]*\) IMPORT\/EXPORT:Empty/\1/p
+ q
+ }
+ /^.*Storage Element '$currentslot' IMPORT\/EXPORT:Full/ {
+ s/.*Storage Element \([0-9][0-9]*\) IMPORT\/EXPORT:Full/-2/p
+ q
+ }
+}
+' < $mtx_status 2>& 1`
+ shift # get rid of the "x"
+ loadedslotx=$1
+ if [ ! -z $loadedslotx ]; then
+ loadedslot=$loadedslotx
+ fi
+ fi
+
+ #Use the first empty slot if we don't know which slot is loaded'
+ if [ $loadedslot -eq -2 ]; then
+ set x `sed -n '
+{
+ /^.*Storage Element \([0-9][0-9]*\):Empty/ {
+ s/.*Storage Element \([0-9][0-9]*\):Empty/\1/p
+ q
+ }
+ /^.*Storage Element \([0-9][0-9]*\) IMPORT\/EXPORT:Empty/ {
+ s/.*Storage Element \([0-9][0-9]*\) IMPORT\/EXPORT:Empty/\1/p
+ q
+ }
+}
+' < $mtx_status 2>& 1`
+ shift # get rid of the "x"
+ loadedslot=$1
+ fi
+
if IsNumeric "$loadedslot" ; then
:
else
Exit 2 \
- "<none>" \
+ `_ '<none>'` \
"currently loaded slot ($loadedslot) not numeric"
return $? # in case we are internal
fi
- Log "STATUS -> currently loaded slot = $loadedslot"
- LogAppend " -> currently loaded barcode = \"$loadedbarcode\""
+ Log `_ 'STATUS -> currently loaded slot = %s' "$loadedslot"`
+ LogAppend `_ ' -> currently loaded barcode = "%s"' "$loadedbarcode"`
}
###
fi
get_mtx_status
slot_list=`sed -n '
-/^Data Transfer Element:Full/ {
- s/.*(Storage Element \([0-9][0-9]*\) Loaded)\(.*\)/\1/p
+/^Data Transfer Element:Full (Storage Element \([0-9][0-9]*\) Loaded)/ {
+ s/.*(Storage Element \([0-9][0-9]*\) Loaded).*/\1/p
+}
+/^Data Transfer Element '$driveslot':Full (Storage Element \([0-9][0-9]*\) Loaded)/ {
+ s/.*Storage Element \([0-9][0-9]*\) Loaded.*/\1/p
+}
+/^Data Transfer Element '$driveslot':Full (Unknown Storage Element Loaded)/ {
+ : loop
+ n
+ /^.*Storage Element \([0-9][0-9]*\):Full/ {
+ s/.*Storage Element \([0-9][0-9]*\):Full.*/\1/p
+ b loop
+ }
+ /^.*Storage Element \([0-9][0-9]*\):Empty/ {
+ s/.*Storage Element \([0-9][0-9]*\):Empty/\1/p
+ }
}
-/^Data Transfer Element '$driveslot':Full/ {
- s/.*(Storage Element \([0-9][0-9]*\) Loaded)\(.*\)/\1/p
+/^.*Storage Element \([0-9][0-9]*\):Full/ {
+ s/.*Storage Element \([0-9][0-9]*\):Full.*/\1/p
}
-/^[ ]*Storage Element \([0-9][0-9]*\):Full/ {
- s/.*Storage Element \([0-9][0-9]*\):.*/\1/p
+/^.*Storage Element \([0-9][0-9]*\) IMPORT\/EXPORT:Full/ {
+ s/.*Storage Element \([0-9][0-9]*\) IMPORT\/EXPORT:Full.*/\1/p
}
' < $mtx_status 2>&1 | grep -v "^${cleanslot}\$" | sort -n`
slot_list=`echo $slot_list` # remove the newlines
last=$lastslot
for slot in $slot_list; do
if [ $firstslot -lt 0 ]; then
- Log "SLOTLIST -> firstslot set to $slot"
+ Log `_ 'SLOTLIST -> firstslot set to %s' "$slot"`
firstslot=$slot
fi
if [ $lastslot -lt 0 ]; then
fi
done
if [ $lastslot -lt 0 -a $last -ge 0 ]; then
- Log "SLOTLIST -> lastslot set to $last"
+ Log `_ 'SLOTLIST -> lastslot set to %s' "$last"`
lastslot=$last
fi
if [ $firstslot -lt 0 ]; then
Exit 2 \
- "<none>" \
- "cannot determine first slot"
+ `_ '<none>'` \
+ `_ 'cannot determine first slot'`
return $? # in case we are internal
elif [ $lastslot -lt 0 ]; then
Exit 2 \
- "<none>" \
- "cannot determine last slot"
+ `_ '<none>'` \
+ `_ 'cannot determine last slot'`
return $? # in case we are internal
fi
fi
done
if [ -z "$amanda_slot_list" ]; then
Exit 2 \
- "<none>" \
+ `_ '<none>'` \
"no slots available"
return $? # in case we are internal
fi
SUF=
fi
-DBGFILE=`amgetconf$SUF dbopen.$argv0 2>/dev/null | grep -v BUGGY`
+DBGFILE=`amgetconf$SUF dbopen.$argv0 2>/dev/null`
if [ -z "$DBGFILE" ]
then
DBGFILE=/dev/null # will try this again below
fi
-changerfile=`amgetconf$SUF changerfile 2>/dev/null | grep -v BUGGY`
+changerfile=`amgetconf$SUF changerfile 2>/dev/null`
if [ -z "$changerfile" ]; then
Exit 2 \
- "<none>" \
+ `_ '<none>'` \
"changerfile must be specified in amanda.conf"
fi
-tape=`amgetconf$SUF tapedev 2>/dev/null | grep -v BUGGY`
+tape=`amgetconf$SUF tapedev 2>/dev/null`
if [ -z "$tape" ]; then
Exit 2 \
- "<none>" \
+ `_ '<none>'` \
"tapedev may not be empty"
elif [ $tape = "/dev/null" -o `expr "$tape" : 'null:'` -eq 5 ]; then
Exit 2 \
- "<none>" \
+ `_ '<none>'` \
"tapedev ($tape) may not be the null device"
fi
-TAPE=`amgetconf$SUF changerdev 2>/dev/null | grep -v BUGGY`
+TAPE=`amgetconf$SUF changerdev 2>/dev/null`
if [ -z "$TAPE" ]; then
Exit 2 \
- "<none>" \
+ `_ '<none>'` \
"changerdev may not be empty"
elif [ $TAPE = "/dev/null" ]; then
Exit 2 \
- "<none>" \
+ `_ '<none>'` \
"changerdev ($TAPE) may not be the null device"
fi
export TAPE # for mtx command
+CHANGER=$TAPE
+export CHANGER # for mtx command
+
#### Set up the various config files.
-configfile=$changerfile.conf
+conf_match=`expr "$changerfile" : .\*\.conf\$`
+if [ $conf_match -ge 6 ]; then
+ configfile=$changerfile
+ changerfile=`echo $changerfile | sed 's/.conf$//g'`
+else
+ configfile=$changerfile.conf
+fi
+
+if [ ! -e $configfile ]; then
+ Exit 2 \
+ `_ '<none>'` \
+ "configuration file \"$configfile\" doesn't exist"
+fi
+if [ ! -f $configfile ]; then
+ Exit 2 \
+ `_ '<none>'` \
+ "configuration file \"$configfile\" is not a file"
+fi
+
cleanfile=$changerfile-clean
accessfile=$changerfile-access
slotfile=$changerfile-slot
cleancount=`cat $cleanfile`
accesscount=`cat $accessfile`
+test -z "$MT" && Exit 2 "<none>" "No mt command defined"
+test ! -f "$MT" && Exit 2 "<none>" "mt command ($MT) doesn't exist"
+test -z "$MTX" && Exit 2 "<none>" "No mtx command defined"
+test ! -f "$MTX" && Exit 2 "<none>" "mtx command ($MTX) doesn't exist"
+
#### Dig out of the config file what is needed
varlist=
else
DBGFILE=/dev/null
fi
- Log === Start "`date`" ===
+ Log `_ '=== Start %s ===' "\`date\`"`
fi
if [ -z "$driveslot" ]; then
Exit 2 \
- "<none>" \
- "cannot determine drive slot from $tape"
+ `_ '<none>'` \
+ `_ 'cannot determine drive slot from %s' "$tape"`
fi
stdout=$TMPDIR/$myname.1.$$
mtx_status=$TMPDIR/$myname.status.$$
trap "rm -f $stdout $stderr $mtx_status" 0 # exit cleanup
-Log "Using config file $configfile"
+Log `_ 'Using config file %s' "$configfile"`
# Log the argument list.
-Log "Arg info:"
+Log `_ "Arg info:"`
LogAppend "\$# = $#"
i=0
LogAppend "\$$i = \"$argv0\""
get_slot_list
-Log "Config info:"
+Log `_ "Config info:"`
for var in $varlist; do
if [ $var = "OFFLINE_BEFORE_UNLOAD" ]; then
continue # old name
eval val=\"'$'$var\"
if [ -z "$val" ]; then
Exit 2 \
- "<none>" \
- "$var missing in $configfile"
+ `_ '<none>'` \
+ `_ '%s missing in %s' "$var" "$configfile"`
fi
if IsNumeric "$val" ; then
:
else
Exit 2 \
- "<none>" \
- "$var ($val) not numeric in $configfile"
+ `_ '<none>'` \
+ `_ '%s (%s) not numeric in %s' "$var" "$val" "$configfile"`
fi
LogAppend $var = \"$val\"
done
if [ $firstslot -gt $lastslot ]; then
Exit 2 \
- "<none>" \
- "firstslot ($firstslot) greater than" \
- "lastslot ($lastslot) in $configfile"
+ `_ '<none>'` \
+ `_ 'firstslot (%s) greater than lastslot (%s) in %s' "$firstslot" "$lastslot" "$configfile"`
fi
if [ $autoclean -ne 0 -a $cleanslot -lt 0 ]; then
Exit 2 \
- "<none>" \
- "autoclean set but cleanslot not valid ($cleanslot)"
+ `_ '<none>'` \
+ `_ 'autoclean set but cleanslot not valid (%s)' "$cleanslot"`
fi
# Set up the current slot
currentslot=`cat $slotfile`
if IsNumeric "$currentslot" ; then
if [ $currentslot -lt $firstslot ]; then
- Log "SETUP -> current slot $currentslot" \
- "less than $firstslot ..." \
- "resetting to $firstslot"
+ Log `_ 'SETUP -> current slot %s less than %s ... resetting to %s' "$currentslot" "$firstslot" "$firstslot"`
currentslot=$firstslot
elif [ $currentslot -gt $lastslot ]; then
- Log "SETUP -> current slot $currentslot" \
- "greater than $lastslot ..." \
- "resetting to $lastslot"
+ Log `_ 'SETUP -> current slot %s greater than %s ... resetting to %s' "$currentslot" "$lastslot" "$lastslot"`
currentslot=$lastslot
fi
else
- Log "SETUP -> contents of $slotfile ($currentslot) invalid," \
- "setting current slot to first slot ($firstslot)"
+ Log `_ 'SETUP -> contents of %s (%s) invalid, setting current slot to first slot (%s)' "$slotfile" "$currentslot" "$firstslot"`
currentslot=$firstslot
fi
else
new_currentslot=$next_slot_after_current
fi
- Log "WARNING -> current slot $currentslot not available," \
- "setting current slot to next slot ($new_currentslot)"
+ Log `_ 'WARNING -> current slot %s not available, setting current slot to next slot (%s)' "$currentslot" "$new_currentslot"`
currentslot=$new_currentslot
fi
eject() {
test -n "$DEBUG" && set -x
- Log "EJECT -> ejecting tape from $tape"
+ Log `_ 'EJECT -> ejecting tape from %s' "$tape"`
get_loaded_info
if [ $loadedslot -gt 0 ]; then
- Log "EJECT -> moving tape from drive $driveslot" \
- "to storage slot $loadedslot"
+ Log `_ 'EJECT -> moving tape from drive %s to storage slot %s' "$driveslot" "$loadedslot"`
if [ $offline_before_unload -ne 0 ]; then
Run $MT $MTF $tape offline > /dev/null 2>&1
fi
sleep $unloadpause
result=`Run $MTX unload $loadedslot $driveslot 2>&1`
status=$?
- Log " -> status $status, result \"$result\""
+ Log `_ ' -> status %s, result "%s"' "$status" "$result"`
mtx_status_valid=0
if [ $status -ne 0 ]; then
answer="$result"
code=0
fi
else
- answer="Drive was not loaded"
+ answer=`_ 'Drive was not loaded'`
code=1
fi
Exit $code "$loadedslot" "$answer"
reset() {
test -n "$DEBUG" && set -x
- Log "RESET -> loading tape from slot $firstslot" \
- "to drive $driveslot ($tape)"
+ Log `_ 'RESET -> loading tape from slot %s to drive %s (%s)' "$firstslot" "$driveslot" "$tape"`
# Call loadslot without doing it as an internal and let it finish
# things up.
loadslot $firstslot
# NOTREACHED
- Exit 2 "<none>" "reset: should not get here"
+ Exit 2 `_ '<none>'` `_ 'reset: should not get here'`
return $? # in case we are internal
}
loadslot() {
test -n "$DEBUG" && set -x
if [ $# -lt 1 ]; then
- Exit 2 "<none>" "Missing -slot argument"
+ Exit 2 `_ '<none>'` `_ 'Missing -slot argument'`
return $? # in case we are internal
fi
whichslot=$1
- Log "LOADSLOT -> load drive $driveslot ($tape) from slot $whichslot"
+ Log `_ 'LOADSLOT -> load drive %s (%s) from slot %s' "$driveslot" "$tape" "$whichslot"`
numeric=`echo $whichslot | sed 's/[^0-9]//g'`
case $whichslot in
find_slot=$cleanslot
;;
*)
- Exit 2 "<none>" "Illegal slot: \"$whichslot\""
+ Exit 2 `_ '<none>'` `_ 'Illegal slot: "%s"' "$whichslot"`
return $? # in case we are internal
;;
esac
done
if [ $# -le 0 ]; then
Exit 2 \
- "<none>" \
- "Cannot find slot $find_slot" \
- "in slot list ($slot_list)"
+ `_ '<none>'` \
+ `_ 'Cannot find slot %s in slot list (%s)' "$find_slot " "$slot_list"`
return $? # in case we are internal
fi
Exit 0 "$loadedslot" "$tape"
return $? # in case we are internal
fi
+ if [ $loadedslot -eq -2 ]; then
+ Exit 0 "$loadedslot" "$tape"
+ return $? # in case we are internal
+ fi
# If we are loading the cleaning tape, bump the cleaning count
# and reset the access count. Otherwise, bump the access count
fi
# Load the tape, finally!
- Log "LOADSLOT -> loading tape from slot $loadslot" \
- "to drive $driveslot ($tape)"
+ Log `_ "LOADSLOT -> loading tape from slot %s to drive %s (%s)" "$loadslot" "$driveslot" "$tape"`
result=`Run $MTX load $loadslot $driveslot 2>&1`
status=$?
- Log " -> status $status, result \"$result\""
+ Log `_ ' -> status %s, result "%s"' "$status" "$result"`
mtx_status_valid=0
if [ $status -ne 0 ]; then
Exit 2 "$loadslot" "$result"
waittime=`expr $waittime + $poll_drive_ready`
done
if [ $ready -eq 0 ]; then
- Exit 2 "$loadslot" "Drive not ready after" \
- "$max_drive_wait seconds," \
- "rewind said \"$result\""
+ Exit 2 "$loadslot" `_ 'Drive not ready after %s seconds, rewind said "%s"' "$max_drive_wait" "$result"`
return $? # in case we are internal
fi
test -n "$DEBUG" && set -x
get_loaded_info
get_slot_list
- Log "INFO -> first slot: $firstslot"
- LogAppend " -> current slot: $currentslot"
- LogAppend " -> loaded slot: $loadedslot"
- LogAppend " -> last slot: $lastslot"
- LogAppend " -> slot list: $slot_list"
- LogAppend " -> can go backwards: 1"
- LogAppend " -> havereader: $havereader"
+ Log `_ 'INFO -> first slot: %s' "$firstslot"`
+ LogAppend `_ ' -> current slot: %s' "$currentslot"`
+ LogAppend `_ ' -> loaded slot: %s' "$loadedslot"`
+ LogAppend `_ ' -> last slot: %s' "$lastslot"`
+ LogAppend `_ ' -> slot list: %s' "$slot_list"`
+ LogAppend `_ ' -> can go backwards: 1'`
+ LogAppend `_ ' -> havereader: %s' "$havereader"`
###
# Check if a barcode reader is configured or not. If so, it
if [ $currentslot -lt $firstslot -o $currentslot -gt $lastslot ]; then
currentslot=$firstslot # what "current" will get
fi
- set x $slot_list
- shift # get rid of the "x"
- numslots=$#
+ numslots=`expr $lastslot - $firstslot + 1`
Exit 0 "$currentslot" "$numslots 1 $reader"
return $? # in case we are internal
}
while read lbl bc junk; do
line=`expr $line + 1`
if [ -z "$lbl" -o -z "$bc" -o -n "$junk" ]; then
- Log "ERROR -> Line $line malformed: $lbl $bc $junk"
- LogAppend " -> Remove $labelfile" \
- "and run" \
- "\"$sbindir/amtape $config update\""
+ Log `_ 'ERROR -> Line %s malformed: %s %s %s' "$line" "$lbl" "$bc" "$junk"`
+ LogAppend `_ ' -> Remove %s and run "%s %s update"' "$labelfile" "$sbindir/amtape" "$config"`
Exit 2 \
- "<none>" \
- "Line $line malformed in $labelfile: $lbl $bc $junk"
+ `_ '<none>'` \
+ `_ 'Line %s malformed in %s: %s %s %s' "$line" "$labelfile" "$lbl" "$bc" "$junk"`
return $? # in case we are internal
fi
if [ $lbl = "$lbl_search" -o $bc = "$bc_search" ]; then
if [ $labelfile_entry_found -ne 0 ]; then
- Log "ERROR -> Duplicate entries: $labelfile line $line"
- LogAppend " -> Remove $labelfile" \
- "and run" \
- "\"$sbindir/amtape $config update\""
+ Log `_ 'ERROR -> Duplicate entries: %s line %s' "$labelfile" "$line"`
+ LogAppend `_ ' -> Remove $labelfile and run "$sbindir/amtape $config update"' "$labelfile" "$sbindir/amtape" "$config"`
Exit 2 \
- "<none>" \
- "Duplicate entries: $labelfile line $line"
+ `_ '<none>'` \
+ `_ 'Duplicate entries: %s line %s' "$labelfile" "$line"`
return $? # in case we are internal
fi
labelfile_entry_found=1
addlabel() {
test -n "$DEBUG" && set -x
if [ $# -lt 1 ]; then
- Exit 2 "<none>" "Missing -label argument"
+ Exit 2 `_ '<none>'` `_ 'Missing -label argument'`
return $? # in case we are internal
fi
tapelabel=$1
if [ $havereader -eq 0 ]; then
- Exit 2 "<none>" "Not configured with barcode reader"
+ Exit 2 `_ '<none>'` `_ 'Not configured with barcode reader'`
return $? # in case we are internal
fi
get_loaded_info
if [ $loadedslot -lt 0 ]; then
- Exit 1 "<none>" "No tape currently loaded"
+ Exit 1 `_ '<none>'` `_ 'No tape currently loaded'`
return $? # in case we are internal
fi
- Log "LABEL -> Adding label \"$tapelabel\"" \
- "with barcode \"$loadedbarcode\"" \
- "for slot $loadedslot" \
- "into $labelfile"
+ Log `_ 'LABEL -> Adding label "%s" with barcode "%s" for slot %s into %s' "$tapelabel" "$loadedbarcode" "$loadedslot" "$labelfile"`
read_labelfile "$tapelabel" "$loadedbarcode" < $labelfile
if [ $labelfile_entry_found -ne 0 ]; then
lf_val=
new_val=$tapelabel
fi
if [ -n "$lf_val" ]; then
- LogAppend "ERROR -> !!! Label database corrupted !!!"
- LogAppend " -> \"$old_val\" conflicts with" \
- "new $val_type \"$new_val\"" \
- "for $lf_type \"$lf_val\""
- LogAppend " -> Remove $labelfile" \
- "and run" \
- "\"$sbindir/amtape $config update\""
+ LogAppend `_ 'ERROR -> !!! Label database corrupted !!!'`
+ LogAppend `_ ' -> "%s" conflicts with new %s "%s" for %s "%s"' "$old_val" "$val_type" "$new_val" "$lf_type" "$lf_val"`
Exit 2 \
- "<none>" \
- "$tapelabel: \"$old_val\" conflicts with" \
- "new $val_type \"$new_val\"" \
- "for $lf_type \"$lf_val\""
+ `_ '<none>'` \
+ `_ '%s: "%s" conflicts with new %s "%s" for %s "%s"' "$tapelabel" "$old_val" "$val_type" "$new_val" "$lf_type" "$lf_val"`
return $? # in case we are internal
fi
- LogAppend " -> already synced"
+ LogAppend `_ " -> already synced"`
else
echo "$tapelabel $loadedbarcode" >> $labelfile
- LogAppend " -> appended $labelfile entry:" \
- "$tapelabel $loadedbarcode"
+ LogAppend `_ ' -> appended %s entry: %s %s' "$labelfile" "$tapelabel" "$loadedbarcode"`
fi
Exit 0 "$loadedslot" "$tape"
return $? # in case we are internal
searchtape() {
test -n "$DEBUG" && set -x
if [ $# -lt 1 ]; then
- Exit 2 "<none>" "Missing -search argument"
+ Exit 2 `_ '<none>'` `_ 'Missing -search argument'`
return $? # in case we are internal
fi
tapelabel=$1
if [ $havereader -eq 0 ]; then
- Exit 2 "<none>" "Not configured with barcode reader"
+ Exit 2 `_ '<none>'` `_ 'Not configured with barcode reader'`
return $? # in case we are internal
fi
- Log "SEARCH -> Hunting for label \"$tapelabel\""
+ Log `_ 'SEARCH -> Hunting for label "%s"' "$tapelabel"`
read_labelfile "$tapelabel" "" < $labelfile
if [ $labelfile_entry_found -eq 0 ]; then
- LogAppend " -> !!! label \"$tapelabel\" not found" \
- "in $labelfile !!!"
- LogAppend " -> Remove $labelfile" \
- "and run" \
- "\"$sbindir/amtape $config update\""
+ LogAppend `_ ' -> !!! label "%s" not found in %s !!!' "$tapelabel" "$labelfile"`
+ LogAppend `_ ' -> Remove $labelfile and run "%s %s update"' "$labelfile" "$sbindir/amtape" "$config"`
Exit 2 \
- "<none>" \
- "$tapelabel: label \"$tapelabel\" not found in $labelfile"
+ `_ '<none>'` \
+ `_ '%s: label "%s" not found in %s' "$tapelabel" "$tapelabel" "$labelfile"`
return $? # in case we are internal
fi
- LogAppend " -> barcode is \"$labelfile_barcode\""
+ LogAppend `_ ' -> barcode is "%s"' "$labelfile_barcode"`
get_mtx_status
foundslot=`sed -n '
/VolumeTag *= *'$labelfile_barcode' *$/ {
q
}
' < $mtx_status`
- LogAppend " -> foundslot is $foundslot"
+ LogAppend `_ ' -> foundslot is %s' "$foundslot"`
if [ -z "$foundslot" ]; then
- LogAppend "ERROR -> !!! Could not find slot" \
- "for barcode \"$labelfile_barcode\"!!!"
- LogAppend " -> Remove $labelfile" \
- "and run" \
- "\"$sbindir/amtape $config update\""
+ LogAppend `_ 'ERROR -> !!! Could not find slot for barcode "%s"!!!' "$labelfile_barcode"`
+ LogAppend `_ ' -> Remove %s and run "%s %s update"' "$labelfile" "$sbindir/amtape" "$config"`
Exit 2 \
- "<none>" \
- "barcode \"$labelfile_barcode\"" \
- "not found in mtx status output"
+ `_ '<none>'` \
+ `_ 'barcode "%s" not found in mtx status output' "$labelfile_barcode"`
return $? # in case we are internal
fi
# Call loadslot without doing it as an internal and let it finish
# things up.
loadslot $foundslot
# NOTREACHED
- Exit 2 "<none>" "searchtape: should not get here"
+ Exit 2 `_ '<none>'` `_ 'searchtape: should not get here'`
return $? # in case we are internal
}
###
if [ $# -lt 1 ]; then
- Exit 2 "<none>" "Usage: $myname -command args"
+ Exit 2 `_ '<none>'` `_ 'Usage: %s -command args' "$myname"`
fi
cmd=$1
shift
loadslot clean
;;
*)
- Exit 2 "<none>" "unknown option: $cmd"
+ Exit 2 `_ '<none>'` `_ 'unknown option: %s' "$cmd"`
;;
esac
-Exit 2 "<none>" "$myname: should not get here"
+Exit 2 `_ '<none>'` `_ '%s: should not get here' "$myname"`