Tuesday, May 6, 2025

Script for applying EBS technology patches

A key step in applying EBS CPU patches is to decide which technology patches are required by both ETCC checker and quarterly CPU Release document for WebLogic and Oracle Homes of Fusion Middleware. After the list of required patches for each component is decided, I write a shell script to run the patching process and make it more consistent and much quicker cross nodes and different instances (Dev, QA, & Prod).

Pre-steps: place technology patch files to a location shared by many servers. For January 2025 CPU patches (Doc ID 3061170.1), 3 patches are needed and copied to each dedicated sub-folder WLS and FMW_Comm under location /path/to/Jan2025_CPU:
 
- FMW_Comm
Holds 3 Fusion Middleware patch files. Each .zip file is unzipped to its own sub-folder here.
$ cd /path/to/Jan2025_CPU/FMW_Comm
$ ls *.*
ocm.rsp
p33974106_111190_Generic.zip
p33960746_111190_Generic.zip
p34714760_111190_Generic.zip

Do unzip and chmod just one time.
$ unzip p33974106_111190_Generic.zip
$ unzip p33960746_111190_Generic.zip
$ unzip p34714760_111190_Generic.zip

Open READ permission for other OS accounts to run the script to patch instances on other servers: (Or, remove the sub-folder and then unzip the .zip file again before each opatch run.)
$ chmod -R +r 33974106
$ chmod -R +r 33960746
$ chmod -R +r 34714760

$ ls -l | egrep "^drw" |awk '{print $9}'
33974106
33960746
34714760

- WLS 
Holds 3 WLS patch zip files, and each file is saved in its own sub-folder:
13845626/p13845626_10360231017_Generic.zip
35476084/p35476084_1036_Linux-x86-64.zip
35586779/p35586779_1036_Generic.zip

- FMW_Ora
Only holds opatch response file ocm.rsp. No Forms & Reports patch is required by January 2025 CPU patches.

-FMW_Web
Empty. No IAS_ORACLE_HOME patch is required by January 2025 CPU patches.

============= script apply_EBStechPatches.sh ============
# apply tech patches for January 2025 EBS CPU technology patches. 
# it can be easily modified for other R12.2 EBS CPU releases.
# 1. Make sure same patches are required cross different nodes and instances!
# 2. Assume all patch files are saved in 4 sub-folders of a shared location: 
# FMW_Ora, FMW_Comm, FMW_Web, WLS
# 3. Assume ocm.rsp for for running opatch silently exists in folder $patchFileLoc/FMW_Ora
#
# Call the script, for example: ./apply_EBStechPatches.sh 'appsPWD$%^&_!'
#
###  Specify the path to the shared location where patch files are saved:
patchFileLoc=/path/to/Jan2025_CPU
appsPWD=$1
if [ -z "$appsPWD" ]; then
 echo "ETCC needs password to run the script. Exit ..."
 exit 1
fi
runcount=`ps -ef | grep ${LOGNAME:0:7} | grep tnslsnr | wc -l`
if [ $runcount -gt 1 ]
then
 echo "EBS services may still running. Please stop them first. (count: $runcount)"
 exit 1
fi

## Optional
# echo "Run ETCC script:" 
# cd $patchFileLoc/ETCC
# echo $appsPWD | checkMTpatch.sh

