3508 zone install should utilize/populate global zone d/l cache
2279 client output oddities since caching changes
#!/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 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
. /usr/lib/brand/ipkg/common.ksh
f_img=$(gettext "failed to create image")
f_pkg=$(gettext "failed to install package")
f_interrupted=$(gettext "Installation cancelled due to interrupt.")
m_authority=$(gettext " Authority: Using %s.")
m_cache=$(gettext " Cache: Using %s.")
m_image=$(gettext " Image: Preparing at %s ...")
m_core=$(gettext " Installing: (output follows)\n")
m_smf=$(gettext "Postinstall: Copying SMF seed repository ...")
m_brokenness=$(gettext "Postinstall: Working around http://defect.opensolaris.org/bz/show_bug.cgi?id=681")
m_more_brokenness=$(gettext "Postinstall: Working around http://defect.opensolaris.org/bz/show_bug.cgi?id=741")
m_mannote=$(gettext " Note: Man pages can be obtained by installing SUNWman")
m_complete=$(gettext " Done: Installation completed in %s seconds.")
m_postnote=$(gettext " Next Steps: Boot the zone, then log into the zone console")
m_postnote2=$(gettext " (zlogin -C) to complete the configuration process")
m_done=$(gettext " done.")
trap_cleanup() {
print "$f_interrupted"
exit $int_code
}
int_code=$ZONE_SUBPROC_NOTCOMPLETE
trap trap_cleanup INT
zonename=""
zonepath=""
#
# If there's a preferred authority set for the system, set that as our
# default. Otherwise use opensolaris.org.
#
authority="opensolaris.org=http://pkg.opensolaris.org"
if [[ -x /usr/bin/pkg ]]; then
sysauth=`LC_ALL=C /usr/bin/pkg authority | grep preferred | awk '{printf "%s=%s", $1, $3}'`
if [[ $? -eq 0 && -n "$sysauth" ]]; then
authority=$sysauth
fi
fi
# Setup i18n output
TEXTDOMAIN="SUNW_OST_OSCMD"
export TEXTDOMAIN
while getopts "a:z:R:h" opt; do
case $opt in
h) fail_usage "$0 [-h] [-a <authority>]";;
R) zonepath="$OPTARG" ;;
z) zonename="$OPTARG" ;;
a) authority="$OPTARG" ;;
*) fail_usage "$0 [-h] [-a <authority>]";;
esac
done
shift $((OPTIND-1))
if [[ -z $zonepath || -z $zonename ]]; then
print -u2 "Brand error: No zone path or name"
exit $ZONE_SUBPROC_USAGE
fi
zoneroot=$zonepath/root
#
# Before installing the zone, set up ZFS dataset hierarchy for the zone root
# dataset.
#
get_current_gzbe
# Find the zone's current dataset. This should have been created by zoneadm.
get_zonepath_ds $zonepath
# Check that zone is not in the ROOT dataset.
fail_zonepath_in_rootds $ZONEPATH_DS
/usr/sbin/zfs create -o mountpoint=legacy -o zoned=on $ZONEPATH_DS/ROOT \
|| fail_fatal "$f_zfs_create"
/usr/sbin/zfs create -o $PROP_ACTIVE=on -o $PROP_PARENT=$CURRENT_GZBE \
$ZONEPATH_DS/ROOT/zbe || fail_incomplete "$f_zfs_create"
/usr/bin/mkdir $zoneroot || fail_incomplete "$f_root_create"
/usr/sbin/mount -F zfs $ZONEPATH_DS/ROOT/zbe $zoneroot || \
fail_incomplete "$f_zfs_mount"
#
# Done setting up the zone's datasets.
#
printf "$m_authority" `echo $authority | cut -d= -f 2`
printf "\n$m_image" $zoneroot
pkg image-create -z -F -a "$authority" $zoneroot || fail_incomplete "$f_img"
printf "$m_done\n"
entire_fmri=$(pkg list -Hv entire | nawk '{print $1}')
PKG_IMAGE="$zoneroot"
export PKG_IMAGE
if [ -d /var/pkg/download ]; then
PKG_CACHEDIR=/var/pkg/download
export PKG_CACHEDIR
printf "$m_cache\n" $PKG_CACHEDIR
fi
printf "$m_core\n"
pkg install -q $entire_fmri || fail_incomplete "$f_pkg"
pkg install -q SUNWcsd || fail_incomplete "$f_pkg"
pkglist=""
pkglist="$pkglist SUNWcnetr SUNWesu SUNWadmr SUNWadmap SUNWbzip SUNWgzip"
#
# Workaround: For now, SUNWipkg has no dependencies so we must supply it python.
#
pkglist="$pkglist SUNWPython SUNWipkg"
#
# Get some diagnostic tools, truss, dtrace, etc.
#
pkglist="$pkglist SUNWtoo SUNWdtrc SUNWrcmdc SUNWbip"
#
# Get at least one sensible shell, and vi
#
pkglist="$pkglist SUNWbash SUNWvim"
#
# Get ssh and sshd.
#
pkglist="$pkglist SUNWsshcu SUNWssh SUNWsshd"
#
# Get some name services.
#
pkglist="$pkglist SUNWnis SUNWlldap"
#
# Get nfs client and autofs; it's a pain not to have them.
#
pkglist="$pkglist SUNWnfsc SUNWatfs"
#
# Get man(1) but not the man pages
#
pkglist="$pkglist SUNWdoc"
# Do the install
pkg install $pkglist || fail_incomplete "$f_pkg"
printf "\n$m_mannote\n"
printf "$m_smf"
ln -s ns_files.xml $zoneroot/var/svc/profile/name_service.xml
ln -s generic_limited_net.xml $zoneroot/var/svc/profile/generic.xml
ln -s inetd_generic.xml $zoneroot/var/svc/profile/inetd_services.xml
ln -s platform_none.xml $zoneroot/var/svc/profile/platform.xml
# This was formerly done in i.manifest
repfile=$zoneroot/etc/svc/repository.db
cp $zoneroot/lib/svc/seed/nonglobal.db $repfile
chmod 0600 $repfile
chown root:sys $repfile
printf "$m_done\n"
# Clean up root as a role and jack if needed
if grep "^root::::type=role;" $zoneroot/etc/user_attr >/dev/null 2>&1; then
printf "$m_brokenness\n"
#
# Remove "jack" user.
#
print "/^jack:/d\nw" | ed -s $zoneroot/etc/passwd
chmod u+w $zoneroot/etc/shadow
print "/^jack:/d\nw" | ed -s $zoneroot/etc/shadow
chmod u-w $zoneroot/etc/shadow
#
# Set root from a role back to... not a role. Grr.
#
print "s/^root::::type=role;/root::::/\nw" |
ed -s $zoneroot/etc/user_attr
fi
#
# Make sure sysidtools run; we manually poke in the SSH action
# so that we get an SSH key. Yes, this is seriously borken.
#
printf "$m_more_brokenness\n"
/usr/sbin/sysidconfig -b $zoneroot -a /lib/svc/method/sshd
touch $zoneroot/etc/.UNCONFIGURED
# Umount the dataset on the root.
/usr/sbin/umount $zoneroot
printf "$m_complete\n\n" ${SECONDS}
printf "$m_postnote\n"
printf "$m_postnote2\n"
exit $ZONE_SUBPROC_OK