#!/bin/sh
# Copyright (c) 2009, Oracle Corporation.  All rights reserved

echo This script is going to restore the Oracle Home to the previous state.
echo It does not perform any of the following:
echo - Running init/pre/post scripts
echo - Oracle binary re-link
echo - Customized steps performed manually by user
echo Please use this script with supervision from Oracle Technical Support.



# Get ORACLE_HOME from environment variable "ORACLE_HOME"
OH=${ORACLE_HOME}

# Error out if OH is not set
if [ "$OH" = "" ]; then
    echo Oracle Home is not set.
    echo Please set env. variable ORACLE_HOME and try again.
    echo Script failed to proceed.
    exit 1
fi

echo "About to modify Oracle Home( $OH )"
echo "Do you want to proceed? [Y/N]"
if [ "$1" = "-silent" ]; then
   response="Y"
else
    read response;
fi

if [ $response = "y" ] || [ $response = "Y" ]; then
    echo "User responded with : Y"
else
    echo "User responded with : $response"
    exit 0
fi




echo Date   Time : `date` >> $OH/cfgtoollogs/opatch/opatch_history.txt
echo Oracle Home : $OH >> $OH/cfgtoollogs/opatch/opatch_history.txt
echo Command     : restore.sh >> $OH/cfgtoollogs/opatch/opatch_history.txt

\rm -rf $OH/.patch_storage/9452259_Mar_18_2010_23_37_55/files

cd $OH/.patch_storage/9452259_Mar_18_2010_23_37_55/backup
for dname in "`\ls -1A`" ; do
    \cp -fR $dname $OH ;
done

echo Restore script completed.
