JumpStart finish script for patch installation

From: Allen Belk (allen.belk@usm.edu)
Date: Thu Jul 11 2002 - 14:46:29 EDT


Managers,
    The following script was taken from the CD included with the Sun
Blueprints book "JumpStart Technoloy", which I highly recommend to anyone
just starting out with Solaris and JumpStart. With a few modifications to
adapt to my custom invironment (different PATCH_DIR), the script works
perfectly using the patchadd command to install the patches. Unfortunately,
the script uses the -d option with the patchadd command with prevents the
backing out of patches. If I remove the -d option to cause patchadd to
backup the patched files so I can remove them at a later date, if need be,
the patchadd command starts complaining about a mount point for
/var/sadm/pkg.

Checking installed patches...
Verifying sufficient filesystem capacity (dry run method)...
df: Could not find mount point for /var/sadm/pkg
Insufficient space in /var/sadm/pkg to save old files.

I am not familiar with the way chroot works and honestly the whole concept
is hard for me to wrap my brain around. If any of you out there can make
since of this and can suggest a way of making the patches reversible with
this script, or another if you have one, I would greatly appreciate your
help.

#!/bin/sh
#
#ident "@(#)install-recommended-patches.fin 1.6 00/10/19 SMI"
#
# This script is responsible for installing a Sun Recommended
# and Security Patch Cluster from ${BASEDIR}/${PATCH_DIR}.

errorCondition=0
mountedProc=0

BASEDIR="/a"
PATCH_SERV_DIR=""
PATCH_DIR="/mnt"
MNTTAB="${BASEDIR}/etc/mnttab"
OE_VER="`uname -r`"

mount -F nfs -o ro 192.168.1.1:/export/jumpstart ${BASEDIR}/${PATCH_DIR}

case ${OE_VER} in

   5.8)
      PATCH_SERV_DIR="Patches/8_Recommended"
      ;;

   5.7)
      PATCH_SERV_DIR="Patches/7_Recommended"
      ;;

   5.6)
      PATCH_SERV_DIR="Patches/2.6_Recommended"
      ;;

   5.5.1)
      PATCH_SERV_DIR="Patches/2.5.1_Recommended"
      ;;

   *)
      errorCondition=1
      ;;

esac

if [ ${errorCondition} = 0 ]; then
   if [ ! -d ${BASEDIR}/${PATCH_DIR} ]; then
      echo "The directory, ${PATCH_DIR}, does not exist."
   else

      # Some patches require a loopback filesystem be used when
      # installing using chroot.

      if [ -d /proc ]; then
         if [ "`df -n /proc | awk '{ print $3 }'`" = "proc" ]; then
            if [ -d ${BASEDIR}/proc ]; then
               if [ "`df -n ${BASEDIR}/proc | \
                  awk '{ print $3 }'`" != "proc" ]; then
                  mount -F lofs /proc ${BASEDIR}/proc
                  mountedProc=1
               fi
            fi
         fi
      fi

      if [ ! -s ${MNTTAB} ]; then
         if [ -s /etc/mnttab ]; then

            # First create ${MNTTAB} so patches can read it:

            echo "Copying /etc/mnttab from miniroot to ${MNTTAB}"
            echo ""

            rm -f ${MNTTAB}

            if [ "${OE_VER}" = "5.5.1" ]; then

               # This is necessary for "install_cluster" to get the mount
               # point for /var/sadm/patch from the "real" root filesystem.

               cat /etc/mnttab | sed 's/\/a/\//g' > ${MNTTAB}

               # This is necessary for "df" to execute which is needed by
               # "install_cluster" to determine if enough free disk
               # space exists on the target system.

               touch ${BASEDIR}/etc/.mnttab.lock
               chown root:root ${BASEDIR}/etc/.mnttab.lock
               chmod 644 ${BASEDIR}/etc/.mnttab.lock
            else
               cp /etc/mnttab ${MNTTAB}
            fi
         else
            echo "Could not find a valid /etc/mnttab"
            errorCondition=1
         fi
      fi

      if [ ${errorCondition} = 0 ]; then

         SHOWCOMMAND=""

         if [ -x ${BASEDIR}/usr/sbin/patchadd ]; then
            SHOWCOMMAND="/usr/sbin/patchadd"
         elif [ -x ${BASEDIR}/usr/bin/showrev ]; then
            SHOWCOMMAND="/usr/bin/showrev"
         fi

# if [ "${SHOWCOMMAND}" != "" ]; then
# echo "The following patches are currently installed:"
# echo ""
# chroot ${BASEDIR} ${SHOWCOMMAND} -p
# echo ""
# fi

         cd ${BASEDIR}/${PATCH_DIR}

         if [ -d ${PATCH_SERV_DIR} ]; then
            echo "Installing the ${PATCH_SERV_DIR} patch cluster."
            echo ""

            if [ "${SHOWCOMMAND}" = "/usr/sbin/patchadd" ]; then
               chroot ${BASEDIR} /usr/sbin/patchadd -u \
                  -M ${PATCH_DIR}/${PATCH_SERV_DIR} patch_order
            elif [ -x ${PATCH_DIR}/${PATCH_SERV_DIR}/install_cluster ]; then
               chroot ${BASEDIR} \
                  ${PATCH_DIR}/${PATCH_SERV_DIR}/install_cluster -q \
                  ${PATCH_DIR}/${PATCH_SERV_DIR}
            else
               echo "Cannot find /usr/sbin/patchadd or install_cluster"
            fi
         else
            echo "Could not find the ${PATCH_SERV_DIR} patch cluster"
         fi
      fi

      umount ${BASEDIR}/${PATCH_DIR}
      if [ ${mountedProc} = 1 ]; then
         umount ${BASEDIR}/proc
      fi
   fi
fi

Thanks,

Allen

 | Allen Belk, Systems Administrator III
 | University of Southern Mississippi
 | Office of Technology Resources
 | allen.belk@usm.edu - 601.266.5973
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers



This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 23:24:35 EDT