#!/bin/sh

OH=`echo $ORACLE_HOME`

if [ "$1" = "-rollback" ]
then
        TIME=`date +%d"-"%m"-"%Y"_"%H"-"%M"-"%S`
        if [ -s $OH/inventory/filemap/Apache/Jserv/libexec/files.map ]
        then

#Check if the inventory contains file.map entry for 9207 CPUOct (bugno 4567854)
#If so clear the entry by taking a backup of the file.
                grep 4567854 $OH/inventory/filemap/Apache/Jserv/libexec/files.map > /dev/null
                if [ $? -eq 0 ]
                then
                mv $OH/inventory/filemap/Apache/Jserv/libexec/files.map $OH/inventory/filemap/Apache/Jserv/libexec/files.map.$TIME
                sed '/4567854/d' $OH/inventory/filemap/Apache/Jserv/libexec/files.map.$TIME > $OH/inventory/filemap/Apache/Jserv/libexec/files.map
                fi
        fi

#Checking for new directories created by Opatch during patch application
#Clearing the file.map entries for those.

        if [ -s $OH/inventory/filemap/cpu/CPUOct2005/files.map ]
        then
                mv $OH/inventory/filemap/cpu/CPUOct2005/files.map $OH/inventory/filemap/cpu/CPUOct2005/files.map.$TIME
                touch $OH/inventory/filemap/cpu/CPUOct2005/files.map
        fi

        if [ -s $OH/inventory/filemap/cpu/CPUOct2005/owa_all/30/files.map ]
        then
                mv $OH/inventory/filemap/cpu/CPUOct2005/owa_all/30/files.map $OH/inventory/filemap/cpu/CPUOct2005/owa_all/30/files.map.$TIME
                touch $OH/inventory/filemap/cpu/CPUOct2005/owa_all/30/files.map
        fi

        if [ -s $OH/inventory/filemap/cpu/CPUOct2005/owa_all/90/files.map ]
        then
                mv $OH/inventory/filemap/cpu/CPUOct2005/owa_all/90/files.map $OH/inventory/filemap/cpu/CPUOct2005/owa_all/90/files.map.$TIME
                touch $OH/inventory/filemap/cpu/CPUOct2005/owa_all/90/files.map
        fi

fi

if  [ -d $OH/cpu/CPUOct2005_rollback ]
then
    mv $OH/cpu/CPUOct2005_rollback $OH/cpu/CPUOct2005
    mkdir $OH/cpu/CPUOct2005/.rollbacked
fi
if [ -f $OH/cpu/CPUOct2005/check.sh ]
then
        chmod u+x $OH/cpu/CPUOct2005/check.sh
fi
