Listing 1 Create jumpstart server
#!/bin/sh
###########################################################################
##
## create-js-server
##
## Copyright (c) 2002 arr@oceanwave.com
## All rights reserved.
##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following conditions
## are met:
##
## 1. Redistributions of source code must retain the above copyright
## notice, this list of conditions and the following disclaimer.
## 2. Redistributions in binary form must reproduce the above copyright
## notice, this list of conditions and the following disclaimer in the
## documentation and/or other materials provided with the distribution.
## 3. The name of the author may not be used to endorse or promote products
## derived from this software without specific prior written permission.
##
## THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR
## IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
## OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
## IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
## INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
## NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
## THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
##
###########################################################################
###########################################################################
#
# This script creates a jumpstart image from the Solaris Software CDs 1 of 2
# and 2 of 2 ISO images and copies over the default sysidcfg file from the
# existing Solaris 9 sysidcfg directory if none exists for the newly installed
# OS version.
#
# This script expects the ISO images of the Solaris Software CDs 1 of 2 and 2
# of 2 to be located in a single directory in either zipped or unzipped
# format.
#
# This script requires two arguments:
#
# * The name of the first ISO image, e.g. sol-9-u5-sparc-v1.zip (or
# /full/path/to/sol-9-u5-sparc-v1.zip, if the images are not located in
# the current directory)
#
# * The full path to where the jumpstart image is to be installed,
# e.g. /install/data/cdrom/SunOS-5.9-sparc-12.03
#
###########################################################################
cdroot=/cdrom
s0=${cdroot}/s0
s1=${cdroot}/s1
lf1=/dev/lofi/1
lf2=/dev/lofi/2
sysidcfgdir=/install/jumpstart/sysidcfg
if [ "x$1" = x ]; then
echo "Usage: $0 <iso-image> /path/to/install/server"
exit 0
fi
if [ "x$2" = x ]; then
echo "Usage: $0 <iso-image> /path/to/install/server"
exit 0
fi
path=`dirname $1`
serverroot=$2
osver=`basename ${serverroot} | awk -F- '{print $1 "-" $2}'`
if [ "x${path}" = x. ]; then
echo "path not set"
path=`/usr/bin/pwd`
fi
zipimage=`basename $1 -v1.zip`
isoimage=`basename $1`
if [ "${isoimage}" != "${zipimage}" ]; then
imgname=`basename $1 -v1.zip`
cd ${path}
if [ -f "${path}/${imgname}-v1.zip" ] && [ -f ${imgname}-v2.zip ]; then
echo "Using zipped ISO images, unzipping ${imgname}-v1.zip... \c"
unzip ${imgname}-v1.zip 1> /dev/null
echo " ${imgname}-v2.zip"
unzip ${imgname}-v2.zip 1> /dev/null
echo
else
echo "Can not find both ${path}/${imgname} zip files, aborting."
exit 1
fi
else
imgname=`basename $1 -v1.iso`
fi
if [ "${imgname}" = "${isoimage}" ]; then
echo
echo "You specified ${isoimage}, an invalid ISO image name."
echo "Be sure to use the first disk image. It should end in \"-v1.iso\" \
or \"-v1.zip\"."
echo
exit 0
fi
if [ ! -f "${path}/${imgname}-v1.iso" ]; then
echo
echo "The file ${path}/${imgname}-v1.iso does not exist."
echo "Please choose a valid ISO image and try again."
echo
exit 0
elif [ ! -f "${path}/${imgname}-v2.iso" ]; then
echo "The file ${path}/${imgname}-v2.iso does not exist, aborting."
echo
exit 1
fi
echo "Creating s1 of the first ISO image."
echo
if [ ! -f ${path}/${imgname}-v1-s1.iso ]; then
string=`/usr/bin/dd if=${path}/${imgname}-v1.iso bs=512 count=1 2>/dev/null| \
od -D -j 452 -N 8`
startcyl=`echo ${string}| awk '{print $2}'`
sblock=`/usr/bin/expr ${startcyl} \* 640` # 640 == num blocks in cyl
size=`echo ${string}| awk '{print $3}'`
size=`/usr/bin/expr ${size} \+ 0`
/usr/bin/dd if=${path}/${imgname}-v1.iso of=${path}/${imgname}-v1-s1.iso \
bs=512 skip=${sblock} count=${size} 2>/dev/null
echo "Slice 1 image created."
else
echo
echo "${path}/${imgname}-v1-s1.iso"
echo "already exists, using that."
fi
echo "Mounting both images using lofiadm."
echo
/usr/sbin/lofiadm -a ${path}/${imgname}-v1.iso ${lf1}
/usr/sbin/lofiadm -a ${path}/${imgname}-v1-s1.iso ${lf2}
/usr/bin/mkdir -p ${s0} ${s1}
/sbin/mount -F hsfs -o ro ${lf1} ${s0}
/sbin/mount -F ufs -o ro ${lf2} ${s1}
echo "ISO images mounted, installing the server in:"
echo "${serverroot}"
echo
if [ -e ${serverroot} ]; then
echo "${serverroot} exists, moving to ${serverroot}.old"
mv ${serverroot} ${serverroot}.old
fi
/usr/bin/mkdir -p ${serverroot}
cd ${s0}
version=`/bin/ls -1|grep Solaris`
cd ${version}/Tools
./setup_install_server ${serverroot}
cd /
echo
echo "Installation of the first CDROM complete."
echo "Unmounting the ISO images of the first CDROM and mounting the second."
echo
/sbin/umount ${s0}
/sbin/umount ${s1}
/usr/sbin/lofiadm -d ${lf1}
/usr/sbin/lofiadm -d ${lf2}
if [ ! -f ${path}/${imgname}-v2.iso ]; then
echo "${path}/${imgname}-v2.iso does not exist, aborting!"
exit 0
fi
/usr/sbin/lofiadm -a ${path}/${imgname}-v2.iso ${lf1}
/sbin/mount -F hsfs -o ro ${lf1} ${s0}
cd ${s0}/${version}/Tools
./add_to_install_server ${serverroot}
cd /
echo "Installation of the second CDROM complete."
echo "Unmounting the ISO image of the second CDROM."
echo
/sbin/umount ${s0}
/usr/sbin/lofiadm -d ${lf1}
if [ ! -f ${sysidcfgdir}/${osver}/sysidcfg ]; then
echo "Copying over the sysidcfg file from"
echo "${sysidcfgdir}/SunOS-5.9 to"
echo "${sysidcfgdir}/${osver}/sysidcfg."
echo
/usr/bin/mkdir -p ${sysidcfgdir}/${osver}
/usr/bin/cp ${sysidcfgdir}/SunOS-5.9/sysidcfg ${sysidcfgdir}/${osver}/
else
echo "${sysidcfgdir}/${osver}/sysidcfg already exists, not overwriting."
echo
fi
echo "Jumpstart disk image installation complete"
if [ "x${zipimage}" != x ]; then
echo "Cleaning up unzipped ISO images."
rm ${path}/${imgname}-v1.iso ${path}/${imgname}-v1-s1.iso \
${path}/${imgname}-v2.iso
fi
|