#!/bin/sh
##*******************************************************************
## File Name :
xxrl_recreate_symlinks.sh
## File Location :
$XXRL_TOP/bin
## Created By :
Abul Mohsin
## Creation Date : June
21, 2014
## Description :
This program deletes the old Symbolic Links
## that are copied over from PROD
refresh, then
## recreates them for that instance. If no *.prog
## files
found, the program simply exists.
##
## Program Language : Shell
Script
## Specific Module : Generic
for all modules
## Create SymLink : %>
chmod 755 xxrl_data_ldr.prog
## %>
ln -s $FND_TOP/bin/fndcpesr xxrl_data_ldr
##
## Execute Command : %>
./xxrl_recreate_symlinks.sh
##
##*******************************************************************
## History: (Date, Version, Programmer,
Change Description)
##-------------------------------------------------------------------
## 06/21/14 1.0 A.Mohsin Initial version
##
##*******************************************************************
##----------------------------------------------------
##-- set these variables based on user preference
##----------------------------------------------------
customTop=$XX_TOP ##-- this is based on company's custom top
##----------------------------------------------------
##-- set these variables based on user preference
##----------------------------------------------------
fileExt="prog" ##--
usually .prog file in Oracle
debugMode='N'
##-- use 'Y' if you need to display everything
##----------------------------------------------------
##-- set up local variables based on previous ones
##----------------------------------------------------
binDir=${customTop}/bin
echo
' '
echo
binDir=$binDir
##-- go to BIN directory first
cd
$binDir
if
[ "$debugMode" = 'Y' ]; then
pwd
fi
##----------------------------------------------------
##-- get the number of symbolic link files from BIN dir
##----------------------------------------------------
fileListCnt=`ls *.${fileExt} | sed 's/\.[^.]*$//' | wc -l`
echo
"${fileExt} File Count $fileListCnt"
echo
' '
##----------------------------------------------------
##-- if 1 or more files found in the BIN directory,
##-- then, get the symbolic link files from BIN directory
##----------------------------------------------------
if
[ $fileListCnt -gt 0 ]; then
fileList=`ls
*.${fileExt} | sed 's/\.[^.]*$//'`
for fileName in ${fileList};
do
##----------------------------------------------------
##-- check if the file
exists and is a symbolicLink
##----------------------------------------------------
if [ $debugMode = 'Y' ]; then
echo "SymbolicLink
fileName="$fileName
fi
##----------------------------------------------------
##-- check if the file
exists and is a symbolicLink
##----------------------------------------------------
if [[ -f "$fileName" &&
-L "$fileName" ]]; then
##----------------------------------------------------
##-- first, remove the
SymbolicLink file
##----------------------------------------------------
echo " Deleting SymbolicLink $fileName"
rm $fileName
retCode=$?
if [ $retCode != 0 ]; then
echo "File
$fileName was not removed. Please re-verify."
fi
##----------------------------------------------------
##-- Recreating
SymbolicLink file
##----------------------------------------------------
echo " Recreating SymbolicLink for
$fileName.$fileExt"
ln -s $FND_TOP/bin/fndcpesr $fileName
retCode=$?
if [ $retCode != 0 ]; then
echo "SymbolicLink
$fileName was not created. Please check the .prog file."
fi
##----------------------------------------------------
##-- if the file is not a
SymbolicLink, show err msg
##----------------------------------------------------
else
echo " $fileName is NOT a symlink"
fi
echo ' '
done
else
echo "No
SymbolicLink files found"
echo "Exiting
the program"
fi
exit