#
# 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
#
#
#
m_usage=$(gettext "solaris10 brand usage:\n\tinstall -u | -p [-v | -s] -a archive | -d directory [-c sysidcfg].\n\tThe -a archive option specifies an archive name which can be a flar,\n\ttar, pax or cpio archive.\n\tThe -d directory option specifies an existing directory.\n\tThe -u option unconfigures the zone, -p preserves the configuration.\n\tThe -c option gives a sysidcfg file and causes an unconfiguration of the zone.")
# Clean up on interrupt
}
# If the install failed then clean up the ZFS datasets we created.
# trap_cleanup calls trap_exit. Do not run trap_exit twice.
# umount any mounted file systems
#
# If cleanup completed, don't force the use of zoneadm
# uninstall, as it will have no work to do.
#
fi
fi
vlog "Exiting with exit code $EXIT_CODE"
exit $EXIT_CODE
}
#
# The main body of the script starts here.
#
# This script should never be called directly by a user but rather should
# only be called by zoneadm to install a s10 system image into a zone.
#
# If we weren't passed at least two arguments, exit now.
typeset zone
eval $(bind_legacy_zone_globals zone)
shift; shift # remove ZONENAME and ZONEPATH from arguments array
# Clear the child dataset list - solaris10 should not create them.
set -A zone.new_be_datasets
#
# Exit code to return if install is interrupted or exit code is otherwise
# unspecified.
#
unset inst_type
unset msg
unset silent_mode
unset OPT_V
unset OPT_C
#
# It is worth noting here that we require the end user to pick one of
# -u (sys-unconfig) or -p (preserve config). This is because we can't
# really know in advance which option makes a better default. Forcing
# the user to pick one or the other means that they will consider their
# choice and hopefully not be surprised or disappointed with the result.
#
unset unconfig_zone
unset preserve_zone
unset SANITY_SKIP
while getopts "a:c:d:Fpr:suv" opt
do
a)
if [[ -n "$inst_type" ]]; then
fi
inst_type="archive"
;;
d)
if [[ -n "$inst_type" ]]; then
fi
inst_type="directory"
;;
F) SANITY_SKIP=1;;
p) preserve_zone="-p";;
r)
if [[ -n "$inst_type" ]]; then
fi
inst_type="stdin"
;;
s) silent_mode=1;;
u) unconfig_zone="-u";;
v) OPT_V="-v";;
exit $ZONE_SUBPROC_USAGE;;
esac
done
shift OPTIND-1
# The install can't be both verbose AND silent...
if [[ -n $silent_mode && -n $OPT_V ]]; then
fi
if [[ -z $install_media ]]; then
fi
# The install can't both preserve and unconfigure
if [[ -n $unconfig_zone && -n $preserve_zone ]]; then
fi
# Must pick one or the other.
if [[ -z $unconfig_zone && -z $preserve_zone ]]; then
fi
#
# From here on out, an unspecified exit or interrupt should exit with
# ZONE_SUBPROC_FATAL, meaning a user will need to do an uninstall before
# attempting another install, as we've modified the directories we were going
# to install to in some way. Note, however, that this is influenced by
# pin_datasets() and trap_exit().
#
trap trap_cleanup INT
vlog "Starting pre-installation tasks."
#
# Run p2v.
#
# Getting the output to the right places is a little tricky because what
# we want is for p2v to output in the same way the installer does: verbose
# messages to the log file always, and verbose messages printed to the
# user if the user passes -v. This rules out simple redirection. And
# we can't use tee or other tricks because they cause us to lose the
# return value from the p2v script due to the way shell pipelines work.
#
# The simplest way to do this seems to be to hand off the management of
# the log file to the p2v script. So we run p2v with -l to tell it where
# to find the log file and then reopen the log (O_APPEND) when p2v is done.
#
p2v_result=$?
else
log "\n$install_fail"
log "$install_log" "$LOGFILE"
exit $ZONE_SUBPROC_FATAL
fi
# Add a service tag for this zone.
log "\n$install_good" "${zone.name}"
trap - EXIT
# This needs to be set since the exit trap handler is going run.
exit $ZONE_SUBPROC_OK