Back to the main page

Boot archive update for x86

It's important that Solaris on x86 architecture has boot archive files in good conditions.

Read more about booting on x86 platform here.

So what I do is update boot archive files through cronjob, say once per day. The below scripts also sends me email with list of all files and update result, like if some files are really changed, etc.

#set -x

# script updates boot archive list
# this has to be done every time there is change on system, like install new patch
# but this is usually forgoten, so I run this through cronjob
# =====================================================================

# Only the root user can update boot archive
if [ "`/usr/bin/id | /usr/bin/cut -c1-5`" != "uid=0" ] ; then
   echo "You must be the root user to run `basename $0`."
   exit 1

# variables
BOOTADM=`which bootadm`
MAILX=`which mailx`
CAT=`which cat`
RM=`which rm`

# JFYI generates list of boot archive files
# ===============================================
${BOOTADM} list-archive -v > /tmp/archive-list.$$

if [ "$?" -ne "0" ] ; then
        ${MAILX} -s "Cannot generate boot archive list on ${HOST} - check this manually" ${RECPT}
        exit 1

# update boot archive list
# =========================
${BOOTADM} update-archive -v > /tmp/update-archive-result.$$

if [ "$?" -ne "0" ] ; then
        ${MAILX} -s "Cannot update boot archive on ${HOST} - check this manually" ${RECPT}
        exit 1

# Insert text as first/second line in temp files
sed '1i\
Archive Boot List'  /tmp/archive-list.$$ > /tmp/archive-list1.$$ ; mv /tmp/archive-list1.$$ /tmp/archive-list.$$

sed '2i\
================ '  /tmp/archive-list.$$ > /tmp/archive-list1.$$ ; mv /tmp/archive-list1.$$ /tmp/archive-list.$$

# Insert dividing ++++++++++
sed '1i\
++++++++++++++++++++' /tmp/update-archive-result.$$ > /tmp/update-archive-result1.$$ ; \
mv /tmp/update-archive-result1.$$ /tmp/update-archive-result.$$

sed '2i\
Update Archive result' /tmp/update-archive-result.$$ > /tmp/update-archive-result1.$$ ; \
mv /tmp/update-archive-result1.$$ /tmp/update-archive-result.$$

sed '3i\
=============== ' /tmp/update-archive-result.$$ > /tmp/update-archive-result1.$$ ; \
mv /tmp/update-archive-result1.$$ /tmp/update-archive-result.$$

# merge 2 temp files in order to email them
# ==============================================
${CAT} /tmp/archive-list.$$ /tmp/update-archive-result.$$ > /tmp/emailfile.$$ || \
echo "Cannot merge 2 temp files about boot archive update"

# send email about successful update
# ===================================
${CAT} /tmp/emailfile.$$ | ${MAILX} -s "Update of boot archive on ${HOST} is successful" ${RECPT} || \
echo "Cannot send email about successful boot archive update"

# remove temp files
# =======================
${RM} /tmp/emailfile.$$ /tmp/archive-list.$$ /tmp/update-archive-result.$$ \
        || echo "Cannot remove temp file /tmp/emailfile.$$"

exit 0

Back to the main page