#!/bin/sh

# localrestore - utility to restore a local backup file
#		 to be used after upgrade
#
# Usage: localrestore path/file

backupdir=/var/tmp
backupfile=backup-upgrade.rat
backup=$backupdir/$backupfile

echo ""
echo "WARNING: localrestore is to be only used after an upgrade"
echo "         of the SSRR software"
echo "         Otherwise, the system will have unintended data"
echo ""

if [ ! -r "$shadow" ]; then
	echo "You must be root to execute this command"
	echo "Exiting..."
	exit 1
fi

ans=''
while [ "$ans" != 'n' -a "$ans" != 'y' ]; do
	/bin/echo "Continue? [y/n] (n):\c"
	read ans
	if [ X"$ans" = 'X' ]; then
		ans='n'
	fi
done

if [ "$ans" = 'n' ]; then
	echo "Exiting..."
	exit 0
else
	if [ ! -f "$backup" ]; then
		echo "$backup does not exist"
		echo "Exiting..."
		exit 1
	fi

	if [ ! -r "$backup" ]; then
		echo "$backup is not readable"
		echo "Exiting..."
		exit 1
	fi
	
	cd /
	echo tar xvfp $backup 
fi

touch /var/adm/messages.se*
chmod 644 /var/adm/messages.se*
chown root /var/adm/messages.se*
chmod 100 /var/remote.support/scripts/modchk

echo "Restore completed"
