common.ksh revision 090f667debfb7792a579172d3f173753762ee29a
#
# 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 2010 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
unset LD_LIBRARY_PATH
export PATH
# Values for service tags.
ST_PRODUCT_NAME="Solaris 10 Containers"
ST_PRODUCT_REV="1.0"
ST_PRODUCT_UUID="urn:uuid:2f459121-dec7-11de-9af7-080020a9ed93"
f_sanity_vers=$(gettext "The image release version must be 10 (got %s), the zone is not usable on this system.")
f_sanity_downrev=$(gettext "The image patch level is downrev for running in a solaris10 branded zone.\n(patchlist %s)")
f_no_active_ds=$(gettext "No active dataset; the zone's ZFS root dataset must be configured as\n\ta zone boot environment.")
f_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")
{
typeset dir="$1"
res=0
#
# Check for some required directories and make sure this isn't a
# sparse zone image.
#
if [[ ! -e $dir/$x ]]; then
log "$f_sanity_detail" "$x" "$dir"
res=1
fi
done
# Files from SUNWcsr and SUNWcsu that are in sparse inherit-pkg-dirs.
if [[ ! -e $dir/$x ]]; then
log "$f_sanity_detail" "$x" "$dir"
res=1
fi
done
fi
return
fi
#
# Check image release to be sure its S10.
#
image_vers="unknown"
fi
res=1
fi
#
# Make sure we have the minimal KU patch we support. These are the
# KUs for S10u8.
#
req_patch="141445-09"
else
req_patch="141444-09"
fi
do
res=1
fi
done
#
# Check the core kernel pkg for the required KU patch.
#
found=0
do
do
if [[ $patch == $req_patch ]]; then
found=1
break
fi
done
break
fi
done
res=1
fi
#
# Check the S10 image for a required version of the emulation.
#
if [[ -f $dir/$VERS_FILE ]]; then
fi
# Now get the current emulation version.
# Verify that the emulation can run this version of S10.
res=1
fi
fi
}
# $1 ZONEPATH_DS
}
#
# Make sure the active dataset is mounted for the zone.
#
# If already mounted then we're done.
mount -F zfs $ACTIVE_DS $zonepath/root || fail_fatal "$f_zfs_mount"
}
#
# Set up ZFS dataset hierarchy for the zone root dataset.
#
# Find the zone's current dataset. This should have been created by
# zoneadm (or the attach hook).
#
# We need to tolerate errors while creating the datasets and making the
# mountpoint, since these could already exist from an attach scenario.
#
if (( $? != 0 )); then
if (( $? != 0 )); then
fi
else
/usr/sbin/zfs set mountpoint=legacy $ZONEPATH_DS/ROOT \
fi
if (( $? != 0 )); then
else
zfs inherit mountpoint $ACTIVE_DS >/dev/null 2>&1
fi
if [ ! -d $ZONEROOT ]; then
fi
mount -F zfs $ACTIVE_DS $ZONEROOT || fail_fatal "$f_zfs_mount"
}
#
# 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.
#
mkdir -m 1777 -p $ZONEROOT/tmp || exit $EXIT_CODE
fi
mkdir -m 1755 -p $ZONEROOT/var/run || exit $EXIT_CODE
fi
mkdir -m 1777 -p $ZONEROOT/var/tmp || exit $EXIT_CODE
fi
fi
mkdir -m 755 -p $ZONEROOT/proc || exit $EXIT_CODE
fi
mkdir -m 755 -p $ZONEROOT/dev || exit $EXIT_CODE
fi
fi
}
#
# We're sys-unconfig-ing the zone. This will normally halt the zone, however
# there are problems with sys-unconfig and it can hang when the zone is booted
# to milestone=none. Sys-unconfig also sometimes hangs halting the zone.
# Thus, we take some care to workaround these sys-unconfig limitations.
#
# On entry we expect the zone to be booted. We use sys-unconfig -R to make it
# think its working on an alternate root and let the caller halt the zone.
#
if (( $? != 0 )); then
return 1
fi
return 0
}
#
# Get zone's uuid for service tag.
#
{
typeset ZONENAME="$1"
INSTANCE_UUID="urn:st:${ZONEUUID}"
return 0
}
#
# Add a service tag for a given zone. We use two UUIDs-- the first,
# the Product UUID, comes from the Sun swoRDFish ontology. The second
# is the UUID of the zone itself, which forms the instance UUID.
#
{
typeset ZONENAME="$1"
typeset SOURCE="$2"
if [ ! -x $STCLIENT ]; then
return 0
fi
$STCLIENT -a \
-P "none" \
-m "Sun" \
err=$?
# 226 means "duplicate record," which we can ignore.
return 1
fi
return 0
}
#
# Remove a service tag for a given zone.
#
{
typeset ZONENAME="$1"
if [ ! -x $STCLIENT ]; then
return 0
fi
return 0
}