What prepatch.sh and postpatch.sh do when manually applying DB home patch of GI RU/RUR

When manually apply Oracle clusterware  GI RU/RUR patches,   for DB home, the steps will be similar like :

  • Run  prepatch.sh
  • Apply patches
  • Run postpatch.sh

What prepatch.sh really does ?

1)Let’s look at the prepatch.sh first :

...
..
.
## Function for adding write permission to the owner for all of
## the scripts in the Oracle Home.
ALL_SCRIPTS="bin/srvctl bin/srvconfig bin/cluvfy"

ALL_DBEXES="bin/racgmain bin/racgeut bin/diskmon.bin bin/lsnodes bin/osdbagrp bin/rawutl srvm/admin/ractrans srvm/admin/getcrshome bin/gnsd bin/crsdiag.pl"

ALL_DBLIBS="lib/libhasgen11.$LEXT lib/libttsh11.$LEXT lib32/libttsh11.$LEXT lib32/libdbcfg11.$LEXT lib32/libhasgen11.$LEXT lib32/libocr11.$LEXT lib32/libocrb11.$LEXT lib32/libocrutl11.$LEXT lib32/libsrvm11.$LEXT lib32/libsrvmhas11.$LEXT lib32/libsrvmocr11.$LEXT lib32/libuini11.$LEXT lib/libclsra11.$LEXT lib/libdbcfg11.$LEXT lib/libocr11.$LEXT lib/libocrb11.$LEXT lib/libocrutl11.$LEXT lib/libuini11.$LEXT lib/librdjni11.$LEXT lib/libgns11.$LEXT lib/libgnsjni11.$LEXT lib/libagfw11.$LEXT"

addperms()
{
for file in $ALL_SCRIPTS
do
if [ -f "$OH/$file" ]; then
$CHMOD 755 $OH/$file
fi
done
}

addperms2()
{
for file in $ALL_DBEXES
do
if [ -f "$OH/$file" ]; then
$CHMOD 755 $OH/$file
fi
done
}

addperms3()
{
for file in $ALL_DBLIBS
do
if [ -f "$OH/$file" ]; then
$CHMOD 755 $OH/$file
fi
done
}
...
..
.
RACGWRAP=$OH/bin/racgwrap
PARAMFILE=$OH/install/params.ora
SRVCTL=$OH/bin/srvctl

addperms
addperms2
## Opatch places the libs with proper permissions set. 
## No need to alter here.
## addperms3
...
..
.
##
## Now that we have values for all of the values, then place them into
## the stored parameter file.
##
$RMF $PARAMFILE

$ECHO ORACLE_HOME=$ORACLE_HOME >> $PARAMFILE
$ECHO ORACLE_BASE=$ORACLE_BASE >> $PARAMFILE
$ECHO s_OracleHome=$ORACLE_HOME >> $PARAMFILE

$ECHO "$0 completed successfully."
exit 0;
[oracle@oemnode1 scripts]$

2)Run prepatch.sh when patching 28864593.

[oracle@oemnode1 28864593]$ custom/scripts/prepatch.sh -dbhome $ORACLE_HOME
custom/scripts/prepatch.sh completed successfully.
[oracle@oemnode1 28864593]$

3) Running of prepatch.sh achieves.

a) Change permission to 755 for the files in variable “ALL_SCRIPTS”.

ALL_SCRIPTS="bin/srvctl bin/srvconfig bin/cluvfy"
for file in $ALL_SCRIPTS
do
     if [ -f "$OH/$file" ]; then
        $CHMOD 755 $OH/$file
     fi
done
}

b) Change permission to 755 for the files in variable “ALL_DBEXES”.

ALL_DBEXES="bin/racgmain bin/racgeut bin/diskmon.bin bin/lsnodes bin/osdbagrp bin/rawutl srvm/admin/ractrans srvm/admin/getcrshome bin/gnsd bin/crsdiag.pl"
for file in $ALL_DBEXES
do
if [ -f "$OH/$file" ]; then
   $CHMOD 755 $OH/$file
fi
done

c)  Saves configuration  values in $ORACLE_HOME/install/params.ora consumed by postpatch.sh later.

PARAMFILE=$OH/install/params.ora

$RMF $PARAMFILE

