Solaris patch backout script

Here is the back out script. It is NOT Sun Supported. Customer needs to
use it at his own risk.

#! /bin/sh
# This is just an example on how to remove all the patches
# applied in a Recommended Patch Cluster.

LOGFILE=/var/sadm/install_data/cluster_remove.log

echo
echo
echo
echo " ————————————————-"
echo " RUN THIS SCRIPT AS ROOT IN SINGLEUSER MODE"
echo " This script is compatible with Solaris 2.6 and higher."
echo
echo " The remove_cluster script will remove patches automatically"
echo " using any patch_order file which must exist in the"
echo " same directory where the script resides."
echo " The patch_order file can be copied from the last installed
echo " patch cluster or it can be created manually. It needs to be
echo " in a XXXXXX-YY format (one entry per line)."
echo
echo " The patches will be removed in a reverse order"
echo " (patch listed on the bottom of the patch_order file"
echo " will be removed first)."
echo " You might see some errors, as most likely not all of the patches"
echo " in the cluster were applied to your machine."
echo
echo " This process will be logged to: ${LOGFILE}"
echo
echo "Hit C to abort or RETURN to continue"
read response
#####
# Reverse patch_order file
#####

patchlist=`awk ‘{ line[NR] = $0 } END { for (i=NR; i>0; i=i-1)\
print line[i] }’ ./patch_order`
#####
# Remove them
#####
echo "" >> ${LOGFILE}
echo "" >> ${LOGFILE}
echo "*** Removal begins `date` ***" >> ${LOGFILE}
echo "Removing patches in reverse order from the patch_order file" | tee
-a ${LOGFILE}
echo "" >> ${LOGFILE}
###########
for patch in ${patchlist} ; do
echo "Removing ${patch}…" | tee -a ${LOGFILE}
( /usr/sbin/patchrm ${patch} ) >> ${LOGFILE} 2>&1
result=$?
if [ ${result} -ne 0 ]; then
echo " Removal of ${patch} failed. Return code
${result}." | tee -a ${LOGFILE}
fi
done
echo "***** remove_cluster script finished on `date` ******" | tee -a
${LOGFILE}
exit 0

Leave a Reply

Your email address will not be published. Required fields are marked *