From 758dc1c6bb91695ca624f99bd8939c66d1dd41d1 Mon Sep 17 00:00:00 2001 From: Peter Tribble Date: Thu, 22 Mar 2018 11:54:01 +0000 Subject: [PATCH] Remove broken legacy image_install and p2v --- install/depend | 1 + pkginfo | 2 +- usr/lib/brand/alien-root/config.xml | 4 +- usr/lib/brand/alien-root/image_install | 236 ------------ usr/lib/brand/alien-root/p2v | 490 ------------------------- usr/lib/brand/alien-root/pkgcreatezone | 51 +-- usr/lib/brand/whole-root/config.xml | 4 +- usr/lib/brand/whole-root/image_install | 236 ------------ usr/lib/brand/whole-root/p2v | 474 ------------------------ usr/lib/brand/whole-root/pkgcreatezone | 61 +-- usr/share/man/man5/alien-root.5 | 27 +- 11 files changed, 34 insertions(+), 1552 deletions(-) delete mode 100755 usr/lib/brand/alien-root/image_install delete mode 100755 usr/lib/brand/alien-root/p2v delete mode 100755 usr/lib/brand/whole-root/image_install delete mode 100755 usr/lib/brand/whole-root/p2v diff --git a/install/depend b/install/depend index f488168..6a4677b 100644 --- a/install/depend +++ b/install/depend @@ -1,2 +1,3 @@ +P TRIBarchiver-gnu-tar P TRIBtext-gnu-grep P TRIBtext-gnu-sed diff --git a/pkginfo b/pkginfo index d9852f7..d500489 100644 --- a/pkginfo +++ b/pkginfo @@ -1,6 +1,6 @@ PKG="TRIBblix-zones" NAME="Tribblix zone brands" -VERSION="0.19.0" +VERSION="0.20.0" ZAP_URL="https://github.com/tribblix/tribblix-zones" ARCH="i386,sparc" CATEGORY="application" diff --git a/usr/lib/brand/alien-root/config.xml b/usr/lib/brand/alien-root/config.xml index 8d80646..44a1db8 100644 --- a/usr/lib/brand/alien-root/config.xml +++ b/usr/lib/brand/alien-root/config.xml @@ -22,7 +22,7 @@ Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. - Copyright (c) 2015 Peter C. Tribble peter.tribble@gmail.com + Copyright (c) 2018 Peter C. Tribble peter.tribble@gmail.com DO NOT EDIT THIS FILE. --> @@ -39,7 +39,7 @@ /usr/bin/getent passwd %u /usr/lib/brand/alien-root/pkgcreatezone -z %z -R %R - a:d:i:o:hpsuv + i:o:h /usr/lib/brand/alien-root/prestate %z %R 2 0 diff --git a/usr/lib/brand/alien-root/image_install b/usr/lib/brand/alien-root/image_install deleted file mode 100755 index 7bf27b7..0000000 --- a/usr/lib/brand/alien-root/image_install +++ /dev/null @@ -1,236 +0,0 @@ -#!/bin/ksh -p -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -# -# image_install is used when installing a zone in a 'p2v' scenario. In -# this case the zone install hook will branch off to this script which -# is responsible for setting up the physical system image in the zonepath -# and performing the various modifications necessary to enable a physical -# system image to run inside a zone. This script sets up the image in the -# zonepath then calls the p2v script to modify the image to run in a zone. -# - -. /usr/lib/brand/tribblix-common/common.ksh - -m_usage=$(gettext "\n install {-a archive|-d path} {-p|-u} [-s|-v]") -install_log=$(gettext " Log File: %s") - -p2ving=$(gettext "Postprocessing: This may take a while...") -p2v_prog=$(gettext " Postprocess: ") -p2v_done=$(gettext " Result: Postprocessing complete.") -p2v_fail=$(gettext " Result: Postprocessing failed.") -m_postnote3=$(gettext " Make any other adjustments, such as disabling SMF services\n that are no longer needed.") - -media_missing=\ -$(gettext "%s: you must specify an installation source using '-a' or '-d'.") -cfgchoice_missing=\ -$(gettext "you must specify -u (sys-unconfig) or -p (preserve identity).") - -# Clean up on interrupt -trap_cleanup() -{ - msg=$(gettext "Installation cancelled due to interrupt.") - log "$msg" - - trap_exit -} - -# If the install failed then clean up the ZFS datasets we created. -trap_exit() -{ - # umount any mounted file systems - [[ -n "$fstmpfile" ]] && umnt_fs - - if (( $zone_is_mounted != 0 )); then - error "$v_unmount" - zoneadm -z $ZONENAME unmount - zone_is_mounted=0 - fi - - if (( $EXIT_CODE != $ZONE_SUBPROC_OK )); then - /usr/lib/brand/alien-root/uninstall $ZONENAME $ZONEPATH -F - fi - - 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 pkgcreatezone to install an OpenSolaris system image into -# a zone. -# - -# -# Exit code to return if install is interrupted or exit code is otherwise -# unspecified. -# -EXIT_CODE=$ZONE_SUBPROC_USAGE - -zone_is_mounted=0 -trap trap_cleanup INT -trap trap_exit EXIT - -# If we weren't passed at least two arguments, exit now. -(( $# < 2 )) && exit $ZONE_SUBPROC_USAGE - -ZONENAME="$1" -ZONEPATH="$2" -# XXX shared/common script currently uses lower case zonename & zonepath -zonename="$ZONENAME" -zonepath="$ZONEPATH" - -ZONEROOT="$ZONEPATH/root" - -shift; shift # remove zonename and zonepath from arguments array - -unset inst_type -unset msg -unset silent_mode -unset verbose_mode - -# -# 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 - -while getopts "a:d:psuv" opt -do - case "$opt" in - a) - if [[ -n "$inst_type" ]]; then - fatal "$both_kinds" "zoneadm install" - fi - inst_type="archive" - install_media="$OPTARG" - ;; - d) - if [[ -n "$inst_type" ]]; then - fatal "$both_kinds" "zoneadm install" - fi - inst_type="directory" - install_media="$OPTARG" - ;; - p) preserve_zone="-p";; - s) silent_mode=1;; - u) unconfig_zone="-u";; - v) verbose_mode="-v";; - *) exit $ZONE_SUBPROC_USAGE;; - esac -done -shift OPTIND-1 - -# The install can't be both verbose AND silent... -[[ -n $silent_mode && -n $verbose_mode ]] && \ - fatal "$f_incompat_options" "-s" "-v" - -[[ -z $install_media ]] && fatal "$media_missing" "zoneadm install" - -# The install can't both preserve and unconfigure -[[ -n $unconfig_zone && -n $preserve_zone ]] && \ - fatal "$f_incompat_options" "-u" "-p" - -# Must pick one or the other. -[[ -z $unconfig_zone && -z $preserve_zone ]] && fail_usage "$cfgchoice_missing" - -LOGFILE=$(/usr/bin/mktemp -t -p /var/tmp $ZONENAME.install_log.XXXXXX) -[[ -z "$LOGFILE" ]] && fatal "$e_tmpfile" -exec 2>>"$LOGFILE" -log "$install_log" "$LOGFILE" - -vlog "Starting pre-installation tasks." - -# -# From here on out, an unspecified exit or interrupt should exit with -# ZONE_SUBPROC_NOTCOMPLETE, 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. -# -EXIT_CODE=$ZONE_SUBPROC_NOTCOMPLETE - -# ZONEROOT was created by our caller (pkgcreatezone) - -vlog "Installation started for zone \"$ZONENAME\"" -install_image "$inst_type" "$install_media" - -# -# 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. -# -log "$p2ving" -vlog "running: p2v $verbose_mode $unconfig_zone $ZONENAME $ZONEPATH" -/usr/lib/brand/alien-root/p2v -l "$LOGFILE" $verbose_mode $unconfig_zone $ZONENAME \ - $ZONEPATH -p2v_result=$? -exec 2>>$LOGFILE - -if (( $p2v_result != 0 )); then - log "$p2v_fail" - log "" - log "$install_fail" - log "$install_log" "$LOGFILE" - exit $ZONE_SUBPROC_FATAL -fi -vlog "$p2v_done" - -zone_is_mounted=1 -zoneadm -z $ZONENAME mount -f || fatal "$e_badmount" - -safe_copy $LOGFILE $ZONEPATH/lu/a/var/log/$ZONENAME.install$$.log - -zoneadm -z $ZONENAME unmount || fatal "$e_badunmount" -zone_is_mounted=0 - -trap - EXIT -rm -f $LOGFILE - -# Mount active dataset on the root. -is_brand_labeled -(( $? == 0 )) && mount_active_ds - -log "" -log "$m_complete" ${SECONDS} -printf "$install_log\n" "$ZONEROOT/var/log/$ZONENAME.install$$.log" -printf "$m_postnote\n" -printf "$m_postnote2\n" -printf "$m_postnote3\n" - -exit $ZONE_SUBPROC_OK diff --git a/usr/lib/brand/alien-root/p2v b/usr/lib/brand/alien-root/p2v deleted file mode 100755 index 8cccbbe..0000000 --- a/usr/lib/brand/alien-root/p2v +++ /dev/null @@ -1,490 +0,0 @@ -#!/bin/ksh -p -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -# NOTE: this script runs in the global zone and touches the non-global -# zone, so care should be taken to validate any modifications so that they -# are safe. - -# Restrict executables to /usr/bin and /usr/sbin -PATH=/usr/bin:/usr/sbin -export PATH -unset LD_LIBRARY_PATH - -. /usr/lib/brand/tribblix-common/common.ksh - -LOGFILE= -EXIT_CODE=1 - -# Clean up on failure -trap_exit() -{ - if (( $ZONE_IS_MOUNTED != 0 )); then - error "$v_unmount" - zoneadm -z $ZONENAME unmount - fi - - exit $EXIT_CODE -} - -# -# For an exclusive stack zone, fix up the network configuration files. -# We need to do this even if unconfiguring the zone so sys-unconfig works -# correctly. -# -fix_net() -{ - [[ "$STACK_TYPE" == "shared" ]] && return - - NETIF_CNT=0 - for i in $ZONEROOT/etc/hostname.* $ZONEROOT/etc/dhcp.* - do - if [[ -f "$i" ]]; then - NETIF_CNT=$(($NETIF_CNT+1)) - OLD_HOSTNET="$i" - fi - done - if (( $NETIF_CNT != 1 )); then - vlog "$v_nonetfix" - return - fi - - NET=$(LC_ALL=C zonecfg -z $ZONENAME info net) - if (( $? != 0 )); then - error "$e_badinfo" "net" - return - fi - - NETIF=$(echo $NET | nawk '{ - for (i = 1; i < NF; i++) { - if ($i == "physical:") { - if (length(net) == 0) { - i++ - net = $i - } else { - multiple=1 - } - } - } - } - END { if (!multiple) - print net - }') - - if [[ -z "$NETIF" ]]; then - vlog "$v_nonetfix" - return - fi - - NEWHOSTNET=${OLD_HOSTNET%*.*} - if [[ "$OLD_HOSTNET" != "$NEWHOSTNET.$NETIF" ]]; then - safe_move $OLD_HOSTNET $NEWHOSTNET.$NETIF - fi -} - -# -# Disable all of the shares since the zone cannot be an NFS server. -# Note that we disable the various instances of the svc:/network/shares/group -# SMF service in the fix_smf function. -# -fix_nfs() -{ - zonedfs=$ZONEROOT/etc/dfs - - if [[ -h $zonedfs/dfstab || ! -f $zonedfs/dfstab ]]; then - error "$e_badfile" "/etc/dfs/dfstab" - return - fi - - tmpfile=$(mktemp -t) - if [[ -z "$tmpfile" ]]; then - error "$e_tmpfile" - return - fi - - nawk '{ - if (substr($1, 0, 1) == "#") { - print $0 - } else { - print "#", $0 - modified=1 - } - } - END { - if (modified == 1) { - printf("# Modified by p2v ") - system("/usr/bin/date") - exit 0 - } - exit 1 - }' $zonedfs/dfstab >>$tmpfile - - if (( $? == 0 )); then - if [[ ! -f $zonedfs/dfstab.pre_p2v ]]; then - safe_copy $zonedfs/dfstab $zonedfs/dfstab.pre_p2v - fi - safe_copy $tmpfile $zonedfs/dfstab - fi - rm -f $tmpfile -} - -# -# Comment out most of the old mounts since they are either unneeded or -# likely incorrect within a zone. Specific mounts can be manually -# reenabled if the corresponding device is added to the zone. -# -fix_vfstab() -{ - if [[ -h $ZONEROOT/etc/vfstab || ! -f $ZONEROOT/etc/vfstab ]]; then - error "$e_badfile" "/etc/vfstab" - return - fi - - tmpfile=$(mktemp -t) - if [[ -z "$tmpfile" ]]; then - error "$e_tmpfile" - return - fi - - nawk '{ - if (substr($1, 0, 1) == "#") { - print $0 - } else if ($1 == "fd" || $1 == "/proc" || $1 == "swap" || - $1 == "ctfs" || $1 == "objfs" || $1 == "sharefs" || - $4 == "nfs" || $4 == "lofs") { - print $0 - } else { - print "#", $0 - modified=1 - } - } - END { - if (modified == 1) { - printf("# Modified by p2v ") - system("/usr/bin/date") - exit 0 - } - exit 1 - }' $ZONEROOT/etc/vfstab >>$tmpfile - - if (( $? == 0 )); then - if [[ ! -f $ZONEROOT/etc/vfstab.pre_p2v ]]; then - safe_copy $ZONEROOT/etc/vfstab \ - $ZONEROOT/etc/vfstab.pre_p2v - fi - safe_copy $tmpfile $ZONEROOT/etc/vfstab - fi - rm -f $tmpfile -} - -# -# Delete or disable SMF services. -# -fix_smf() -{ - SMF_UPGRADE=/a/var/svc/profile/upgrade - - # - # Fix network services if shared stack. - # - if [[ "$STACK_TYPE" == "shared" ]]; then - vlog "$v_fixnetsvcs" - - NETPHYSDEF="svc:/network/physical:default" - NETPHYSNWAM="svc:/network/physical:nwam" - - vlog "$v_enblsvc" "$NETPHYSDEF" - zlogin -S $ZONENAME "echo /usr/sbin/svcadm enable $NETPHYSDEF \ - >>$SMF_UPGRADE" >$SMF_UPGRADE" >$SMF_UPGRADE" >$SMF_UPGRADE" >$SMF_UPGRADE" /dev/null 2>&1 - if (( $? != 0 )); then - continue - fi - - vlog "$v_rmpkg" "$i" - zlogin -S $ZONENAME LC_ALL=C \ - /usr/bin/pkg -R /a uninstall -r $i &2 || \ - error "$e_rmpkg" $i - done -} - -# -# Zoneadmd writes a one-line index file into the zone when the zone boots, -# so any information about installed zones from the original system will -# be lost at that time. Here we'll warn the sysadmin about any pre-existing -# zones that they might want to clean up by hand, but we'll leave the zonepaths -# in place in case they're on shared storage and will be migrated to -# a new host. -# -warn_zones() -{ - zoneconfig=$ZONEROOT/etc/zones - - if [[ -h $zoneconfig/index || ! -f $zoneconfig/index ]]; then - error "$e_badfile" "/etc/zones/index" - return - fi - - NGZ=$(nawk -F: '{ - if (substr($1, 0, 1) == "#" || $1 == "global") - continue - - if ($2 == "installed") - printf("%s ", $1) - }' $zoneconfig/index) - - # Return if there are no installed zones to warn about. - [[ -z "$NGZ" ]] && return - - log "$v_rmzones" "$NGZ" - - NGZP=$(nawk -F: '{ - if (substr($1, 0, 1) == "#" || $1 == "global") - continue - - if ($2 == "installed") - printf("%s ", $3) - }' $zoneconfig/index) - - log "$v_rmzonepaths" - - for i in $NGZP - do - log " %s" "$i" - done -} - -# -# failure should unmount the zone if necessary; -# -ZONE_IS_MOUNTED=0 -trap trap_exit EXIT - -# -# Parse the command line options. -# -OPT_U= -OPT_V= -OPT_L= -while getopts "b:uvl:" opt -do - case "$opt" in - u) OPT_U="-u";; - v) OPT_V="-v";; - l) LOGFILE="$OPTARG"; OPT_L="-l \"$OPTARG\"";; - *) exit 1;; - esac -done -shift OPTIND-1 - -(( $# != 2 )) && exit 1 - -[[ -n $LOGFILE ]] && exec 2>>$LOGFILE - -ZONENAME=$1 -ZONEPATH=$2 -ZONEROOT=$ZONEPATH/root - -e_badinfo=$(gettext "Failed to get '%s' zone resource") -e_badfile=$(gettext "Invalid '%s' file within the zone") -e_tmpfile=$(gettext "Unable to create temporary file") -v_mkdirs=$(gettext "Creating mount points") -v_nonetfix=$(gettext "Cannot update /etc/hostname.{net} file") -v_change_var=$(gettext "Changing the pkg variant to nonglobal...") -e_change_var=$(gettext "Changing the pkg variant to nonglobal failed") -v_update=$(gettext "Updating the zone software to match the global zone...") -v_updatedone=$(gettext "Zone software update complete") -e_badupdate=$(gettext "Updating the Zone software failed") -v_adjust=$(gettext "Updating the image to run within a zone") -v_stacktype=$(gettext "Stack type '%s'") -v_rmhollowsvcs=$(gettext "Deleting global zone-only SMF services") -v_fixnetsvcs=$(gettext "Adjusting network SMF services") -v_rminvalidsvcs=$(gettext "Disabling invalid SMF services") -v_collectingsmf=$(gettext "Collecting SMF svc data") -v_delsvc=$(gettext "Delete SMF svc '%s'") -e_delsvc=$(gettext "deleting SMF svc '%s'") -v_enblsvc=$(gettext "Enable SMF svc '%s'") -e_enblsvc=$(gettext "enabling SMF svc '%s'") -v_dissvc=$(gettext "Disable SMF svc '%s'") -e_adminf=$(gettext "Unable to create admin file") -v_rmpkg=$(gettext "Remove package '%s'") -e_rmpkg=$(gettext "removing package '%s'") -v_rmzones=$(gettext "The following zones in this image will be unusable: %s") -v_rmzonepaths=$(gettext "These zonepaths could be removed from this image:") -v_exitgood=$(gettext "Postprocessing successful.") - -# -# Do some validation on the paths we'll be accessing -# -safe_dir etc -safe_dir etc/dfs -safe_dir etc/zones -safe_dir var -safe_dir var/log -safe_dir var/pkg - -# Now do the work to update the zone. - -# Before booting the zone we may need to create a few mnt points, just in -# case they don't exist for some reason. -# -# Whenever we reach into the zone while running in the global zone we -# need to validate that none of the interim directories are symlinks -# that could cause us to inadvertently modify the global zone. -vlog "$v_mkdirs" -if [[ ! -f $ZONEROOT/tmp && ! -d $ZONEROOT/tmp ]]; then - mkdir -m 1777 -p $ZONEROOT/tmp || exit $EXIT_CODE -fi -if [[ ! -f $ZONEROOT/var/run && ! -d $ZONEROOT/var/run ]]; then - mkdir -m 1755 -p $ZONEROOT/var/run || exit $EXIT_CODE -fi -if [[ ! -h $ZONEROOT/etc && ! -f $ZONEROOT/etc/mnttab ]]; then - touch $ZONEROOT/etc/mnttab || exit $EXIT_CODE - chmod 444 $ZONEROOT/etc/mnttab || exit $EXIT_CODE -fi -if [[ ! -f $ZONEROOT/proc && ! -d $ZONEROOT/proc ]]; then - mkdir -m 755 -p $ZONEROOT/proc || exit $EXIT_CODE -fi -if [[ ! -f $ZONEROOT/dev && ! -d $ZONEROOT/dev ]]; then - mkdir -m 755 -p $ZONEROOT/dev || exit $EXIT_CODE -fi -if [[ ! -h $ZONEROOT/etc && ! -h $ZONEROOT/etc/svc && ! -d $ZONEROOT/etc/svc ]] -then - mkdir -m 755 -p $ZONEROOT/etc/svc/volatile || exit $EXIT_CODE -fi - -# Check for zones inside of image. -warn_zones - -STACK_TYPE=$(zoneadm -z $ZONENAME list -p | nawk -F: '{print $7}') -if (( $? != 0 )); then - error "$e_badinfo" "stacktype" -fi -vlog "$v_stacktype" "$STACK_TYPE" - -# Note that we're doing this before update-on-attach has run. -fix_net -fix_nfs -fix_vfstab - -# -# Mount the zone so that we can do all of the updates needed on the zone. -# -vlog "$v_mounting" -ZONE_IS_MOUNTED=1 -zoneadm -z $ZONENAME mount -f || fatal "$e_badmount" - -# -# Any errors in these functions are not considered fatal. The zone can be -# be fixed up manually afterwards and it may need some additional manual -# cleanup in any case. -# - -log "$v_adjust" -# cleanup SMF services -fix_smf -# remove invalid pkgs -rm_pkgs - -vlog "$v_unmount" -zoneadm -z $ZONENAME unmount || fatal "$e_badunmount" -ZONE_IS_MOUNTED=0 - -is_brand_labeled -brand_labeled=$? -if (( $brand_labeled == 1 )); then - # The labeled brand needs to mount the zone's root dataset back onto - # ZONEROOT so we can finish processing. - mount_active_ds -fi - -# Change the pkging variant from global zone to non-global zone. -log "$v_change_var" -pkg -R $ZONEROOT change-variant variant.opensolaris.zone=nonglobal || \ - fatal "$e_change_var" - -# -# Run update on attach. State is currently 'incomplete' so use the private -# force-update option. -# This also leaves the zone in the 'installed' state. This is a known bug -# in 'zoneadm attach'. We change the zone state back to 'incomplete' for -# now but this can be removed once 'zoneadm attach' is fixed. -# -log "$v_update" -zoneadm -z $ZONENAME attach -U >&2 || fatal "$e_badupdate" -zoneadm -z $ZONENAME mark incomplete || fatal "$e_badupdate" -log "$v_updatedone" - -[[ -n $OPT_U ]] && unconfigure_zone - -(( $brand_labeled == 1 )) && mount_active_ds - -trap - EXIT -vlog "$v_exitgood" -exit 0 diff --git a/usr/lib/brand/alien-root/pkgcreatezone b/usr/lib/brand/alien-root/pkgcreatezone index 6a7c154..0629ebd 100755 --- a/usr/lib/brand/alien-root/pkgcreatezone +++ b/usr/lib/brand/alien-root/pkgcreatezone @@ -23,7 +23,7 @@ # # Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. # -# Copyright (c) 2013-2016 Peter C. Tribble peter.tribble@gmail.com +# Copyright (c) 2013-2018 Peter C. Tribble peter.tribble@gmail.com # . /usr/lib/brand/tribblix-common/common.ksh @@ -33,7 +33,7 @@ f_interrupted=$(gettext "Installation cancelled due to interrupt.\n") m_image=$(gettext " Image: Preparing at %s.") m_smf=$(gettext " Postinstall: Copying SMF seed repository ...") -m_usage=$(gettext "\n install [-h]\n install {-a archive|-d path} {-p|-u} [-s|-v]") +m_usage=$(gettext "\n install [-h]\n install -i image_file") m_done=$(gettext " done.") @@ -54,24 +54,14 @@ TEXTDOMAIN="SUNW_OST_OSCMD" export TEXTDOMAIN unset iso_image -unset install_archive -unset source_dir unset msg -unset silent_mode -unset verbose_mode -while getopts "a:d:e:hi:pR:sTuvz:" opt; do +while getopts "hi:R:Tz:" opt; do case $opt in - a) install_archive="-a $OPTARG";; - d) source_dir="-d $OPTARG";; h) fail_usage "";; i) iso_image="$OPTARG";; - p) preserve_zone="-p";; R) ZONEPATH="$OPTARG" ;; - s) silent_mode=1;; T) template_mode=1;; - u) unconfig_zone="-u";; - v) verbose_mode="-v";; z) ZONENAME="$OPTARG" ;; *) fail_usage "";; esac @@ -84,7 +74,7 @@ if [[ -z $ZONEPATH || -z $ZONENAME ]]; then fi if [[ -z $iso_image ]]; then - print -u2 "Brand error: No iso image specified" + print -u2 "Brand error: No image file specified" exit $ZONE_SUBPROC_USAGE fi @@ -97,24 +87,6 @@ brand_labeled=$? ZONEROOT=$ZONEPATH/root -# An image install can't use both -a AND -d... -[[ -n "$install_archive" && -n "$source_dir" ]] && - fail_usage "$f_incompat_options" "-a" "-d" - -# The install can't be both verbose AND silent... -[[ -n $silent_mode && -n $verbose_mode ]] && \ - fail_usage "$f_incompat_options" "-s" "-v" - -# The install can't both preserve and unconfigure -[[ -n $unconfig_zone && -n $preserve_zone ]] && \ - fail_usage "$f_incompat_options" "-u" "-p" - -# p2v options are only allowed when installing from an image -if [[ -z $install_archive && -z $source_dir ]]; then - [[ -n $preserve_zone || -n $unconfig_zone ]] && \ - fail_usage "$f_incompat_options" "default" "-p|-u" -fi - # # Before installing the zone, set up ZFS dataset hierarchy for the zone root # dataset. If creating a template, the path should already exist and we use @@ -130,21 +102,6 @@ else fi fi -# -# If we're installing from an image, branch off to that installer. -# -if [[ -n $install_archive || -n $source_dir ]]; then - /usr/lib/brand/alien-root/image_install $ZONENAME $ZONEPATH \ - $install_archive $source_dir $verbose_mode $silent_mode \ - $unconfig_zone $preserve_zone - ii_result=$? - - if (( $ii_result != 0 )); then - exit $ZONE_SUBPROC_NOTCOMPLETE - fi - exit $ZONE_SUBPROC_OK -fi - printf "$m_image\n" $ZONEROOT # diff --git a/usr/lib/brand/whole-root/config.xml b/usr/lib/brand/whole-root/config.xml index cfff4c4..9faa18b 100644 --- a/usr/lib/brand/whole-root/config.xml +++ b/usr/lib/brand/whole-root/config.xml @@ -22,7 +22,7 @@ Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. - Copyright (c) 2013 Peter C. Tribble peter.tribble@gmail.com + Copyright (c) 2018 Peter C. Tribble peter.tribble@gmail.com DO NOT EDIT THIS FILE. --> @@ -39,7 +39,7 @@ /usr/bin/getent passwd %u /usr/lib/brand/whole-root/pkgcreatezone -z %z -R %R - a:d:o:O:hpsuv + o:O:h /usr/lib/brand/whole-root/prestate %z %R 2 0 diff --git a/usr/lib/brand/whole-root/image_install b/usr/lib/brand/whole-root/image_install deleted file mode 100755 index d0426d5..0000000 --- a/usr/lib/brand/whole-root/image_install +++ /dev/null @@ -1,236 +0,0 @@ -#!/bin/ksh -p -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -# -# image_install is used when installing a zone in a 'p2v' scenario. In -# this case the zone install hook will branch off to this script which -# is responsible for setting up the physical system image in the zonepath -# and performing the various modifications necessary to enable a physical -# system image to run inside a zone. This script sets up the image in the -# zonepath then calls the p2v script to modify the image to run in a zone. -# - -. /usr/lib/brand/tribblix-common/common.ksh - -m_usage=$(gettext "\n install {-a archive|-d path} {-p|-u} [-s|-v]") -install_log=$(gettext " Log File: %s") - -p2ving=$(gettext "Postprocessing: This may take a while...") -p2v_prog=$(gettext " Postprocess: ") -p2v_done=$(gettext " Result: Postprocessing complete.") -p2v_fail=$(gettext " Result: Postprocessing failed.") -m_postnote3=$(gettext " Make any other adjustments, such as disabling SMF services\n that are no longer needed.") - -media_missing=\ -$(gettext "%s: you must specify an installation source using '-a' or '-d'.") -cfgchoice_missing=\ -$(gettext "you must specify -u (sys-unconfig) or -p (preserve identity).") - -# Clean up on interrupt -trap_cleanup() -{ - msg=$(gettext "Installation cancelled due to interrupt.") - log "$msg" - - trap_exit -} - -# If the install failed then clean up the ZFS datasets we created. -trap_exit() -{ - # umount any mounted file systems - [[ -n "$fstmpfile" ]] && umnt_fs - - if (( $zone_is_mounted != 0 )); then - error "$v_unmount" - zoneadm -z $ZONENAME unmount - zone_is_mounted=0 - fi - - if (( $EXIT_CODE != $ZONE_SUBPROC_OK )); then - /usr/lib/brand/whole-root/uninstall $ZONENAME $ZONEPATH -F - fi - - 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 pkgcreatezone to install an OpenSolaris system image into -# a zone. -# - -# -# Exit code to return if install is interrupted or exit code is otherwise -# unspecified. -# -EXIT_CODE=$ZONE_SUBPROC_USAGE - -zone_is_mounted=0 -trap trap_cleanup INT -trap trap_exit EXIT - -# If we weren't passed at least two arguments, exit now. -(( $# < 2 )) && exit $ZONE_SUBPROC_USAGE - -ZONENAME="$1" -ZONEPATH="$2" -# XXX shared/common script currently uses lower case zonename & zonepath -zonename="$ZONENAME" -zonepath="$ZONEPATH" - -ZONEROOT="$ZONEPATH/root" - -shift; shift # remove zonename and zonepath from arguments array - -unset inst_type -unset msg -unset silent_mode -unset verbose_mode - -# -# 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 - -while getopts "a:d:psuv" opt -do - case "$opt" in - a) - if [[ -n "$inst_type" ]]; then - fatal "$both_kinds" "zoneadm install" - fi - inst_type="archive" - install_media="$OPTARG" - ;; - d) - if [[ -n "$inst_type" ]]; then - fatal "$both_kinds" "zoneadm install" - fi - inst_type="directory" - install_media="$OPTARG" - ;; - p) preserve_zone="-p";; - s) silent_mode=1;; - u) unconfig_zone="-u";; - v) verbose_mode="-v";; - *) exit $ZONE_SUBPROC_USAGE;; - esac -done -shift OPTIND-1 - -# The install can't be both verbose AND silent... -[[ -n $silent_mode && -n $verbose_mode ]] && \ - fatal "$f_incompat_options" "-s" "-v" - -[[ -z $install_media ]] && fatal "$media_missing" "zoneadm install" - -# The install can't both preserve and unconfigure -[[ -n $unconfig_zone && -n $preserve_zone ]] && \ - fatal "$f_incompat_options" "-u" "-p" - -# Must pick one or the other. -[[ -z $unconfig_zone && -z $preserve_zone ]] && fail_usage "$cfgchoice_missing" - -LOGFILE=$(/usr/bin/mktemp -t -p /var/tmp $ZONENAME.install_log.XXXXXX) -[[ -z "$LOGFILE" ]] && fatal "$e_tmpfile" -exec 2>>"$LOGFILE" -log "$install_log" "$LOGFILE" - -vlog "Starting pre-installation tasks." - -# -# From here on out, an unspecified exit or interrupt should exit with -# ZONE_SUBPROC_NOTCOMPLETE, 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. -# -EXIT_CODE=$ZONE_SUBPROC_NOTCOMPLETE - -# ZONEROOT was created by our caller (pkgcreatezone) - -vlog "Installation started for zone \"$ZONENAME\"" -install_image "$inst_type" "$install_media" - -# -# 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. -# -log "$p2ving" -vlog "running: p2v $verbose_mode $unconfig_zone $ZONENAME $ZONEPATH" -/usr/lib/brand/whole-root/p2v -l "$LOGFILE" $verbose_mode $unconfig_zone $ZONENAME \ - $ZONEPATH -p2v_result=$? -exec 2>>$LOGFILE - -if (( $p2v_result != 0 )); then - log "$p2v_fail" - log "" - log "$install_fail" - log "$install_log" "$LOGFILE" - exit $ZONE_SUBPROC_FATAL -fi -vlog "$p2v_done" - -zone_is_mounted=1 -zoneadm -z $ZONENAME mount -f || fatal "$e_badmount" - -safe_copy $LOGFILE $ZONEPATH/lu/a/var/log/$ZONENAME.install$$.log - -zoneadm -z $ZONENAME unmount || fatal "$e_badunmount" -zone_is_mounted=0 - -trap - EXIT -rm -f $LOGFILE - -# Mount active dataset on the root. -is_brand_labeled -(( $? == 0 )) && mount_active_ds - -log "" -log "$m_complete" ${SECONDS} -printf "$install_log\n" "$ZONEROOT/var/log/$ZONENAME.install$$.log" -printf "$m_postnote\n" -printf "$m_postnote2\n" -printf "$m_postnote3\n" - -exit $ZONE_SUBPROC_OK diff --git a/usr/lib/brand/whole-root/p2v b/usr/lib/brand/whole-root/p2v deleted file mode 100755 index 6eba3d2..0000000 --- a/usr/lib/brand/whole-root/p2v +++ /dev/null @@ -1,474 +0,0 @@ -#!/bin/ksh -p -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -# NOTE: this script runs in the global zone and touches the non-global -# zone, so care should be taken to validate any modifications so that they -# are safe. - -# Restrict executables to /usr/bin and /usr/sbin -PATH=/usr/bin:/usr/sbin -export PATH -unset LD_LIBRARY_PATH - -. /usr/lib/brand/tribblix-common/common.ksh - -LOGFILE= -EXIT_CODE=1 - -# Clean up on failure -trap_exit() -{ - if (( $ZONE_IS_MOUNTED != 0 )); then - error "$v_unmount" - zoneadm -z $ZONENAME unmount - fi - - exit $EXIT_CODE -} - -# -# For an exclusive stack zone, fix up the network configuration files. -# We need to do this even if unconfiguring the zone so sys-unconfig works -# correctly. -# -fix_net() -{ - [[ "$STACK_TYPE" == "shared" ]] && return - - NETIF_CNT=0 - for i in $ZONEROOT/etc/hostname.* $ZONEROOT/etc/dhcp.* - do - if [[ -f "$i" ]]; then - NETIF_CNT=$(($NETIF_CNT+1)) - OLD_HOSTNET="$i" - fi - done - if (( $NETIF_CNT != 1 )); then - vlog "$v_nonetfix" - return - fi - - NET=$(LC_ALL=C zonecfg -z $ZONENAME info net) - if (( $? != 0 )); then - error "$e_badinfo" "net" - return - fi - - NETIF=$(echo $NET | nawk '{ - for (i = 1; i < NF; i++) { - if ($i == "physical:") { - if (length(net) == 0) { - i++ - net = $i - } else { - multiple=1 - } - } - } - } - END { if (!multiple) - print net - }') - - if [[ -z "$NETIF" ]]; then - vlog "$v_nonetfix" - return - fi - - NEWHOSTNET=${OLD_HOSTNET%*.*} - if [[ "$OLD_HOSTNET" != "$NEWHOSTNET.$NETIF" ]]; then - safe_move $OLD_HOSTNET $NEWHOSTNET.$NETIF - fi -} - -# -# Disable all of the shares since the zone cannot be an NFS server. -# Note that we disable the various instances of the svc:/network/shares/group -# SMF service in the fix_smf function. -# -fix_nfs() -{ - zonedfs=$ZONEROOT/etc/dfs - - if [[ -h $zonedfs/dfstab || ! -f $zonedfs/dfstab ]]; then - error "$e_badfile" "/etc/dfs/dfstab" - return - fi - - tmpfile=$(mktemp -t) - if [[ -z "$tmpfile" ]]; then - error "$e_tmpfile" - return - fi - - nawk '{ - if (substr($1, 0, 1) == "#") { - print $0 - } else { - print "#", $0 - modified=1 - } - } - END { - if (modified == 1) { - printf("# Modified by p2v ") - system("/usr/bin/date") - exit 0 - } - exit 1 - }' $zonedfs/dfstab >>$tmpfile - - if (( $? == 0 )); then - if [[ ! -f $zonedfs/dfstab.pre_p2v ]]; then - safe_copy $zonedfs/dfstab $zonedfs/dfstab.pre_p2v - fi - safe_copy $tmpfile $zonedfs/dfstab - fi - rm -f $tmpfile -} - -# -# Comment out most of the old mounts since they are either unneeded or -# likely incorrect within a zone. Specific mounts can be manually -# reenabled if the corresponding device is added to the zone. -# -fix_vfstab() -{ - if [[ -h $ZONEROOT/etc/vfstab || ! -f $ZONEROOT/etc/vfstab ]]; then - error "$e_badfile" "/etc/vfstab" - return - fi - - tmpfile=$(mktemp -t) - if [[ -z "$tmpfile" ]]; then - error "$e_tmpfile" - return - fi - - nawk '{ - if (substr($1, 0, 1) == "#") { - print $0 - } else if ($1 == "fd" || $1 == "/proc" || $1 == "swap" || - $1 == "ctfs" || $1 == "objfs" || $1 == "sharefs" || - $4 == "nfs" || $4 == "lofs") { - print $0 - } else { - print "#", $0 - modified=1 - } - } - END { - if (modified == 1) { - printf("# Modified by p2v ") - system("/usr/bin/date") - exit 0 - } - exit 1 - }' $ZONEROOT/etc/vfstab >>$tmpfile - - if (( $? == 0 )); then - if [[ ! -f $ZONEROOT/etc/vfstab.pre_p2v ]]; then - safe_copy $ZONEROOT/etc/vfstab \ - $ZONEROOT/etc/vfstab.pre_p2v - fi - safe_copy $tmpfile $ZONEROOT/etc/vfstab - fi - rm -f $tmpfile -} - -# -# Delete or disable SMF services. -# -fix_smf() -{ - SMF_UPGRADE=/a/var/svc/profile/upgrade - - # - # Fix network services if shared stack. - # - if [[ "$STACK_TYPE" == "shared" ]]; then - vlog "$v_fixnetsvcs" - - NETPHYSDEF="svc:/network/physical:default" - NETPHYSNWAM="svc:/network/physical:nwam" - - vlog "$v_enblsvc" "$NETPHYSDEF" - zlogin -S $ZONENAME "echo /usr/sbin/svcadm enable $NETPHYSDEF \ - >>$SMF_UPGRADE" >$SMF_UPGRADE" >$SMF_UPGRADE" >$SMF_UPGRADE" >$SMF_UPGRADE" &2 || \ - error "$e_rmpkg" $i - done -} - -# -# Zoneadmd writes a one-line index file into the zone when the zone boots, -# so any information about installed zones from the original system will -# be lost at that time. Here we'll warn the sysadmin about any pre-existing -# zones that they might want to clean up by hand, but we'll leave the zonepaths -# in place in case they're on shared storage and will be migrated to -# a new host. -# -warn_zones() -{ - zoneconfig=$ZONEROOT/etc/zones - - if [[ -h $zoneconfig/index || ! -f $zoneconfig/index ]]; then - error "$e_badfile" "/etc/zones/index" - return - fi - - NGZ=$(nawk -F: '{ - if (substr($1, 0, 1) == "#" || $1 == "global") - continue - - if ($2 == "installed") - printf("%s ", $1) - }' $zoneconfig/index) - - # Return if there are no installed zones to warn about. - [[ -z "$NGZ" ]] && return - - log "$v_rmzones" "$NGZ" - - NGZP=$(nawk -F: '{ - if (substr($1, 0, 1) == "#" || $1 == "global") - continue - - if ($2 == "installed") - printf("%s ", $3) - }' $zoneconfig/index) - - log "$v_rmzonepaths" - - for i in $NGZP - do - log " %s" "$i" - done -} - -# -# failure should unmount the zone if necessary; -# -ZONE_IS_MOUNTED=0 -trap trap_exit EXIT - -# -# Parse the command line options. -# -OPT_U= -OPT_V= -OPT_L= -while getopts "b:uvl:" opt -do - case "$opt" in - u) OPT_U="-u";; - v) OPT_V="-v";; - l) LOGFILE="$OPTARG"; OPT_L="-l \"$OPTARG\"";; - *) exit 1;; - esac -done -shift OPTIND-1 - -(( $# != 2 )) && exit 1 - -[[ -n $LOGFILE ]] && exec 2>>$LOGFILE - -ZONENAME=$1 -ZONEPATH=$2 -ZONEROOT=$ZONEPATH/root - -e_badinfo=$(gettext "Failed to get '%s' zone resource") -e_badfile=$(gettext "Invalid '%s' file within the zone") -e_tmpfile=$(gettext "Unable to create temporary file") -v_mkdirs=$(gettext "Creating mount points") -v_nonetfix=$(gettext "Cannot update /etc/hostname.{net} file") -v_update=$(gettext "Updating the zone software to match the global zone...") -v_updatedone=$(gettext "Zone software update complete") -e_badupdate=$(gettext "Updating the Zone software failed") -v_adjust=$(gettext "Updating the image to run within a zone") -v_stacktype=$(gettext "Stack type '%s'") -v_rmhollowsvcs=$(gettext "Deleting global zone-only SMF services") -v_fixnetsvcs=$(gettext "Adjusting network SMF services") -v_rminvalidsvcs=$(gettext "Disabling invalid SMF services") -v_collectingsmf=$(gettext "Collecting SMF svc data") -v_delsvc=$(gettext "Delete SMF svc '%s'") -e_delsvc=$(gettext "deleting SMF svc '%s'") -v_enblsvc=$(gettext "Enable SMF svc '%s'") -e_enblsvc=$(gettext "enabling SMF svc '%s'") -v_dissvc=$(gettext "Disable SMF svc '%s'") -v_rmpkg=$(gettext "Remove package '%s'") -e_rmpkg=$(gettext "removing package '%s'") -v_rmzones=$(gettext "The following zones in this image will be unusable: %s") -v_rmzonepaths=$(gettext "These zonepaths could be removed from this image:") -v_exitgood=$(gettext "Postprocessing successful.") - -# -# Do some validation on the paths we'll be accessing -# -safe_dir etc -safe_dir etc/dfs -safe_dir etc/zones -safe_dir var -safe_dir var/log - -# Now do the work to update the zone. - -# Before booting the zone we may need to create a few mnt points, just in -# case they don't exist for some reason. -# -# Whenever we reach into the zone while running in the global zone we -# need to validate that none of the interim directories are symlinks -# that could cause us to inadvertently modify the global zone. -vlog "$v_mkdirs" -if [[ ! -f $ZONEROOT/tmp && ! -d $ZONEROOT/tmp ]]; then - mkdir -m 1777 -p $ZONEROOT/tmp || exit $EXIT_CODE -fi -if [[ ! -f $ZONEROOT/var/run && ! -d $ZONEROOT/var/run ]]; then - mkdir -m 1755 -p $ZONEROOT/var/run || exit $EXIT_CODE -fi -if [[ ! -h $ZONEROOT/etc && ! -f $ZONEROOT/etc/mnttab ]]; then - touch $ZONEROOT/etc/mnttab || exit $EXIT_CODE - chmod 444 $ZONEROOT/etc/mnttab || exit $EXIT_CODE -fi -if [[ ! -f $ZONEROOT/proc && ! -d $ZONEROOT/proc ]]; then - mkdir -m 755 -p $ZONEROOT/proc || exit $EXIT_CODE -fi -if [[ ! -f $ZONEROOT/dev && ! -d $ZONEROOT/dev ]]; then - mkdir -m 755 -p $ZONEROOT/dev || exit $EXIT_CODE -fi -if [[ ! -h $ZONEROOT/etc && ! -h $ZONEROOT/etc/svc && ! -d $ZONEROOT/etc/svc ]] -then - mkdir -m 755 -p $ZONEROOT/etc/svc/volatile || exit $EXIT_CODE -fi - -# Check for zones inside of image. -warn_zones - -STACK_TYPE=$(zoneadm -z $ZONENAME list -p | nawk -F: '{print $7}') -if (( $? != 0 )); then - error "$e_badinfo" "stacktype" -fi -vlog "$v_stacktype" "$STACK_TYPE" - -# Note that we're doing this before update-on-attach has run. -fix_net -fix_nfs -fix_vfstab - -# -# Mount the zone so that we can do all of the updates needed on the zone. -# -vlog "$v_mounting" -ZONE_IS_MOUNTED=1 -zoneadm -z $ZONENAME mount -f || fatal "$e_badmount" - -# -# Any errors in these functions are not considered fatal. The zone can be -# be fixed up manually afterwards and it may need some additional manual -# cleanup in any case. -# - -log "$v_adjust" -# cleanup SMF services -fix_smf -# remove invalid pkgs -rm_pkgs - -vlog "$v_unmount" -zoneadm -z $ZONENAME unmount || fatal "$e_badunmount" -ZONE_IS_MOUNTED=0 - -is_brand_labeled -brand_labeled=$? -if (( $brand_labeled == 1 )); then - # The labeled brand needs to mount the zone's root dataset back onto - # ZONEROOT so we can finish processing. - mount_active_ds -fi - -# -# Run update on attach. State is currently 'incomplete' so use the private -# force-update option. -# This also leaves the zone in the 'installed' state. This is a known bug -# in 'zoneadm attach'. We change the zone state back to 'incomplete' for -# now but this can be removed once 'zoneadm attach' is fixed. -# -log "$v_update" -zoneadm -z $ZONENAME attach -U >&2 || fatal "$e_badupdate" -zoneadm -z $ZONENAME mark incomplete || fatal "$e_badupdate" -log "$v_updatedone" - -[[ -n $OPT_U ]] && unconfigure_zone - -(( $brand_labeled == 1 )) && mount_active_ds - -trap - EXIT -vlog "$v_exitgood" -exit 0 diff --git a/usr/lib/brand/whole-root/pkgcreatezone b/usr/lib/brand/whole-root/pkgcreatezone index 08fcc50..2da05ff 100755 --- a/usr/lib/brand/whole-root/pkgcreatezone +++ b/usr/lib/brand/whole-root/pkgcreatezone @@ -23,7 +23,7 @@ # # Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. # -# Copyright (c) 2013-2016 Peter C. Tribble peter.tribble@gmail.com +# Copyright (c) 2013-2018 Peter C. Tribble peter.tribble@gmail.com # . /usr/lib/brand/tribblix-common/common.ksh @@ -33,7 +33,7 @@ f_interrupted=$(gettext "Installation cancelled due to interrupt.\n") m_image=$(gettext " Image: Preparing at %s.") m_smf=$(gettext " Postinstall: Copying SMF seed repository ...") -m_usage=$(gettext "\n install [-h]\n [{-o|-O} overlay [...]]\n install {-a archive|-d path} {-p|-u} [-s|-v]") +m_usage=$(gettext "\n install [-h]\n [{-o|-O} overlay [...]]") m_done=$(gettext " done.") @@ -55,25 +55,15 @@ template_mode=0 TEXTDOMAIN="SUNW_OST_OSCMD" export TEXTDOMAIN -unset install_archive -unset source_dir unset msg -unset silent_mode -unset verbose_mode -while getopts "a:d:e:hpo:O:R:sTuvz:" opt; do +while getopts "ho:O:R:Tz:" opt; do case $opt in - a) install_archive="-a $OPTARG";; - d) source_dir="-d $OPTARG";; h) fail_usage "";; o) copy_overlays="$copy_overlays $OPTARG" ;; O) add_overlays="$add_overlays $OPTARG" ;; - p) preserve_zone="-p";; R) ZONEPATH="$OPTARG" ;; - s) silent_mode=1;; T) template_mode=1;; - u) unconfig_zone="-u";; - v) verbose_mode="-v";; z) ZONENAME="$OPTARG" ;; *) fail_usage "";; esac @@ -94,36 +84,6 @@ brand_labeled=$? ZONEROOT=$ZONEPATH/root -# An image install can't use both -a AND -d... -[[ -n "$install_archive" && -n "$source_dir" ]] && - fail_usage "$f_incompat_options" "-a" "-d" - -# The install can't be both verbose AND silent... -[[ -n $silent_mode && -n $verbose_mode ]] && \ - fail_usage "$f_incompat_options" "-s" "-v" - -# The install can't both preserve and unconfigure -[[ -n $unconfig_zone && -n $preserve_zone ]] && \ - fail_usage "$f_incompat_options" "-u" "-p" - -# setting overlays not allowed when installing from a system image. -if [[ -n "$install_archive" || -n "$source_dir" ]]; then - [[ -n "$copy_overlays" ]] && \ - fail_usage "$f_incompat_options" "-a|-d" "-o" -fi - -# adding overlays not allowed when installing from a system image. -if [[ -n "$install_archive" || -n "$source_dir" ]]; then - [[ -n "$add_overlays" ]] && \ - fail_usage "$f_incompat_options" "-a|-d" "-O" -fi - -# p2v options are only allowed when installing from an image -if [[ -z $install_archive && -z $source_dir ]]; then - [[ -n $preserve_zone || -n $unconfig_zone ]] && \ - fail_usage "$f_incompat_options" "default" "-p|-u" -fi - # # Before installing the zone, set up ZFS dataset hierarchy for the zone root # dataset. If creating a template, the path should already exist and we use @@ -139,21 +99,6 @@ else fi fi -# -# If we're installing from an image, branch off to that installer. -# -if [[ -n $install_archive || -n $source_dir ]]; then - /usr/lib/brand/whole-root/image_install $ZONENAME $ZONEPATH \ - $install_archive $source_dir $verbose_mode $silent_mode \ - $unconfig_zone $preserve_zone - ii_result=$? - - if (( $ii_result != 0 )); then - exit $ZONE_SUBPROC_NOTCOMPLETE - fi - exit $ZONE_SUBPROC_OK -fi - printf "$m_image\n" $ZONEROOT # diff --git a/usr/share/man/man5/alien-root.5 b/usr/share/man/man5/alien-root.5 index 4e6a9a8..ba993c2 100644 --- a/usr/share/man/man5/alien-root.5 +++ b/usr/share/man/man5/alien-root.5 @@ -1,4 +1,4 @@ -.TH "ALIEN-ROOT" "5" "Jun 4, 2017" "Tribblix" +.TH "ALIEN-ROOT" "5" "Mar 22, 2018" "Tribblix" .SH "NAME" alien-root zone variant .SH DESCRIPTION @@ -7,11 +7,13 @@ The alien-root zone brand in Tribblix allows you to run an alternative illumos distribution in a zone. .LP The current implementation simply populates the zone file systems from -a tarball or an installation ISO image. Tarballs generated by the -zmvix.sh script from the mvi project (https://github.com/ptribble/mvi) -should be suitable. Installation ISO images from OmniOS, OpenIndiana, -XStreamOS, and DilOS should be recognised. Any further customization -or software installation must be done inside the zone. +a tarball, a live ISO image, or a zfs send stream. Tarballs generated +by the zmvix.sh script from the mvi project +(https://github.com/ptribble/mvi) should be suitable. Installation ISO +images from OmniOS prior to r151022, OpenIndiana, XStreamOS, and DilOS +should be recognised. For ZFS send streams, the PXE images provided by +the OmniOSce project can be used. Any further customization or software +installation must be done inside the zone. .LP The approach used is fragile due to the nature of stable interfaces in illumos. Namely, the userland in the zone must be similar to that in @@ -48,6 +50,19 @@ the zone file system needs to be specified as follows. .fi .in -2 .sp +.SH NOTES +.LP +If the alien zone uses the IPS packaging system, then you should issue +the following command in the newly created zone. +.sp +.in +2 +.nf +\fBpkg change-variant variant.opensolaris.zone=nonglobal\fR +.fi +.in -2 +.sp +.LP +And then reboot the zone. .SH SEE ALSO .LP \fBzones\fR(5), \fBbrands\fR(5), \fBzap\fR(1)