#!/bin/sh

# getactbrst
#
# Usage: getactbrst <archive> <actbrst> <logfile>
# This script must be run by a user with appropriate privileges (e.g., root)
#
# archive: the filename of the restore archive
# logfile: the filename of the log file to create
# actbrst: the filename of the actbrst file
#
# Return Codes:
# 1 - tar error
# 06-27-07  R. Manso  Remove the --overwrite option from the tar command.


CURRENTDIR=$PWD
ARCHIVE=$1
ACTBRST=$2
LOG=$3

# Start log
echo -e "-> getactbrst `date`\n" >> $LOG

echo -e "archive is $ARCHIVE\n" >> $LOG

echo -e "actbrst is $ACTBRST\n" >> $LOG

# make sure we are in the system temp directory
cd /tmp

if !(tar -xvjf $ARCHIVE $ACTBRST -C /tmp > /tmp/actbrst.log 2>&1); then
    echo -e "tar error extracting files from archive.. exiting\n" >> /tmp/actbrst.log
    cat /tmp/actbrst.log >> $LOG
    cd $CURRENTDIR
    exit 1
fi
cp /tmp/console/data/actbrst.trm /tmp/actbrst.trm



cd $CURRENTDIR

cat /tmp/actbrst.log >> $LOG

# stop log
echo -e "<- getactbrst `date` \n" >> $LOG

exit 0