$ECHO ORACLE_HOME=$ORACLE_HOME >> $PARAMFILE
$ECHO ORACLE_BASE=$ORACLE_BASE >> $PARAMFILE
$ECHO s_OracleHome=$ORACLE_HOME >> $PARAMFILE
[oracle@oemnode1 scripts]$ cat $ORACLE_HOME/install/params.ora
ORACLE_HOME=/u01/app/oracle/Product/18.0.0/dbhome_1
ORACLE_BASE=
s_OracleHome=/u01/app/oracle/Product/18.0.0/dbhome_1

What postpatch.sh really does ?

1) Part of the postpatch.sh script.

ALL_SCRIPTS="bin/srvctl bin/srvconfig bin/cluvfy"
ALL_DBEXES="bin/racgmain bin/racgeut bin/diskmon.bin bin/lsnodes bin/osdbagrp bin/rawutl srvm/admin/ractrans srvm/admin/getcrshome bin/gnsd bin/crsdiag.pl"
ALL_DBLIBS="lib/libhasgen11.$LEXT lib/libttsh11.$LEXT lib32/libttsh11.$LEXT lib32/libdbcfg11.$LEXT lib32/libhasgen11.$LEXT lib32/libocr11.$LEXT lib32/libocrb11.$LEXT lib32/libocrutl11.$LEXT lib32/libsrvm11.$LEXT lib32/libsrvmhas11.$LEXT lib32/libsrvmocr11.$LEXT lib32/libuini11.$LEXT lib/libclsra11.$LEXT lib/libdbcfg11.$LEXT lib/libocr11.$LEXT lib/libocrb11.$LEXT lib/libocrutl11.$LEXT lib/libuini11.$LEXT lib/librdjni11.$LEXT lib/libgns11.$LEXT lib/libgnsjni11.$LEXT lib/libagfw11.$LEXT"
...
..
.
ORA_ENV_FILE=$OH/install/params.ora
ORA_SCRIPT_FILE=$ALL_SCRIPTS

resetPerms()
{
  for i in $ORA_SCRIPT_FILE;
  do
     if [ -f "$OH/$i" ]; then
       $ECHO "Reapplying file permissions on $OH/$i"
       $CHMOD +x $OH/$i
     fi
  done
}
resetPerms2()
{
  for i in $ALL_DBEXES
  do
     if [ -f "$OH/$i" ]; then
       $ECHO "Reapplying file permissions on $OH/$i"
       $CHMOD +x $OH/$i
     fi
  done
}
resetPerms3()
{
  for i in $ALL_DBLIBS
  do
     if [ -f "$OH/$i" ]; then
       $ECHO "Reapplying file permissions on $OH/$i"
       $CHMOD +x $OH/$i
     fi
  done
}
..
.
ORA_ENV_FILE=$OH/install/params.ora
ORA_SCRIPT_FILE=$ALL_SCRIPTS

for i in $ORA_SCRIPT_FILE;
do
  SCRIPT_FILE=$OH/$i
  BASENAME=`$BNAME $SCRIPT_FILE`
  SBSNAME="$OH/crs/sbs/$BASENAME.sbs"

  if [ -f $SBSNAME ]; then
    $ECHO "Found uninstantiated $SBSNAME file, copying to $SCRIPT_FILE"
    $CP $SBSNAME $SCRIPT_FILE
  fi

  if [ -f $SCRIPT_FILE ];
  then
    ## Make sure that the file is really script file.
    $SH -n $SCRIPT_FILE > $NULL 2>&1
    STATUS1=$?
    LC_ALL=C $FILE $SCRIPT_FILE | $GREP -wi "text" > $NULL 2>&1
    STATUS2=$?
    if [ "$STATUS1" != "0" ] && [ "$STATUS2" != "0" ]; then
      $ECHO "Skipping non-text file $SCRIPT_FILE"
      continue
    fi

    $ECHO "Parsing file $SCRIPT_FILE"
    $CP $SCRIPT_FILE $SCRIPT_FILE.$
    for line in `$CAT $ORA_ENV_FILE.$`;
    do
            varName=`$ECHO $line | $AWK -F"=" '{ print $1 }'`
            varValue=`$ECHO $line | $AWK -F"=" '{ print $2 }'`
            varValue=`$ECHO "$varValue" | $SED -e 's|\/|\\\/|g'`

      $CAT $SCRIPT_FILE.$ | $SED -e s/%$varName%/$varValue/g > /tmp/$
      $RMF $SCRIPT_FILE.$
      $CP /tmp/$ $SCRIPT_FILE.$
    done

    $RMF /tmp/$

    if [ -s $SCRIPT_FILE.$ ];
    then
      $RMF $SCRIPT_FILE
      $CP $SCRIPT_FILE.$ $SCRIPT_FILE
    else
            $ECHO "Failed to parse the file $SCRIPT_FILE"
      $RMF $SCRIPT_FILE.$
      exit 1
    fi
    $RMF $SCRIPT_FILE.$;
  fi
