110840SGerald.Jelinek@Sun.COM# 210840SGerald.Jelinek@Sun.COM# CDDL HEADER START 310840SGerald.Jelinek@Sun.COM# 410840SGerald.Jelinek@Sun.COM# The contents of this file are subject to the terms of the 510840SGerald.Jelinek@Sun.COM# Common Development and Distribution License (the "License"). 610840SGerald.Jelinek@Sun.COM# You may not use this file except in compliance with the License. 710840SGerald.Jelinek@Sun.COM# 810840SGerald.Jelinek@Sun.COM# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 910840SGerald.Jelinek@Sun.COM# or http://www.opensolaris.org/os/licensing. 1010840SGerald.Jelinek@Sun.COM# See the License for the specific language governing permissions 1110840SGerald.Jelinek@Sun.COM# and limitations under the License. 1210840SGerald.Jelinek@Sun.COM# 1310840SGerald.Jelinek@Sun.COM# When distributing Covered Code, include this CDDL HEADER in each 1410840SGerald.Jelinek@Sun.COM# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 1510840SGerald.Jelinek@Sun.COM# If applicable, add the following below this CDDL HEADER, with the 1610840SGerald.Jelinek@Sun.COM# fields enclosed by brackets "[]" replaced with your own identifying 1710840SGerald.Jelinek@Sun.COM# information: Portions Copyright [yyyy] [name of copyright owner] 1810840SGerald.Jelinek@Sun.COM# 1910840SGerald.Jelinek@Sun.COM# CDDL HEADER END 2010840SGerald.Jelinek@Sun.COM# 2110840SGerald.Jelinek@Sun.COM# 2211771Sgerald.jelinek@sun.com# Copyright 2010 Sun Microsystems, Inc. All rights reserved. 2310840SGerald.Jelinek@Sun.COM# Use is subject to license terms. 2410840SGerald.Jelinek@Sun.COM# 2510840SGerald.Jelinek@Sun.COM 2610840SGerald.Jelinek@Sun.COMunset LD_LIBRARY_PATH 2710840SGerald.Jelinek@Sun.COMPATH=/usr/bin:/usr/sbin 2810840SGerald.Jelinek@Sun.COMexport PATH 2910840SGerald.Jelinek@Sun.COM 3010840SGerald.Jelinek@Sun.COM. /usr/lib/brand/shared/common.ksh 3110840SGerald.Jelinek@Sun.COM 3211771Sgerald.jelinek@sun.com# Values for service tags. 3311771Sgerald.jelinek@sun.comSTCLIENT=/usr/bin/stclient 3411771Sgerald.jelinek@sun.comST_PRODUCT_NAME="Solaris 10 Containers" 3511771Sgerald.jelinek@sun.comST_PRODUCT_REV="1.0" 3611771Sgerald.jelinek@sun.comST_PRODUCT_UUID="urn:uuid:2f459121-dec7-11de-9af7-080020a9ed93" 3711771Sgerald.jelinek@sun.com 3810900Sgerald.jelinek@sun.comw_sanity_detail=$(gettext " WARNING: Skipping image sanity checks.") 3910840SGerald.Jelinek@Sun.COMf_sanity_detail=$(gettext "Missing %s at %s") 4010840SGerald.Jelinek@Sun.COMf_sanity_sparse=$(gettext "Is this a sparse zone image? The image must be whole-root.") 4110840SGerald.Jelinek@Sun.COMf_sanity_vers=$(gettext "The image release version must be 10 (got %s), the zone is not usable on this system.") 4210840SGerald.Jelinek@Sun.COMf_not_s10_image=$(gettext "%s doesn't look like a Solaris 10 image.") 4310840SGerald.Jelinek@Sun.COMf_sanity_nopatch=$(gettext "Unable to determine the image's patch level.") 4410840SGerald.Jelinek@Sun.COMf_sanity_downrev=$(gettext "The image patch level is downrev for running in a solaris10 branded zone.\n(patchlist %s)") 4510840SGerald.Jelinek@Sun.COMf_need_newer_emul=$(gettext "The image requires a newer version of the solaris10 brand emulation.") 4610840SGerald.Jelinek@Sun.COMf_zfs_create=$(gettext "Unable to create the zone's ZFS dataset.") 4710840SGerald.Jelinek@Sun.COMf_no_ds=$(gettext "No zonepath dataset; the zonepath must be a ZFS dataset.") 4810840SGerald.Jelinek@Sun.COMf_multiple_ds=$(gettext "Multiple active datasets.") 4910840SGerald.Jelinek@Sun.COMf_no_active_ds=$(gettext "No active dataset; the zone's ZFS root dataset must be configured as\n\ta zone boot environment.") 5010840SGerald.Jelinek@Sun.COMf_zfs_unmount=$(gettext "Unable to unmount the zone's root ZFS dataset (%s).\nIs there a global zone process inside the zone root?\nThe current zone boot environment will remain mounted.\n") 5110840SGerald.Jelinek@Sun.COMf_zfs_mount=$(gettext "Unable to mount the zone's ZFS dataset.") 5210840SGerald.Jelinek@Sun.COMincompat_options=$(gettext "mutually exclusive options.\n%s") 5310840SGerald.Jelinek@Sun.COM 5410840SGerald.Jelinek@Sun.COMsanity_ok=$(gettext " Sanity Check: Passed. Looks like a Solaris 10 image.") 5510840SGerald.Jelinek@Sun.COMsanity_fail=$(gettext " Sanity Check: FAILED (see log for details).") 5610840SGerald.Jelinek@Sun.COM 5710840SGerald.Jelinek@Sun.COMe_badboot=$(gettext "Zone boot failed") 5810840SGerald.Jelinek@Sun.COMe_nosingleuser=$(gettext "ERROR: zone did not finish booting to single-user.") 5910840SGerald.Jelinek@Sun.COMe_unconfig=$(gettext "sys-unconfig failed") 6010840SGerald.Jelinek@Sun.COMv_unconfig=$(gettext "Performing zone sys-unconfig") 6110840SGerald.Jelinek@Sun.COM 6211771Sgerald.jelinek@sun.comv_no_tags=$(gettext "Service tags facility not present.") 6311771Sgerald.jelinek@sun.come_bad_uuid=$(gettext "Failed to get zone UUID") 6411771Sgerald.jelinek@sun.comv_addtag=$(gettext "Adding service tag: %s") 6511771Sgerald.jelinek@sun.comv_deltag=$(gettext "Removing service tag: %s") 6611771Sgerald.jelinek@sun.come_addtag_fail=$(gettext "Adding service tag failed (error: %s)") 6711771Sgerald.jelinek@sun.com 6810840SGerald.Jelinek@Sun.COMsanity_check() 6910840SGerald.Jelinek@Sun.COM{ 7010840SGerald.Jelinek@Sun.COM typeset dir="$1" 7110840SGerald.Jelinek@Sun.COM res=0 7210840SGerald.Jelinek@Sun.COM 7310840SGerald.Jelinek@Sun.COM # 7410840SGerald.Jelinek@Sun.COM # Check for some required directories and make sure this isn't a 7510840SGerald.Jelinek@Sun.COM # sparse zone image. 7610840SGerald.Jelinek@Sun.COM # 7710840SGerald.Jelinek@Sun.COM checks="etc etc/svc var var/svc" 7810840SGerald.Jelinek@Sun.COM for x in $checks; do 7910840SGerald.Jelinek@Sun.COM if [[ ! -e $dir/$x ]]; then 8010840SGerald.Jelinek@Sun.COM log "$f_sanity_detail" "$x" "$dir" 8110840SGerald.Jelinek@Sun.COM res=1 8210840SGerald.Jelinek@Sun.COM fi 8310840SGerald.Jelinek@Sun.COM done 8410840SGerald.Jelinek@Sun.COM # Files from SUNWcsr and SUNWcsu that are in sparse inherit-pkg-dirs. 8510840SGerald.Jelinek@Sun.COM checks="lib/svc sbin/zonename usr/bin/chmod" 8610840SGerald.Jelinek@Sun.COM for x in $checks; do 8710840SGerald.Jelinek@Sun.COM if [[ ! -e $dir/$x ]]; then 8810840SGerald.Jelinek@Sun.COM log "$f_sanity_detail" "$x" "$dir" 8910840SGerald.Jelinek@Sun.COM log "$f_sanity_sparse" 9010840SGerald.Jelinek@Sun.COM res=1 9110840SGerald.Jelinek@Sun.COM fi 9210840SGerald.Jelinek@Sun.COM done 9310840SGerald.Jelinek@Sun.COM 9410900Sgerald.jelinek@sun.com if (( $res != 0 )); then 9510900Sgerald.jelinek@sun.com log "$sanity_fail" 9610900Sgerald.jelinek@sun.com fatal "$install_fail" "$ZONENAME" 9710900Sgerald.jelinek@sun.com fi 9810900Sgerald.jelinek@sun.com 9910900Sgerald.jelinek@sun.com if [[ "$SANITY_SKIP" == 1 ]]; then 10010900Sgerald.jelinek@sun.com log "$w_sanity_detail" 10110900Sgerald.jelinek@sun.com return 10210900Sgerald.jelinek@sun.com fi 10310900Sgerald.jelinek@sun.com 10410840SGerald.Jelinek@Sun.COM # 10510840SGerald.Jelinek@Sun.COM # Check image release to be sure its S10. 10610840SGerald.Jelinek@Sun.COM # 10710840SGerald.Jelinek@Sun.COM image_vers="unknown" 10810840SGerald.Jelinek@Sun.COM if [[ -f $dir/var/sadm/system/admin/INST_RELEASE ]]; then 10910840SGerald.Jelinek@Sun.COM image_vers=$(nawk -F= '{if ($1 == "VERSION") print $2}' \ 11010840SGerald.Jelinek@Sun.COM $dir/var/sadm/system/admin/INST_RELEASE) 11110840SGerald.Jelinek@Sun.COM fi 11210840SGerald.Jelinek@Sun.COM 11310840SGerald.Jelinek@Sun.COM if [[ "$image_vers" != "10" ]]; then 11410840SGerald.Jelinek@Sun.COM log "$f_sanity_vers" "$image_vers" 11510840SGerald.Jelinek@Sun.COM res=1 11610840SGerald.Jelinek@Sun.COM fi 11710840SGerald.Jelinek@Sun.COM 11810840SGerald.Jelinek@Sun.COM # 11910840SGerald.Jelinek@Sun.COM # Make sure we have the minimal KU patch we support. These are the 12010840SGerald.Jelinek@Sun.COM # KUs for S10u8. 12110840SGerald.Jelinek@Sun.COM # 12210840SGerald.Jelinek@Sun.COM if [[ $(uname -p) == "i386" ]]; then 12310840SGerald.Jelinek@Sun.COM req_patch="141445-09" 12410840SGerald.Jelinek@Sun.COM else 12510840SGerald.Jelinek@Sun.COM req_patch="141444-09" 12610840SGerald.Jelinek@Sun.COM fi 12710840SGerald.Jelinek@Sun.COM 12810840SGerald.Jelinek@Sun.COM for i in $dir/var/sadm/pkg/SUNWcakr* 12910840SGerald.Jelinek@Sun.COM do 13010840SGerald.Jelinek@Sun.COM if [[ ! -d $i || ! -f $i/pkginfo ]]; then 13110840SGerald.Jelinek@Sun.COM log "$f_sanity_nopatch" 13210840SGerald.Jelinek@Sun.COM res=1 13310840SGerald.Jelinek@Sun.COM fi 13410840SGerald.Jelinek@Sun.COM done 13510840SGerald.Jelinek@Sun.COM 13610840SGerald.Jelinek@Sun.COM # 13710840SGerald.Jelinek@Sun.COM # Check the core kernel pkg for the required KU patch. 13810840SGerald.Jelinek@Sun.COM # 13910840SGerald.Jelinek@Sun.COM found=0 14010840SGerald.Jelinek@Sun.COM for i in $dir/var/sadm/pkg/SUNWcakr*/pkginfo 14110840SGerald.Jelinek@Sun.COM do 14210840SGerald.Jelinek@Sun.COM patches=$(nawk -F= '{if ($1 == "PATCHLIST") print $2}' $i) 14310840SGerald.Jelinek@Sun.COM for patch in $patches 14410840SGerald.Jelinek@Sun.COM do 14510840SGerald.Jelinek@Sun.COM if [[ $patch == $req_patch ]]; then 14610840SGerald.Jelinek@Sun.COM found=1 14710840SGerald.Jelinek@Sun.COM break 14810840SGerald.Jelinek@Sun.COM fi 14910840SGerald.Jelinek@Sun.COM done 15010840SGerald.Jelinek@Sun.COM 15110840SGerald.Jelinek@Sun.COM if (( $found == 1 )); then 15210840SGerald.Jelinek@Sun.COM break 15310840SGerald.Jelinek@Sun.COM fi 15410840SGerald.Jelinek@Sun.COM done 15510840SGerald.Jelinek@Sun.COM 15610840SGerald.Jelinek@Sun.COM if (( $found != 1 )); then 15710840SGerald.Jelinek@Sun.COM log "$f_sanity_downrev" "$patches" 15810840SGerald.Jelinek@Sun.COM res=1 15910840SGerald.Jelinek@Sun.COM fi 16010840SGerald.Jelinek@Sun.COM 16110840SGerald.Jelinek@Sun.COM # 16210840SGerald.Jelinek@Sun.COM # Check the S10 image for a required version of the emulation. 16310840SGerald.Jelinek@Sun.COM # 16410840SGerald.Jelinek@Sun.COM VERS_FILE=/usr/lib/brand/solaris10/version 16510840SGerald.Jelinek@Sun.COM s10vers_needs=0 16610840SGerald.Jelinek@Sun.COM if [[ -f $dir/$VERS_FILE ]]; then 16710840SGerald.Jelinek@Sun.COM s10vers_needs=$(/usr/bin/egrep -v "^#" $dir/$VERS_FILE) 16810840SGerald.Jelinek@Sun.COM fi 16910840SGerald.Jelinek@Sun.COM 17010840SGerald.Jelinek@Sun.COM # Now get the current emulation version. 17110840SGerald.Jelinek@Sun.COM emul_vers=$(/usr/bin/egrep -v "^#" $VERS_FILE) 17210840SGerald.Jelinek@Sun.COM 17310840SGerald.Jelinek@Sun.COM # Verify that the emulation can run this version of S10. 17410840SGerald.Jelinek@Sun.COM if (( $s10vers_needs > $emul_vers )); then 17510840SGerald.Jelinek@Sun.COM log "$f_need_newer_emul" 17610840SGerald.Jelinek@Sun.COM res=1 17710840SGerald.Jelinek@Sun.COM fi 17810840SGerald.Jelinek@Sun.COM 17910840SGerald.Jelinek@Sun.COM if (( $res != 0 )); then 18010840SGerald.Jelinek@Sun.COM log "$sanity_fail" 18110840SGerald.Jelinek@Sun.COM fatal "$install_fail" "$ZONENAME" 18210840SGerald.Jelinek@Sun.COM fi 18310840SGerald.Jelinek@Sun.COM 18410840SGerald.Jelinek@Sun.COM vlog "$sanity_ok" 18510840SGerald.Jelinek@Sun.COM} 18610840SGerald.Jelinek@Sun.COM 18710840SGerald.Jelinek@Sun.COM# Find the active dataset under the zonepath dataset to mount on zonepath/root. 18810840SGerald.Jelinek@Sun.COM# $1 ZONEPATH_DS 18910840SGerald.Jelinek@Sun.COMget_active_ds() { 190*12030Sgerald.jelinek@sun.com ACTIVE_DS=$1/ROOT/zbe-0 19110840SGerald.Jelinek@Sun.COM} 19210840SGerald.Jelinek@Sun.COM 19310840SGerald.Jelinek@Sun.COM# 194*12030Sgerald.jelinek@sun.com# Make sure the active dataset is mounted for the zone. 19510840SGerald.Jelinek@Sun.COM# 19610840SGerald.Jelinek@Sun.COMmount_active_ds() { 19710840SGerald.Jelinek@Sun.COM get_zonepath_ds $zonepath 19810840SGerald.Jelinek@Sun.COM get_active_ds $ZONEPATH_DS 19910840SGerald.Jelinek@Sun.COM 200*12030Sgerald.jelinek@sun.com # If already mounted then we're done. 201*12030Sgerald.jelinek@sun.com mnted=`zfs get -H mounted $ACTIVE_DS | cut -f3` 202*12030Sgerald.jelinek@sun.com [[ $mnted = "yes" ]] && return 203*12030Sgerald.jelinek@sun.com 204*12030Sgerald.jelinek@sun.com mount -F zfs $ACTIVE_DS $zonepath/root || fail_fatal "$f_zfs_mount" 20510840SGerald.Jelinek@Sun.COM} 20610840SGerald.Jelinek@Sun.COM 20710840SGerald.Jelinek@Sun.COM# 20810840SGerald.Jelinek@Sun.COM# Set up ZFS dataset hierarchy for the zone root dataset. 20910840SGerald.Jelinek@Sun.COM# 21010840SGerald.Jelinek@Sun.COMcreate_active_ds() { 21110840SGerald.Jelinek@Sun.COM # Find the zone's current dataset. This should have been created by 21210840SGerald.Jelinek@Sun.COM # zoneadm (or the attach hook). 21310840SGerald.Jelinek@Sun.COM get_zonepath_ds $zonepath 21410840SGerald.Jelinek@Sun.COM 21510840SGerald.Jelinek@Sun.COM # 21610840SGerald.Jelinek@Sun.COM # We need to tolerate errors while creating the datasets and making the 21710840SGerald.Jelinek@Sun.COM # mountpoint, since these could already exist from an attach scenario. 21810840SGerald.Jelinek@Sun.COM # 21910840SGerald.Jelinek@Sun.COM 22010840SGerald.Jelinek@Sun.COM /usr/sbin/zfs list -H -o name $ZONEPATH_DS/ROOT >/dev/null 2>&1 22110840SGerald.Jelinek@Sun.COM if (( $? != 0 )); then 22210840SGerald.Jelinek@Sun.COM /usr/sbin/zfs create -o mountpoint=legacy -o zoned=on \ 22310840SGerald.Jelinek@Sun.COM $ZONEPATH_DS/ROOT 22410840SGerald.Jelinek@Sun.COM if (( $? != 0 )); then 22510840SGerald.Jelinek@Sun.COM fail_fatal "$f_zfs_create" 22610840SGerald.Jelinek@Sun.COM fi 22710840SGerald.Jelinek@Sun.COM else 22810840SGerald.Jelinek@Sun.COM /usr/sbin/zfs set mountpoint=legacy $ZONEPATH_DS/ROOT \ 22910840SGerald.Jelinek@Sun.COM >/dev/null 2>&1 23010840SGerald.Jelinek@Sun.COM /usr/sbin/zfs set zoned=on $ZONEPATH_DS/ROOT \ 23110840SGerald.Jelinek@Sun.COM >/dev/null 2>&1 23210840SGerald.Jelinek@Sun.COM fi 23310840SGerald.Jelinek@Sun.COM 234*12030Sgerald.jelinek@sun.com get_active_ds $ZONEPATH_DS 235*12030Sgerald.jelinek@sun.com zfs list -H -o name $ACTIVE_DS >/dev/null 2>&1 23610840SGerald.Jelinek@Sun.COM if (( $? != 0 )); then 237*12030Sgerald.jelinek@sun.com zfs create -o canmount=noauto $ACTIVE_DS 238*12030Sgerald.jelinek@sun.com (( $? != 0 )) && fail_fatal "$f_zfs_create" 23910840SGerald.Jelinek@Sun.COM else 240*12030Sgerald.jelinek@sun.com zfs set canmount=noauto $ACTIVE_DS >/dev/null 2>&1 241*12030Sgerald.jelinek@sun.com zfs inherit mountpoint $ACTIVE_DS >/dev/null 2>&1 242*12030Sgerald.jelinek@sun.com zfs inherit zoned $ACTIVE_DS >/dev/null 2>&1 24310840SGerald.Jelinek@Sun.COM fi 24410840SGerald.Jelinek@Sun.COM 24510840SGerald.Jelinek@Sun.COM if [ ! -d $ZONEROOT ]; then 24610840SGerald.Jelinek@Sun.COM /usr/bin/mkdir -m 0755 -p $ZONEROOT || \ 24710840SGerald.Jelinek@Sun.COM fail_fatal "$f_mkdir" "$ZONEROOT" 24810840SGerald.Jelinek@Sun.COM fi 24910840SGerald.Jelinek@Sun.COM /usr/bin/chmod 700 $ZONEPATH || fail_fatal "$f_chmod" "$ZONEPATH" 25010840SGerald.Jelinek@Sun.COM 251*12030Sgerald.jelinek@sun.com mount -F zfs $ACTIVE_DS $ZONEROOT || fail_fatal "$f_zfs_mount" 25210840SGerald.Jelinek@Sun.COM} 25310840SGerald.Jelinek@Sun.COM 25410840SGerald.Jelinek@Sun.COM# 25510840SGerald.Jelinek@Sun.COM# Before booting the zone we may need to create a few mnt points, just in 25610840SGerald.Jelinek@Sun.COM# case they don't exist for some reason. 25710840SGerald.Jelinek@Sun.COM# 25810840SGerald.Jelinek@Sun.COM# Whenever we reach into the zone while running in the global zone we 25910840SGerald.Jelinek@Sun.COM# need to validate that none of the interim directories are symlinks 26010840SGerald.Jelinek@Sun.COM# that could cause us to inadvertently modify the global zone. 26110840SGerald.Jelinek@Sun.COM# 26210840SGerald.Jelinek@Sun.COMmk_zone_dirs() { 26310840SGerald.Jelinek@Sun.COM vlog "$v_mkdirs" 26410840SGerald.Jelinek@Sun.COM if [[ ! -f $ZONEROOT/tmp && ! -d $ZONEROOT/tmp ]]; then 26510840SGerald.Jelinek@Sun.COM mkdir -m 1777 -p $ZONEROOT/tmp || exit $EXIT_CODE 26610840SGerald.Jelinek@Sun.COM fi 26710840SGerald.Jelinek@Sun.COM if [[ ! -f $ZONEROOT/var/run && ! -d $ZONEROOT/var/run ]]; then 26810840SGerald.Jelinek@Sun.COM mkdir -m 1755 -p $ZONEROOT/var/run || exit $EXIT_CODE 26910840SGerald.Jelinek@Sun.COM fi 27010840SGerald.Jelinek@Sun.COM if [[ ! -f $ZONEROOT/var/tmp && ! -d $ZONEROOT/var/tmp ]]; then 27110840SGerald.Jelinek@Sun.COM mkdir -m 1777 -p $ZONEROOT/var/tmp || exit $EXIT_CODE 27210840SGerald.Jelinek@Sun.COM fi 27310840SGerald.Jelinek@Sun.COM if [[ ! -h $ZONEROOT/etc && ! -f $ZONEROOT/etc/mnttab ]]; then 27410840SGerald.Jelinek@Sun.COM /usr/bin/touch $ZONEROOT/etc/mnttab || exit $EXIT_CODE 27510840SGerald.Jelinek@Sun.COM /usr/bin/chmod 444 $ZONEROOT/etc/mnttab || exit $EXIT_CODE 27610840SGerald.Jelinek@Sun.COM fi 27710840SGerald.Jelinek@Sun.COM if [[ ! -f $ZONEROOT/proc && ! -d $ZONEROOT/proc ]]; then 27810840SGerald.Jelinek@Sun.COM mkdir -m 755 -p $ZONEROOT/proc || exit $EXIT_CODE 27910840SGerald.Jelinek@Sun.COM fi 28010840SGerald.Jelinek@Sun.COM if [[ ! -f $ZONEROOT/dev && ! -d $ZONEROOT/dev ]]; then 28110840SGerald.Jelinek@Sun.COM mkdir -m 755 -p $ZONEROOT/dev || exit $EXIT_CODE 28210840SGerald.Jelinek@Sun.COM fi 28310840SGerald.Jelinek@Sun.COM if [[ ! -h $ZONEROOT/etc && ! -h $ZONEROOT/etc/svc && \ 28410840SGerald.Jelinek@Sun.COM ! -d $ZONEROOT/etc/svc ]]; then 28510840SGerald.Jelinek@Sun.COM mkdir -m 755 -p $ZONEROOT/etc/svc/volatile || exit $EXIT_CODE 28610840SGerald.Jelinek@Sun.COM fi 28710840SGerald.Jelinek@Sun.COM} 28810840SGerald.Jelinek@Sun.COM 28910840SGerald.Jelinek@Sun.COM# 29010840SGerald.Jelinek@Sun.COM# We're sys-unconfig-ing the zone. This will normally halt the zone, however 29110840SGerald.Jelinek@Sun.COM# there are problems with sys-unconfig and it can hang when the zone is booted 29210840SGerald.Jelinek@Sun.COM# to milestone=none. Sys-unconfig also sometimes hangs halting the zone. 29310840SGerald.Jelinek@Sun.COM# Thus, we take some care to workaround these sys-unconfig limitations. 29410840SGerald.Jelinek@Sun.COM# 29510840SGerald.Jelinek@Sun.COM# On entry we expect the zone to be booted. We use sys-unconfig -R to make it 29610840SGerald.Jelinek@Sun.COM# think its working on an alternate root and let the caller halt the zone. 29710840SGerald.Jelinek@Sun.COM# 29810840SGerald.Jelinek@Sun.COMsysunconfig_zone() { 29910840SGerald.Jelinek@Sun.COM /usr/sbin/zlogin -S $ZONENAME /usr/sbin/sys-unconfig -R /./ \ 30010840SGerald.Jelinek@Sun.COM >/dev/null 2>&1 30110840SGerald.Jelinek@Sun.COM if (( $? != 0 )); then 30210840SGerald.Jelinek@Sun.COM error "$e_unconfig" 30310840SGerald.Jelinek@Sun.COM return 1 30410840SGerald.Jelinek@Sun.COM fi 30510840SGerald.Jelinek@Sun.COM 30610840SGerald.Jelinek@Sun.COM return 0 30710840SGerald.Jelinek@Sun.COM} 30811771Sgerald.jelinek@sun.com 30911771Sgerald.jelinek@sun.com# 31011771Sgerald.jelinek@sun.com# Get zone's uuid for service tag. 31111771Sgerald.jelinek@sun.com# 31211771Sgerald.jelinek@sun.comget_inst_uuid() 31311771Sgerald.jelinek@sun.com{ 31411771Sgerald.jelinek@sun.com typeset ZONENAME="$1" 31511771Sgerald.jelinek@sun.com 31611771Sgerald.jelinek@sun.com ZONEUUID=`zoneadm -z $ZONENAME list -p | nawk -F: '{print $5}'` 31711771Sgerald.jelinek@sun.com [[ $? -ne 0 || -z $ZONEUUID ]] && return 1 31811771Sgerald.jelinek@sun.com 31911771Sgerald.jelinek@sun.com INSTANCE_UUID="urn:st:${ZONEUUID}" 32011771Sgerald.jelinek@sun.com return 0 32111771Sgerald.jelinek@sun.com} 32211771Sgerald.jelinek@sun.com 32311771Sgerald.jelinek@sun.com# 32411771Sgerald.jelinek@sun.com# Add a service tag for a given zone. We use two UUIDs-- the first, 32511771Sgerald.jelinek@sun.com# the Product UUID, comes from the Sun swoRDFish ontology. The second 32611771Sgerald.jelinek@sun.com# is the UUID of the zone itself, which forms the instance UUID. 32711771Sgerald.jelinek@sun.com# 32811771Sgerald.jelinek@sun.comadd_svc_tag() 32911771Sgerald.jelinek@sun.com{ 33011771Sgerald.jelinek@sun.com typeset ZONENAME="$1" 33111771Sgerald.jelinek@sun.com typeset SOURCE="$2" 33211771Sgerald.jelinek@sun.com 33311771Sgerald.jelinek@sun.com if [ ! -x $STCLIENT ]; then 33411771Sgerald.jelinek@sun.com vlog "$v_no_tags" 33511771Sgerald.jelinek@sun.com return 0 33611771Sgerald.jelinek@sun.com fi 33711771Sgerald.jelinek@sun.com 33811771Sgerald.jelinek@sun.com get_inst_uuid "$ZONENAME" || (error "$e_bad_uuid"; return 1) 33911771Sgerald.jelinek@sun.com 34011771Sgerald.jelinek@sun.com vlog "$v_addtag" "$INSTANCE_UUID" 34111771Sgerald.jelinek@sun.com $STCLIENT -a \ 34211771Sgerald.jelinek@sun.com -p "$ST_PRODUCT_NAME" \ 34311771Sgerald.jelinek@sun.com -e "$ST_PRODUCT_REV" \ 34411771Sgerald.jelinek@sun.com -t "$ST_PRODUCT_UUID" \ 34511771Sgerald.jelinek@sun.com -i "$INSTANCE_UUID" \ 34611771Sgerald.jelinek@sun.com -P "none" \ 34711771Sgerald.jelinek@sun.com -m "Sun" \ 34811771Sgerald.jelinek@sun.com -A `uname -p` \ 34911771Sgerald.jelinek@sun.com -z "$ZONENAME" \ 35011771Sgerald.jelinek@sun.com -S "$SOURCE" >/dev/null 2>&1 35111771Sgerald.jelinek@sun.com 35211771Sgerald.jelinek@sun.com err=$? 35311771Sgerald.jelinek@sun.com 35411771Sgerald.jelinek@sun.com # 226 means "duplicate record," which we can ignore. 35511771Sgerald.jelinek@sun.com if [[ $err -ne 0 && $err -ne 226 ]]; then 35611771Sgerald.jelinek@sun.com error "$e_addtag_fail" "$err" 35711771Sgerald.jelinek@sun.com return 1 35811771Sgerald.jelinek@sun.com fi 35911771Sgerald.jelinek@sun.com return 0 36011771Sgerald.jelinek@sun.com} 36111771Sgerald.jelinek@sun.com 36211771Sgerald.jelinek@sun.com# 36311771Sgerald.jelinek@sun.com# Remove a service tag for a given zone. 36411771Sgerald.jelinek@sun.com# 36511771Sgerald.jelinek@sun.comdel_svc_tag() 36611771Sgerald.jelinek@sun.com{ 36711771Sgerald.jelinek@sun.com typeset ZONENAME="$1" 36811771Sgerald.jelinek@sun.com 36911771Sgerald.jelinek@sun.com if [ ! -x $STCLIENT ]; then 37011771Sgerald.jelinek@sun.com vlog "$v_no_tags" 37111771Sgerald.jelinek@sun.com return 0 37211771Sgerald.jelinek@sun.com fi 37311771Sgerald.jelinek@sun.com 37411771Sgerald.jelinek@sun.com get_inst_uuid "$ZONENAME" || (error "$e_bad_uuid"; return 1) 37511771Sgerald.jelinek@sun.com 37611771Sgerald.jelinek@sun.com vlog "$v_deltag" "$INSTANCE_UUID" 37711771Sgerald.jelinek@sun.com $STCLIENT -d -i "$INSTANCE_UUID" >/dev/null 2>&1 37811771Sgerald.jelinek@sun.com return 0 37911771Sgerald.jelinek@sun.com} 380