#!/bin/sh
#$Id: shak_sick_v 1.8 1997/01/04 01:23:44 jhl Exp $
# This is what is done when the watchdog timer expires.
USER=root
export USER

sickdelay1="$sickdelay"
sickdelay=0
export sickdelay

halted="queue status: The queue was not halted by this exception."

if [ "$SHAK_devicesecure" = yes ]; then
	halted="queue status: The queue was halted by this exception."
	( trap '' 1 2 15; ${SHAK_LIBPATH}/shak_haltq ) &
fi


    echo "shak:shak_sick: Command timeout: $sickdelay1 seconds expired: "$@" " | logger
    echo "shak:shak_sick: Command timeout: Taking $SHAK_TAPEDEVICE offline. " | logger
    errorstring="`$SHAK_LIBPATH/$SHAK_MT -f ${SHAK_MTDEVICE} offline 2>&1`"
    if [ ! $? -eq 0 -o "$errorstring" ]; then
   		retval=1
    else
   		retval=0
    fi

    if [ "$retval" = "0" ]; then



	echo "shak:shak_sick: Command timeout: $SHAK_TAPEDEVICE offline. " | logger
        mail -s "SHAK: watchdog timeout, tape taken offline." root <<EOF
Shak backup failed due to watchdog timer timeout.
The device $SHAK_TAPEHOST:$SHAK_TAPEDEVICE was taken offline.
Timed out command was: "$*".
Timeout occurred after $sickdelay1 seconds.
$halted
Backup Header SHAK_SHAKHEADER is listed on next line.
header:$SHAK_SHAKHEADER
EOF
    
    
    
    else
   
   
	echo "shak:shak_sick: Command timeout: $SHAK_TAPEDEVICE not taken offline; mt command failed. " | logger
	mail -s "SHAK: watchdog timeout, tape not taken offline" root <<EOF
Shak backup failed due to watchdog timer timeout.
The device $SHAK_TAPEHOST:$SHAK_TAPEDEVICE was not taken offline due
to failure of mt(1) indicated by exit status.
Timed out command was: "$*".
Timeout occurred after $sickdelay1 seconds.
$halted
Backup Header SHAK_SHAKHEADER is listed on next line.
header:$SHAK_SHAKHEADER
EOF
   
   
   fi

exit $retval

