# /etc/Tprestore shell script
# Copyright 1986 L/F Technologies, Carson City, Nevada
# Author: Rodger Lakey
# Date Dec 10, 1986
# Version 1.0
#
DEVICE=/dev/tape

echo "Tape restore program"
echo ""

echo "Enter list of filenames and/or directories to be restored from tape."
echo "Names may be entered on one line separated by spaces,"
echo "or entered on separate lines. A blank line will terminate"
echo "the list. Then the files will be copied from tape."

set -f
LIST=""
while :
do
	echo "Enter names: \c"
	read NAME
	if [ "$NAME" = "" ]
	then
		break
	fi
	LIST="$LIST $NAME"
done

if [ "$LIST" = "" ]
then
	echo "No files have been requested. Exiting program."
	exit
fi

mt rewind
if rbuf $DEVICE | cpio -ivduma $LIST
then
	echo "Restore done, rewinding tape."
else
	echo ""
	echo "An error has occurred while copying the requested"
	echo "files from tape. The backup on the tape may not be good."
	echo "Please either retry the restore, or verify"
	echo "that the tape is usable by using the Tplist program."
fi
set +f
mt rewind

