You can create a finish script to automatically add packages or patches after the Solaris software is installed on a system. By adding packages with a finish script, you reduce time and ensure consistency in which packages and patches are installed on different systems at your site.
When you use the pkgadd(1M) or patchadd(1M) commands in finish scripts, use the -R option to specify /a as the root path.
Example 4–3 shows an example of a finish script that adds packages.
Example 4–4 shows an example of a finish script that adds patches.
#!/bin/sh BASE=/a MNT=/a/mnt ADMIN_FILE=/a/tmp/admin mkdir ${MNT} mount -f nfs sherlock:/export/package ${MNT} cat >${ADMIN_FILE} <<DONT_ASK mail=root instance=overwrite partial=nocheck runlevel=nocheck idepend=nocheck rdepend=nocheck space=ask setuid=nocheck conflict=nocheck action=nocheck basedir=default DONT_ASK /usr/sbin/pkgadd -a ${ADMIN_FILE} -d ${MNT} -R ${BASE} SUNWxyz umount ${MNT} rmdir ${MNT} |
The following describes some commands for this example.
The following command mounts a directory on a server that contains the package to install.
mount -f nfs sherlock:/export/package ${MNT} |
The following command creates a temporary package administration file, admin, to force the pkgadd(1M) command not to perform checks or prompt for questions when installing a package. Use the temporary package administration file to maintain a hands-off installation when you are adding packages.
cat >${ADMIN_FILE} <<DONT_ASK |
The following pkgadd command adds the package by using the -a option, specifying the package administration file, and the -R option, specifying the root path.
/usr/sbin/pkgadd -a ${ADMIN_FILE} -d ${MNT} -R ${BASE} SUNWxyz |
#!/bin/sh ######## # # USER-CONFIGURABLE OPTIONS # ######## # The location of the patches to add to the system after it's installed. # The OS rev (5.x) and the architecture (`mach`) will be added to the # root. For example, /foo on a 8 SPARC would turn into /foo/5.8/sparc LUPATCHHOST=ins3525-svr LUPATCHPATHROOT=/export/solaris/patchdb ######### # # NO USER-SERVICEABLE PARTS PAST THIS POINT # ######### BASEDIR=/a # Figure out the source and target OS versions echo Determining OS revisions... SRCREV=`uname -r` echo Source $SRCREV LUPATCHPATH=$LUPATCHPATHROOT/$SRCREV/`mach` # # Add the patches needed # echo Adding OS patches mount $LUPATCHHOST:$LUPATCHPATH /mnt >/dev/null 2>&1 if [ $? = 0 ] ; then for patch in `cat /mnt/*Recommended/patch_order` ; do (cd /mnt/*Recommended/$patch ; echo yes | patchadd -u -d -R $BASEDIR .) done cd /tmp umount /mnt else echo "No patches found" if |
In the past, the chroot(1M) command was used with the pkgadd and patchadd commands in the finish script environment. In rare instances, some packages or patches do not work with the -R option. You must create a dummy /etc/mnttab file in the /a root path before issuing the chroot command.
To create a dummy /etc/mnttab file, add the following line to your finish script:
cp /etc/mnttab /a/etc/mnttab