Friday, February 5, 2016

Solaris10: patching

I just wrote and haven't tested it. When I have time, I will test when I get a chance. Please feel free to use it test it and see if it works. I manually installed, tested and verified the Solaris 10 1st quartet (Q1) patch successfully. Based on that procedure, I prepare this note.

# cat patch_automate.sh
#!/usr/bin/bash
# Kamal Bhusal
# Last updated - Wed Jan 27 10:28:18 EST 2016
# Automate patching procedure for Solaris 10 zfs root
#

# Patch location
mkdir /var/tmp/patchlog
LOG_DIR="/var/tmp/patchlog"
cp -p /etc/hosts /etc/hosts.01252016
cp -p /etc/nsswitch.conf /etc/nsswitch.conf.01252016
cp -p /etc/mail/sendmail.cf /etc/mail/sendmail.cf.01252016
df -h >>$LOG_DIR/df.out
zfs list >>$LOG_DIR/myzfs.out
zpool list>> $LOG_DIR/zpool.list
zpool status >>$LOG_DIR/zpool.status
cat /etc/lu/ICF.1>>$LOG_DIR/ICF1.bk
cat /etc/lu/ICF.2>>$LOG_DIR/ICF2.bk

cd /var/adm; rm pacct.* auditlog.0 auditlog.1
cd /var/tmp; rm -fr DCE* SPX* TCP* US* RAW* NMP* net* ISPX* VI* BEQ* DEC* ITCP*
cd /var/audit; /usr/local/bin/purge_audit.sh; cd /

# Current Book Environment
C_BE=`df -h / | grep -v Filesystem | awk '{print $1}' | awk -F/ '{print $3}'`
# OLD_Boot_Env
O_BE=`/usr/sbin/lustatus | tail -2 | grep -v "$C_BE" | awk '{print $1}'`
# New Book env
N_BE="aBE01252016"

/usr/sbin/lustatus >> $LOG_DIR/lustatus.log
/usr/sbin/ludelete $O_BE
echo "" >> $LOG_DIR/lustatus.log
echo "---- After deleting old BE ----" >> $LOG_DIR/lustatus.log
echo ""
/usr/sbin/lustatus >> $LOG_DIR/lustatus.log

/usr/sbin/lucreate -n $N_BE
echo "---- After Creating a new BE ----" >> $LOG_DIR/lustatus.log
echo "" >> $LOG_DIR/lustatus.log
/usr/sbin/lustatus >> $LOG_DIR/lustatus.log

# Upload your patch to /data or choice of your directory location
# Now, extract the patch, change your patch dir
mkdir /var/tmp/patch; cd /var/tmp/patch
/usr/bin/unzip -qq /data/Sol_Patch/10_Recommended_06102015.zip
cd 10_Recommended_CPU_2016-01

# Mount your new BE
# mkdir /alt
/usr/sbin/lumount $N_BE /alt

# Apply OS patches to /alt.  Apply Pre-Req first and Patch cluster
echo "Please pay attention here to see if you get any error"
# ./installcluster --apply-prereq --s10patchset >/alt/opt/Patches/10_recommended.pre.out 2>&1 &
# ./installcluster --apply-prereq --s10patchset >/alt/opt/Patches/10_recommended.pre.out
./installcluster --apply-prereq --s10patchset

# Now, apply the Kernel patch.
echo " Patching on progress ..."
nohup ./installcluster -R /alt --s10patchset --disable-space-check > /alt/opt/Patches/10_Recommended.out 2>&1 &

# note: do not use --disable-space-check option if you don't have enough space.
# Verify currently installed patch
showrev -p -R /alt | grep 150400-30 >> $LOG_DIR/new_Patch.log

# Update the boot-archive
bootadm update-archive -R /alt

/usr/sbin/luumount $N_BE

/usr/sbin/luactivate $N_BE

sync;sync;sync
# findally reboot the server
# init 6

# For Jan, 2016 patch, following patches were applied

# cat /alt/opt/Patches/10_Recommended.out | grep -i success | awk '{print "#" $i}'
#Applying 119059-71 ( 33 of 397) ... success
#Applying 119213-32 ( 39 of 397) ... success
#Applying 119783-33 ( 73 of 397) ... success
#Applying 122911-35 (124 of 397) ... success
#Applying 125719-56 (165 of 397) ... success
#Applying 143506-11 (244 of 397) ... success
#Applying 145080-15 (274 of 397) ... success
#Applying 146288-03 (285 of 397) ... success
#Applying 147692-95 (300 of 397) ... success
#Applying 147693-95 (301 of 397) ... success
#Applying 148031-05 (310 of 397) ... success
#Applying 148071-19 (312 of 397) ... success
#Applying 148104-21 (313 of 397) ... success
#Applying 148241-05 (317 of 397) ... success
#Applying 148342-09 (320 of 397) ... success
#Applying 148559-16 (326 of 397) ... success
#Applying 150400-30 (347 of 397) ... success
#Applying 151721-01 (389 of 397) ... success
#Applying 151912-02 (391 of 397) ... success
#Applying 152076-11 (392 of 397) ... success
#Applying 152077-11 (393 of 397) ... success
#Applying 152248-01 (395 of 397) ... success
#Applying 152260-01 (397 of 397) ... success
#

No comments:

Post a Comment