lx_distro_install.ksh revision 6e65f9af82fb77a1e8492623c41e483c87e1b19a
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "%Z%%M% %I% %E% SMI"
#
# This script is called from /usr/lib/brand/lx/lx_install.
#
# options passed down from lx_install:
# -z $ZONENAME
# -r $LINUX_ROOT
#
# options passed down from zoneadm -z <zone-name> install
# -d <Linux-archives-dir>
# [core | server | desktop | development | all]
#
# The desktop cluster will be installed by default.
#
#
#
export PATH
#
# Setup i18n output
#
TEXTDOMAIN="SUNW_OST_OSCMD"
export TEXTDOMAIN
#
# Log passed arguments to file descriptor 2
#
log()
{
}
#
# Send the provided printf()-style arguments to the screen and to the
# logfile.
#
{
typeset fmt="$1"
shift
}
#
# Print and log provided text if the shell variable "verbose_mode" is set
#
verbose()
{
[[ -n $verbose_mode ]] && echo "$@"
}
#
# Get the device underlying a specified mounted file system
#
# Returns 0 on success, 1 on failure.
#
{
typeset mount_dir="$1"
typeset device
unset mount_dev
unset mount_dev
return 1
}
#
# Get the directory name a specified device is mounted as
#
# Returns 0 on success, 1 on failre.
#
{
typeset mount_dev="$1"
typeset dir
unset mount_dir
unset mount_dir
return 1
}
#
# Check the free disk space of the passed filesystem against the passed
# argument.
#
# Returns 0 on success, 1 on failure.
#
{
typeset dir="$1"
typeset mb_required=$2
#
# Return free space in partition containing passed argument in MB
#
screenlog "$mb_req" "$mb_required" "$mb_free"
return 1
fi
return 0
}
#
# Expand passed RPM names to their appropriate filenames in the passed RPM
# directory.
#
# Arguments:
#
# Arguments [2 - n]: RPM names to process
#
# The expanded RPM names are returned in the shell array "rpm_names."
#
# For example:
#
#
# would return something like:
#
# rpms_found[0]: dev-3.3.12.3-1.centos.0.i386.rpm
# rpms_found[1]: kernel-2.4.21-32.EL.i586.rpm
# rpms_found[2]: tetex-1.0.7-67.7.i386.rpm
# rpms_found[3]: redhat-menus-0.39-1.noarch.rpm
#
# The routine returns 0 on success, 1 on an error.
#
{
typeset found=0
typeset left=0
typeset rpmdir="$1/$distro_rpmdir"
typeset arch
typeset procinfo
typeset rpmglob
typeset rpmfile
unset rpms_found
unset rpms_left
shift
cd "$rpmdir"
cd "$curdir"
return 1
fi
#
# If the miniroot is booted, and the archs list isn't already set,
# ask the zone's rpm command for the list of compatible architectures.
#
if [[ -n $miniroot_booted && -z $archs ]]; then
[[ $? -eq 0 ]] &&
[[ -n $archs ]] &&
fi
#
# Either the miniroot isn't booted or asking rpm for the information
# failed for some reason, so make some reasonable assumptions.
#
if [[ -z $archs ]]; then
#
# Check for AMD athlon compatibility. The decision to
# have athlon files checked for before i686 files is
# what Linux does.
#
archs="athlon i686"
fi
#
# Check for i686 compatibility
#
archs="i686"
fi
fi
fi
if [[ $# -eq 1 ]]; then
else
screenlog "$expand_nrpms" "$#"
fi
#
# Search for the appropriate RPM package, using the compatible
# architecture list contained in "archs" to look for the best
# match.
#
# For example, if the processor is an i686, and the rpm is
# "glibc", the script will look for the files (in order):
#
# glibc[.-][0-9]*.i686.rpm
# glibc[.-][0-9]*.i586.rpm
# glibc[.-][0-9]*.i486.rpm
# glibc[.-][0-9]*.i386.rpm
# glibc[.-][0-9]*.noarch.rpm
# glibc[.-][0-9]*.fat.rpm
#
# and will stop when it finds the first match.
#
# TODO: Once the miniroot is booted, we should verify that
# the rpm name has been expanded to "$rpmfile" properly
# by comparing "$rpm" and the output of:
#
#
unset rpmfile
done
if [[ -z $rpmfile ]]; then
else
fi
done
cd "$curdir"
return 0
}
#
# Build the rpm lists used to install a machine.
#
# The first argument is the number of discs in the distribution. The
# second, optional, argument is the metacluster to install.
#
# The array "distro_rpm[]" is built from the individual package RPM arrays
# read in from an individual distribution definition file.
#
{
# Default to a desktop installation
typeset cnt=0
typeset pkgs
break;;
*) screenlog "$unknown_clust" "$clust"
exit $ZONE_SUBPROC_USAGE ;;
esac
done
exit $ZONE_SUBPROC_USAGE
fi
esac
# The RPMs in the miniroot must all be installed properly as well
}
#
# Install the "miniroot" minimal Linux environment that is booted single-user
# to complete the install.
#
# This works by doing feeding the RPM list needed for the installation one
# by one to rpm2cpio(1).
#
# Usage:
# install_miniroot <mounted media dir> <RPMS to install>
#
#
{
typeset mediadir="$1"
typeset rpm
shift
"\n \"$zoneroot\"..."
if [[ $? -ne 0 ]]; then
return 1
fi
done
return 0
}
#
# Install the zone from the mounted disc image by feeding a list of RPMs to
# install from this image to RPM running on the zone via zlogin(1).
#
# Usage:
#
# If the caller doesn't supply a list of RPMs to install, we install any
# we previously stashed away in the deferred RPMs directory.
#
{
#
# convert media directory to zone-relative path
#
typeset zonerpmdir=${1##$rootdir}/$distro_rpmdir
typeset defdir=$rootdir/var/lx_install/deferred_rpms
typeset rpmdir=$2
typeset rpmopts="-i"
typeset rpmerr
typeset deferred_found
typeset install_rpms
shift; shift
[[ -n $verbose_mode ]] && rpmopts="-ivh"
#
# If the caller provided a list of RPMs, determine which of them
# should be installed now, and which should be deferred until
# later.
#
if [[ $# -gt 0 ]]; then
if [[ -n $deferred_rpms ]]; then
return 1
fi
deferred_found="${rpms_found[@]}"
else
fi
install_rpms="$@"
#
# If this distro has any deferred RPMs, we want to simply
# copy them into the zone instead of installing them. We
# then remove them from the list of RPMs to be installed on
# this pass.
#
for rpm in $deferred_found; do
if echo $install_rpms | grep $rpm > /dev/null; then
if ! cp $rpmdir/$distro_rpmdir/$rpm $defdir; then
return 1
fi
fi
done
elif [[ -z $deferred_saved ]]; then
# There are no deferred RPMs to install, so we're done.
return 0
else
install_rpms=${deferred_saved[@]}
fi
#
# There's a quirk in our version of ksh that sometimes resets the
# trap handler for the shell. Since the rpm command will be the
# longest part of any given install, make sure that an interrupt while
# the command is running will bring the miniroot down and clean up
# the interrupted install.
#
trap trap_cleanup INT
#
# Print a message depending on how many RPMS we have to install.
#
# Ten RPMS seems like a reasonable boundary between when an install may
# take a "few" or "several" minutes.
#
if [[ $# -eq 0 ]]; then
elif [[ $# -eq 1 ]]; then
elif [[ $# -lt 10 ]]; then
screenlog "$install_nrpms_few" "$#"
else
screenlog "$install_nrpms_several" "$#"
fi
log ""
log "Installing: $install_rpms"
log ""
echo
#
# LX_INSTALL must be defined when running this command in order to
# enable switches built into various emulated system calls to allow
# the dev package (which may not actually write to /dev) to function.
#
rpmerr=$?
log ""
log ""
return 1
fi
return 0
}
#
# Attempt to unmount all file systems passed on the command line
#
# Returns 0 if all umounts succeeded, otherwise the number of umount failures
#
{
typeset failures=0
typeset mounted
unset umount_failures
fi
done
return $failures
}
#
# Set up lofi mounts required for chroot(1M) to work on a new root directory
# located in /a within a zone.
#
{
typeset dev
typeset mounted
typeset target
unset newroot_mounted
#
# /usr and /lib get lofs mounted in the zone on /native read-only
#
# the use of native devices.
#
unset newroot_mounted
return 1
fi
unset newroot_mounted
return 1
fi
#
# This is a bit ugly; to provide device access within the chrooted
# environment RPM will use for its install, we will create the same
# /dev in the new filesystem we're installing to.
#
do
return 1
fi
#
# If the device file is a symbolic link, create a new link
# in the target directory with the same source.
#
# If the device file is any other file or directory, lofs
# mount it from the device directory into the target directory.
#
if [[ -h $dev ]]; then
#
# Remove extraneous text from the output of file(1) so
# we're left only with the target path of the symbolic
# link.
#
source="${source##*link to }"
unset newroot_mounted
return 1
fi
else
screenlog "$lofs_failed" "$dev" "$target"
unset newroot_mounted
return 1
fi
fi
done
return 0
}
#
# Replace the root directory of a zone with the duplicate previously created
# in the zone's /a directory.
#
{
#
# The zoneadm halt will automatically unmount any file systems
# mounted via lofs in the zone, so that saves us from having to
# methodically unmount each one.
#
return 1
fi
unset miniroot_booted
unset newroot_mounted
#
# Copy the logfile or we'll lose all details of the install into the
# new root directory, so strip "$zoneroot" off the pathname of the
# current logfile and use it to generate the pathname of the log file
# in the new root directory.
#
'Completing install processing; this may take a few minutes')"
#
# Remove the contents of the /dev directory created by the install.
#
# We don't technically need to do this, but the zone infrastructure
# contents so we may as well clean up after ourselves.
#
# The extra checks are some basic paranoia due to the potentially
# dangerous nature of this command but are not intended to catch all
# malicious cases
#
return 0
}
{
unset miniroot_booted
return 1
fi
if ! copy_miniroot; then
return 1
fi
#
# zoneadm gets upset if the zone root directory is group or world
# readable or executable, so make sure it isn't before proceeding.
#
return 1
fi
#
# Now that the miniroot is booted, unset the compatible architecture
# list that expand_rpm_names was using for the miniroot so that it will
# get the list from rpm for the full install.
#
unset archs
#
# Mount all the filesystems needed to install the new root
# directory.
#
if ! newroot_lofimnt; then
if [[ -n $newroot_mounted ]]; then
unset newroot_mounted
fi
return 1
fi
#
# Attempt to initialize the RPM database for the new zone
#
return 1
fi
return 0
}
{
#
# Perform some last cleanup tasks on the newly installed zone.
#
# Note that the zlogin commands aren't checked for errors, as the
# newly installed zone will still boot even if the commands fail.
#
typeset file
typeset defdir=$rootdir/var/lx_install/deferred_rpms
if [[ -d $defdir ]]; then
fi
#
# Run ldconfig in the new root
#
/sbin/ldconfig -f /etc/ld.so.conf
#
# exist
#
#
# Make sure all init.d and rc[0-6].d links are set up properly.
#
done
return 1
fi
return 0
}
#
# Duplicate the installed "miniroot" image in a subdirectory of the base
# directory of the zone.
#
# This is done so that a new root directory can be created that will be used
# as the root of a chrooted directory that RPM running on the zone will install
# into.
#
{
#
# Create the directory $zoneroot/a if it doesn't already exist
#
#
# lxsave_ files.
#
return 0
}
#
# Read the first four lines of the .discinfo file from the root of the passed
# disc directory (which should either be a mounted disc or ISO file.)
#
# The first four lines of the .discinfo file will be used to set appropriate
# shell variables on success:
#
# rd_line[0]: Disc Set Serial Number (sets rd_serial)
# rd_line[1]: Distribution Release Name (sets rd_release)
# rd_line[2]: Distribution Architecture (sets rd_arch)
# rd_line[3]: Disc Number in Distribution (sets rd_discnum)
#
# Returns 0 on success, 1 on failure.
#
{
typeset rd_file="$1/.discinfo"
#
# If the .discinfo file doesn't exist or isn't readable, return 1
#
typeset rd_line
unset rd_arch
unset rd_discnum
unset rd_release
unset rd_serial
typeset linenum=0
#
# If .discinfo architecture isn't "i386," fail here as
# we only support i386 distros at this time.
#
return 1
#
# We've successfully read the first four lines of .discinfo
# into $rd_line, so do the appropriate shell variable munging.
#
rd_release=${rd_line[1]}
#
# CentOS names their releases "final"
#
rd_release="CentOS [Disc Set $rd_serial]"
rd_discnum=${rd_line[3]}
return 0
fi
done < "$rd_file"
#
# The file didn't have at least four lines, so indicate the read
# failed.
#
return 1
}
#
# Mount a disc as reprsented by the passed device name
#
# mount (if vold is active) or directly (if vold is not active.)
#
# Returns 0 on success, 1 on failure, 2 if no disc was available
#
{
typeset device="$1"
typeset mount_err
unset mntdir
return 1
fi
#
# allow vold to handle disc mounting
#
# Have volcheck check for the appropriate disc every two
# seconds for ten seconds.
#
typeset mount_timeout=10
typeset mount_interval=2
volcheck -i $mount_interval -t $mount_timeout \
mount_err=$?
else
#
# Attempt to mount the disc manually
#
mount_err=$?
fi
unset mntdir
return 1
fi
return 0
}
#
# Eject the disc mounted on the passed directory name
#
# Returns 0 on success, 1 on failure.
#
{
typeset mount_dir="$1"
return 0
}
#
# Get a particular disc of a multi-disc set.
#
# This basically works by doing the following:
#
# 1) Mount the disc
# 2) Read the disc's .discinfo file to see which disc it is
# 3) If it's not the desired disc, eject it and ask the user to insert the
# disc we wanted.
#
# Returns 0 on success, 1 on failure.
#
{
typeset mntdev="$1"
typeset discnum="$2"
typeset enter
typeset mount_err
while :; do
while :; do
mount_err=$?
read enter && continue
return 1
fi
return 1
done
#
# Make sure that the mounted disc is disc $discnum.
#
# If it is, return to the caller, otherwise eject the
# disc and try again.
#
verbose "\nRemovable Disc \"$1\": Serial \"$rd_serial\""
verbose " Release \"$rd_release\" Disc #$rd_discnum\n"
read enter || return 1
done
}
#
# Find out which distro the mounted disc belongs to
#
# Do this by cycling through the distro directory and reading each distro
# file in turn looking for:
#
# 1) The number of discs in a distribution
# 2) The serial number of the distribution
# 3) The name of the distribution
#
# Based on this, we can determine based on the ISO files available which
# distributions, if any, we have a complete set of files to support.
#
# The function returns the supported isos in the array "iso_names."
#
{
typeset distro
unset distro_ndiscs
unset distro_file
unset release
for distro in $distro_files; do
return 0
done
return 1
}
#
# Install a zone from discs
#
# Depends on the following variables:
#
# $distro_ndiscs: Number of discs needed to fully install the distribution
#
# returns 0 on success, 1 on failure
#
{
typeset status=0
typeset discnum=1
typeset mountdev="$1"
typeset discorder
typeset retval
#
# Ask for the first disc.
#
# We don't know which distro this may be yet, so we can't ask for
# the first disc in the install order, so we'll just have to ask for
# disc 1.
#
screenlog "$mini_discfail" "$zonename" "1"
return 1
fi
echo
return 1
fi
check_mbfree $zoneroot $distro_mb_required || return 1
echo
echo "\"$rd_release\"\n"
#
# Calculate the proper order for the install discs.
#
# distro_discorder is an array that indicates each disc's place
# in the overall installation process. An array of [4 1 2 3]
# means that "Disk 1" is the 4th disk to be installed, "Disk
# 2" is the 1st disk to be installed, and so on.
#
# Here we are converting that array into one that lists the
# CDs in the order in which they should be installed, such that a
# distro_discorder array of [4 1 2 3] would be converted into
# a discorder array of [2 3 4 1].
#
discorder[${distro_discorder[$discnum - 1]}]=$discnum
done
#
# If the disc that was read above isn't the first disc in the install
# order, eject it and ask for the appropriate disc.
#
screenlog "$mini_discfail" "$zonename" "${discorder[1]}"
return 1
fi
fi
log "Installing zone miniroot."
discnum=1
# Save a copy of $rpms_left. Other functions clobber it.
rpms_left_save="${rpms_left[@]}"
retval=0
if [[ -n $rpms_found ]]; then
"${discorder[$discnum]}..."
return 1
fi
fi
#
# If this is the first disc in the install order and we're
# done installing the miniroot, just exit the loop without
# ejecting the disk as we'll need it again to start the actual
# install.
#
unset zone_mounted
break
fi
unset zone_mounted
[[ -z $rpms_left_save ]] && break
distro_miniroot_rpms="${rpms_left_save[@]}"
"${discorder[$discnum]}"
return 1
fi
done
if [[ -n $rpms_left_save ]]; then
log ""
" ${rpms_left_save[@]}"
log ""
return 1
fi
if ! setup_miniroot; then
return 1
fi
discnum=1
#
# If the disc needed in the install order isn't the one in
# the drive, eject it and ask for the correct one.
#
"${discorder[$discnum]}"
return 1
fi
fi
# Save a copy of $rpms_left. Other functions clobber it.
rpms_left_save="${rpms_left[@]}"
retval=0
if [[ -n $rpms_found ]]; then
log ""
echo
${rpms_found[@]}; then
retval=1
fi
fi
unset zone_mounted
#
# Return non-zero now if the install_zone above failed.
#
#
# No more RPMs means we're done!
#
[[ -z $rpms_left_save ]] && break
distro_rpms="${rpms_left_save[@]}"
done
if [[ -n $deferred_rpms ]]; then
return 1
fi
fi
if [[ -n $rpms_left_save ]]; then
log ""
" ${rpms_left_save[@]}"
log ""
return 1
fi
return $?
}
#
# Find out which distros we have ISO files to support
#
# Do this by cycling through the distro directory and reading each distro
# file in turn looking for:
#
# 1) The number of discs in a distribution
# 2) The serial number of the distribution
# 3) The name of the distribution
#
# Based on this, we can determine based on the ISO files available which
# distributions, if any, we have a complete set of files to support.
#
# The function returns the supported isos in the array "iso_names."
#
{
typeset index
typeset iso_names
typeset iso_release
typeset serial
ndistros=0
unset iso_set
unset distro_file
unset distro_ndiscs
unset release
set -A iso_files "$@"
for distro in $distro_files; do
[[ ! -f $distro ]] && continue
index=0
unset iso_names
continue
fi
verbose " ISO \"$iso\": Serial \"$rd_serial\""
verbose " Release \"$rd_release\" Disc $rd_discnum"
continue
discnum=${distro_discorder[$rd_discnum - 1]}
else
discnum=${distro_discorder[$rd_discnum - 1]}
fi
done
[[ ${#iso_names[@]} -ne $distro_ndiscs ]] && continue
((${#iso_files[@]} == 0)) && break
done
}
#
# Do a lofi add for the passed filename and set lofi_dev to the lofi
#
# If the passed filename already has a lofi device name, simply set lofi_dir
# to the existing device name.
#
# Returns 0 on success, 1 on failure.
#
lofi_add()
{
typeset filename="$1"
return 1
}
#
# Delete the lofi device name passed in.
#
# Returns 0 on success, 1 on failure.
#
lofi_del()
{
typeset lofi_device="$1"
return $?
}
#
# Mount the lofi device name passed in.
#
# Set the variable mntdir to the directory on which the lofi device is
# mounted.
#
# Returns 0 on success, 1 on failure.
#
{
typeset created=0
typeset lofidev="$1"
typeset mntroot="$2"
#
# Check to see if the lofi device is already mounted and return
# the existing mount point if it is.
#
created=1
fi
verbose "FAILED."
return 1
fi
verbose "succeeded."
return 0
}
#
# Unmount the lofi device name passed in, and remove the device mount point
# after unmounting the device.
#
# Returns 0 on success, 1 on failure.
#
{
typeset mntdev="$1"
#
# If the directory name passed wasn't mounted to begin with,
# just return success.
#
verbose "FAILED."
return 1
fi
verbose "succeeded."
return 0
}
#
# Install a zone from mounted ISO files
#
# Argument: Array index of distribution to install
#
# Depends on the following variables:
#
# $iso_set[arg]: List of ISOs required to fully install the
# distribution
#
{
typeset distro=$1
typeset isonum=1
log "Installing zone miniroot."
"${distro_ndiscs[$distro]})"
# Save a copy of $rpms_left. Other functions clobber it.
rpms_left_save="${rpms_left[@]}"
if [[ -n $rpms_found ]]; then
screenlog "$mini_isofail" "$zonename" "$ldir"
return 1
fi
fi
[[ -z $rpms_left_save ]] && break
distro_miniroot_rpms="${rpms_left_save[@]}"
done
if [[ -n $rpms_left_save ]]; then
log ""
" ${rpms_left_save[@]}"
log ""
return 1
fi
if ! setup_miniroot; then
return 1
fi
screenlog "$mk_mntfail" "$rootdir/iso"
screenlog "FAILED."
return 1
fi
isonum=1
echo
return 1
fi
zone_mounted="$rootdir/iso"
# Save a copy of $rpms_left. Other functions clobber it.
rpms_left_save="${rpms_left[@]}"
if [[ -n $rpms_found ]]; then
${rpms_found[@]}; then
screenlog "$zone_isofail" "$zonename" "$iso"
return 1
fi
fi
screenlog "$iso_umntfail" "$name" "$zonename"
return 1
fi
unset zone_mounted
[[ -z $rpms_left_save ]] && break
distro_rpms="${rpms_left_save[@]}"
done
if [[ -n $deferred_rpms ]]; then
return 1
fi
fi
if [[ -n $rpms_left_save ]]; then
log ""
" ${rpms_left_save[@]}"
log ""
return 1
fi
return $?
}
#
# Mount the passed list of ISOs.
#
{
typeset count=1
typeset iso
typeset mntroot=$1
unset iso_filename
unset lofi_devs
unset lofi_mntdir
shift
else
fi
else
verbose " not a valid ISO image."
fi
done
}
{
typeset dev
done
}
#
# Select a distribution to install from the arguments passed and set
# "ndsitro" to the value chosen - 1 (so it may be used as an array index.)
#
# The routine will automatically return with ndisto set to 0 if only one
# argument is passed.
#
{
typeset dist
unset ndistro
if (($# > 1)); then
if [[ -n $silent_mode ]]; then
"directory but silent install"
log " mode specified. Distros available:"
done
return 1
fi
PS3="Select a distribution to install: "
[[ -z $distro ]] && continue
done
fi
#
# Covers both the cases of when only one distro name is passed
# to the routine as well as when an EOF is sent to the distribution
# selection prompt.
#
if [[ -z $dist ]]; then
screenlog "$install_dist" "$1"
ndistro=0
fi
return 0
}
#
# Install a zone using the list of ISO files passed as arguments to this
# function.
#
# Return 0 on success, 1 on failure.
#
{
typeset status=0
mount_isos "/tmp/lxisos" "$@"
if [[ -z ${lofi_mntdir[@]} ]]; then
log "No valid ISO images available or mountable."
[[ -n ${lofi_devs[@]} ]] && umount_isos "${lofi_devs[@]}"
return 1
fi
get_iso_distros "${lofi_mntdir[@]}"
if [[ -z ${release[@]} ]]; then
log "No valid Linux distributions found."
[[ -n ${lofi_devs[@]} ]] && umount_isos "${lofi_devs[@]}"
return 1
fi
. ${distro_file[$ndistro]} > /dev/null
check_mbfree $zoneroot $distro_mb_required || return 1
status=$?
umount_isos "${lofi_devs[@]}"
return $status
}
#
# Clean up on interrupt
#
{
cd "$cwd"
unset miniroot_booted && unset newroot_mounted
if [[ -n $zone_mounted ]]; then
else
fi
unset zone_mounted
fi
if [[ -n $newroot_mounted ]]; then
unset newroot_mounted
fi
[[ ${#lofi_devs[@]} -ne 0 ]] && umount_isos "${lofi_devs[@]}"
exit $ZONE_SUBPROC_FATAL
}
#
# Start of main script
#
distro_dir="$cwd/distros"
unset distro_path
unset logfile
unset newroot_mounted
unset silent_mode
unset verbose_mode
unset zone_mounted
unset zoneroot
unset zonename
unset deferred_saved
#
#
# ZONE_SUBPROC_OK
# ===============
# Installation was successful
#
# ZONE_SUBPROC_USAGE
# ==================
# Improper arguments were passed, so print a usage message before exiting
#
# ZONE_SUBPROC_NOTCOMPLETE
# ========================
# Installation did not complete, but another installation attempt can be
# made without an uninstall
#
# ZONE_SUBPROC_FATAL
# ==================
# Installation failed and an uninstall will be required before another
# install can be attempted
#
#
# Process and set up various global option variables:
#
# distro_path - Path containing files that make up the distribution
# (e.g. a directory containing ISO files or a disc device)
# logfile - Name (if any) of the install log file
# zoneroot - Root directory for the zone to install
# zonename - Name of the zone to install
#
s) silent_mode=1; unset verbose_mode;;
v) verbose_mode=1; unset silent_mode;;
x) set -x;;
esac
done
shift OPTIND-1
install_packages="$@"
[[ -n $silent_mode ]] && exec 1>/dev/null
if [[ -z $zonename ]]; then
echo
fi
if [[ -z $zoneroot ]]; then
echo
fi
#
# Make sure the specified zone root directory exists
#
echo
fi
#
# Make sure the specified zone root subdirectory exists
#
echo
fi
#
# Redirect stderr to the log file if it is specified and is writable
#
if [[ -n $logfile ]]; then
fi
exec 2>>"$logfile"
log "Installing from path \"$distro_path\""
else
[[ -n $silent_mode ]] && exec 2>/dev/null
fi
#
# From this point on, call trap_cleanup() on interrupt (^C)
#
trap trap_cleanup INT
#
# If the distribution path starts with "/cdrom/" assume the install will be
# done from discs, otherwise assume the path is a directory containing ISO
# images.
#
if [[ -n $silent_mode ]]; then
'ERROR: Cannot install from discs in silent mode.')"
echo
return 1
fi
pgrep vold > /dev/null 2>&1 && vold_present=1
if [[ $vold_present -eq 1 && ! -d /cdrom ]]; then
echo
fi
verbose " Attempting disc-based install via path:"
verbose " \"$distro_path\""
else
typeset dir_start
echo
fi
verbose " Attempting ISO-based install from directory:"
verbose " \"$distro_path\""
iso_files=$(find $distro_path -type f -print)
fi
if [[ $? -ne 0 ]]; then
cd "$cwd"
unset miniroot_booted && unset newroot_mounted
if [[ -n $zone_mounted ]]; then
else
fi
unset zone_mounted
fi
if [[ -n $newroot_mounted ]]; then
unset newroot_mounted
fi
"FAILED."
#
# The extra checks are some basic paranoia due to the potentially
# dangerous nature of these commands but are not intended to catch all
# malicious cases.
#
exit $ZONE_SUBPROC_FATAL
fi
log ""
exit $ZONE_SUBPROC_OK