done

$RMF $ORA_ENV_FILE.$

validateScriptFile

resetPerms

resetPerms2

## resetPerms3

$ECHO "Postpatch completed successfully"

exit 0

2)  Run postpatch.sh when patching 28864593.

[oracle@oemnode1 28864593]$ custom/scripts/postpatch.sh -dbhome $ORACLE_HOME
Reading /u01/app/oracle/Product/18.0.0/dbhome_1/install/params.ora..
Reading /u01/app/oracle/Product/18.0.0/dbhome_1/install/params.ora..
Found uninstantiated /u01/app/oracle/Product/18.0.0/dbhome_1/crs/sbs/srvctl.sbs file, copying to /u01/app/oracle/Product/18.0.0/dbhome_1/bin/srvctl
Parsing file /u01/app/oracle/Product/18.0.0/dbhome_1/bin/srvctl
Parsing file /u01/app/oracle/Product/18.0.0/dbhome_1/bin/srvconfig
Parsing file /u01/app/oracle/Product/18.0.0/dbhome_1/bin/cluvfy
Verifying file /u01/app/oracle/Product/18.0.0/dbhome_1/bin/srvctl
Verifying file /u01/app/oracle/Product/18.0.0/dbhome_1/bin/srvconfig
Verifying file /u01/app/oracle/Product/18.0.0/dbhome_1/bin/cluvfy
Reapplying file permissions on /u01/app/oracle/Product/18.0.0/dbhome_1/bin/srvctl
Reapplying file permissions on /u01/app/oracle/Product/18.0.0/dbhome_1/bin/srvconfig
Reapplying file permissions on /u01/app/oracle/Product/18.0.0/dbhome_1/bin/cluvfy
Reapplying file permissions on /u01/app/oracle/Product/18.0.0/dbhome_1/bin/diskmon.bin
Reapplying file permissions on /u01/app/oracle/Product/18.0.0/dbhome_1/bin/lsnodes
Reapplying file permissions on /u01/app/oracle/Product/18.0.0/dbhome_1/bin/osdbagrp
Reapplying file permissions on /u01/app/oracle/Product/18.0.0/dbhome_1/bin/rawutl
Reapplying file permissions on /u01/app/oracle/Product/18.0.0/dbhome_1/srvm/admin/ractrans
Reapplying file permissions on /u01/app/oracle/Product/18.0.0/dbhome_1/srvm/admin/getcrshome
Reapplying file permissions on /u01/app/oracle/Product/18.0.0/dbhome_1/bin/crsdiag.pl
Postpatch completed successfully

3) Running of postpatch.sh achieves.

a) Parsing and verifying the files in variable ALL_SCRIPTS=”bin/srvctl bin/srvconfig bin/cluvfy”
b) Reapplying permissions for files in variable ALL_SCRIPTS=”bin/srvctl bin/srvconfig bin/cluvfy”

ALL_SCRIPTS="bin/srvctl bin/srvconfig bin/cluvfy"
ORA_SCRIPT_FILE=$ALL_SCRIPTS
for i in $ORA_SCRIPT_FILE;
do
if [ -f "$OH/$i" ]; then
   $ECHO "Reapplying file permissions on $OH/$i"
   $CHMOD +x $OH/$i
fi
done

c) Reapplying permissions for files in variable ALL_DBEXES=”bin/racgmain bin/racgeut bin/diskmon.bin bin/lsnodes bin/osdbagrp bin/rawutl srvm/admin/ractrans srvm/admin/getcrshome bin/gnsd bin/crsdiag.pl”

for i in $ALL_DBEXES
do
if [ -f "$OH/$i" ]; then
   $ECHO "Reapplying file permissions on $OH/$i"
   $CHMOD +x $OH/$i
fi
done

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.