-#!/bin/sh
+#!@SHELL@
#
# Exit Status:
# 0 Alles Ok
# 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
#
# autocleancount=99 #### Number of access before a clean.
#
+# cleancycle=120 #### Time (seconds) to clean drive (default 120)
+#
# havereader=0 #### If you have a barcode reader, set to 1.
#
# offline_before_unload=0 #### Does your robot require an
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.*:VolumeTag/ {
- s/.*(Storage Element \([0-9][0-9]*\) Loaded):VolumeTag *= *\([^ ]*\)/\1 \2/p
+/^Data Transfer Element '$driveslot':Full (Unknown Storage Element Loaded):VolumeTag *= *\([^ ]*\)/ {
+ s/.*:VolumeTag *= *\([^ ]*\)/-2 \1/p
q
}
-/^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
q
}
-/^Data Transfer Element '$driveslot':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 (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"
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
+ }
+}
+' < $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
+ }
+}
+' < $mtx_status 2>& 1`
+ shift # get rid of the "x"
+ loadedslot=$1
+ fi
+
if IsNumeric "$loadedslot" ; then
:
else
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/ {
- 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
}
-/^[ ]*Storage Element \([0-9][0-9]*\):Full/ {
- s/.*Storage Element \([0-9][0-9]*\):.*/\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
+ }
+}
+/^.*Storage Element \([0-9][0-9]*\):Full/ {
+ s/.*Storage Element \([0-9][0-9]*\):Full.*/\1/p
}
' < $mtx_status 2>&1 | grep -v "^${cleanslot}\$" | sort -n`
slot_list=`echo $slot_list` # remove the newlines
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>" \
"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 ($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>" \
#### 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
+
cleanfile=$changerfile-clean
accessfile=$changerfile-access
slotfile=$changerfile-slot
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
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
}