echo "Apply WLS patches:"
if [ -f p*.zip ]; then   # if no .zip files in this folder, move to patch next ORACLE_HOME
 zipcount=`ls -al $patchFileLoc/WLS/*.zip | wc -l`
 echo "Apply $zipcount patch(es) to WebLogic..."
 echo $FMW_HOME
 cd $FMW_HOME/utils/bsu/cache_dir
 echo $PWD

 # assume all patch .zip files were copied to folder $patchFileLoc/WLS.
 #
 ### Because removal of conflict WLS patches may required, it is difficult to automate this part.
 ### Editing is needed for each CPU release! ###
 ### Below lines are for January 2025 CPU patching.
 cp -f $patchFileLoc/WLS/13845626/p13845626_10360231017_Generic.zip .
 cp -f $patchFileLoc/WLS/35476084/p35476084_1036_Linux-x86-64.zip .
 cp -f $patchFileLoc/WLS/35586779/p35586779_1036_Generic.zip .
 ls -altr
 unzip -o p35586779_1036_Generic.zip
 unzip -o p35476084_1036_Linux-x86-64.zip
 unzip -o p13845626_10360231017_Generic.zip
 cd ..
 echo $PWD
 ./bsu.sh -remove -patchlist=AMGE -prod_dir=$FMW_HOME/wlserver_10.3
 ./bsu.sh -remove -patchlist=P8S7 -prod_dir=$FMW_HOME/wlserver_10.3
 ./bsu.sh -install -patch_download_dir=$FMW_HOME/utils/bsu/cache_dir -patchlist=E7HI -prod_dir=$FMW_HOME/wlserver_10.3
 ./bsu.sh -install -patch_download_dir=$FMW_HOME/utils/bsu/cache_dir -patchlist=WY44 -prod_dir=$FMW_HOME/wlserver_10.3
 ./bsu.sh -remove -patchlist=CW7X -prod_dir=$FMW_HOME/wlserver_10.3
 ./bsu.sh -install -patch_download_dir=$FMW_HOME/utils/bsu/cache_dir -patchlist=KMHV -prod_dir=$FMW_HOME/wlserver_10.3
 ./bsu.sh -prod_dir=$FMW_HOME/wlserver_10.3 -status=applied -verbose -view | egrep -i 'KMHV|WY44|E7HI'
 ### stop editing ###
else
 echo "No zip files in this folder. No WLS patching is needed for this release."
fi

# Apply patches to 3 Oracle_HOMEs
# Assume ocm.rsp for opatch exists in folder $patchFileLoc/FMW_Ora

echo "Apply patches to Forms & Reports"
cd $patchFileLoc/FMW_Ora       # assume all ORACLE_HOME .zip files were unzipped in this folder.
foldercount=`find * -prune -type d | wc -l`
if [ $foldercount -gt 0 ]; then
 export ORACLE_HOME=$RUN_BASE/EBSapps/10.1.2
 export PATH=$ORACLE_HOME/OPatch:$PATH
 echo "apply $foldercount patch(es) to Oracle Home: $ORACLE_HOME"
 which opatch
 for x in `ls -l | egrep "^drw" |awk '{print $9}'`
 do
  echo "apply patch $x"
  cd $x
  opatch apply -silent -ocmrf $patchFileLoc/FMW_Ora/ocm.rsp
  cd ..
  opatch lsinventory | egrep -i "$x"
  echo
 done
else
 echo "No patch is needed"
fi

echo "Apply patches to ORACLE_WEBTIER:"
cd $patchFileLoc/FMW_Web      # assume all IAS_ORACLE_HOME .zip files were unzipped in this folder.
foldercount=`find * -prune -type d | wc -l`
if [ $foldercount -gt 0 ]; then
 export ORACLE_HOME=$IAS_ORACLE_HOME   # Or, $FMW_HOME/webtier
 export PATH=$ORACLE_HOME/OPatch:$PATH
 echo "apply $foldercount patch(es) to Oracle Home: $ORACLE_HOME"
 which opatch
 for x in `ls -l | egrep "^drw" |awk '{print $9}'`
 do
  echo "apply patch $x"
  cd $x
  opatch apply -silent -ocmrf $patchFileLoc/FMW_Ora/ocm.rsp
  cd ..
  opatch lsinventory | egrep -i "$x"
  echo
 done
else
 echo "No patch is needed"
fi

echo "Apply patches to ORACLE_COMMON:"
cd $patchFileLoc/FMW_Comm      # assume all ORACLE_COMMON .zip files were unzipped in this folder.
foldercount=`find * -prune -type d | wc -l`
if [ $foldercount -gt 0 ]; then
 export ORACLE_HOME=$FMW_HOME/oracle_common
 export PATH=$ORACLE_HOME/OPatch:$PATH
 echo "apply $foldercount patch(es) to Oracle Home: $ORACLE_HOME"
 which opatch
 for x in `ls -l | egrep "^drw" |awk '{print $9}'`
 do
  echo "apply patch $x"
  cd $x
  opatch apply -silent -ocmrf $patchFileLoc/FMW_Ora/ocm.rsp
  cd ..
  opatch lsinventory | egrep -i "$x"
 echo
 done
else
 echo "No patch is needed"
fi

echo "ETCC to confirm no more patches are needed:"
cd $patchFileLoc/ETCC
echo $appsPWD | checkMTpatch.sh
exit 0
============== End ================

No comments: