#
#
-
if [ -d "@AMANDA_DBGDIR@" ]; then
logfile=@AMANDA_DBGDIR@/changer.debug
else
logfile=/dev/null
fi
-myname=$0
+myname=`basename $0`
EGREP='@EGREP@'
exit 2
fi
-MAILER=@MAILER@
ONLINEREGEX="ONLINE|READY|sense[_ ]key[(]0x0[)]|sense key error = 0|^er=0$|, mt_erreg: 0x0|^Current Driver State: at rest$"
REPORTTO=`amgetconf mailto`
+MAILER=`amgetconf mailer`
tape=`amgetconf tapedev`
if [ -z "$tape" ]; then
lastslot=99
resend_mail=900 # 15 minutes
timeout_mail=604800 # 7 days
+abort_file="chg-manual.abort"
+abort_dir=`pwd`
changerfile=`amgetconf changerfile`
request_tty() {
if > /dev/tty; then
- echo -n `_ 'Insert tape into slot %s and press return' "$1"` > /dev/tty
+ echo "$amdevcheck_message" >> /dev/tty
+ # message parsed by ZMC:
+ echo `_ 'Insert tape into slot %s and press return' "$1"` > /dev/tty
+ echo `_ ' or type "NONE" to abort'` > /dev/tty
read ANSWER < /dev/tty
+ if [ X"$ANSWER" = X"NONE" ]; then
+ echo `_ 'Aborting by user request'` > /dev/tty
+ answer=`_ '<none> Aborting by user request'`
+ echo `_ 'Exit ->'` $answer >> $logfile
+ echo $answer
+ exit 2
+ fi
else
- echo -n `_ 'no /dev/tty to ask to change tape'`
- exit 1
+ answer=`_ '<none> no /dev/tty to ask to change tape'`
+ echo `_ 'Exit ->'` $answer >> $logfile
+ echo $answer
+ exit 2
fi
}
# the E-mail once an hour in case it gets lost.
timeout=0
gtimeout=$timeout_mail
+ rm -f $abort_filename
while true;do
if [ $gtimeout -le 0 ]; then
- echo -n `_ 'timeout waiting for tape online'`
- exit 1;
+ answer=`_ '%s %s: timeout waiting for tape online' "$load" "$myname"`
+ echo `_ 'Exit ->'` $answer >> $logfile
+ echo $answer
+ exit 2;
+ fi
+ if [ -f $abort_filename ]; then
+ rm -f $abort_filename
+ answer=`_ '<none> Aborting by user request'`
+ echo `_ 'Exit ->'` $answer >> $logfile
+ echo $answer
+ exit 2
fi
if [ $timeout -le 0 ]; then
- msg=`_ 'insert Amanda tape into slot %s (%s)' "$1" "$tape"`
+ msg=`_ '%s\nInsert Amanda tape into slot %s (%s)\nor \`touch %s\` to abort.' "$amdevcheck_message" "$1" "$tape" "$abort_filename"`
subject=`_ '%s AMANDA TAPE MOUNT REQUEST FOR SLOT %s' "$ORG" "$1"`
echo "$msg" | $MAILER -s "$subject" $REPORTTO
timeout=$resend_mail
request_tty_email() {
if > /dev/tty; then
- echo -n `_ 'Insert tape into slot %s and press return' "$1"` > /dev/tty
- read ANSWER < /dev/tty
+ request_tty "$1"
else
request_email "$1"
fi
answer=`_ "<none> %s: Can't send email because MAILER is not defined" "$myname"`
echo `_ 'Exit ->'` $answer >> $logfile
echo $answer
- exit 1
+ exit 2
fi
fi
answer="$slot $tape"
code=0
else
- answer=`_ '<none> %s: Drive was not loaded' "$myname"`
+ answer=`_ '<none> %s: %s' "$myname" "$amdevcheck_message"`
code=1
fi
echo `_ 'Exit ->'` $answer >> $logfile
exit $code
}
+abort_filename="$abort_dir/$abort_file"
+
#
reset() {
if amdevcheck_status $tape; then
answer="$slot $tape"
else
- answer="0 $tape"
+ answer="0 $tape $amdevcheck_message"
fi
echo `_ 'Exit ->'` $answer >> $logfile
echo $answer
case $whichslot in
current)
load=$slot
- [ $load -eq 0 ] && load=$firstslot
- [ $load -gt $lastslot ] && load=$firstslot
- [ $load -lt $firstslot ] && load=$lastslot
;;
next|advance)
load=`expr $slot + 1`
exit 0
fi
+ if [ X"$whichslot" = X"current" ]; then
+ answer="<none> Current slot not loaded"
+ echo `_ 'Exit ->'` $answer>> $logfile
+ echo $answer
+ exit 1
+ fi
+
expr $accesscount + 1 > $accessfile
if [ $tape_status -eq 0 ]; then
eject
;;
*)
- fmt`gettext "<none> %s: Unknown option %s\n"`
+ fmt=`gettext "<none> %s: Unknown option %s\n"`
printf $fmt $myname $1
exit 2
;;