src/brand/common.ksh
author johansen <johansen@opensolaris.org>
Fri, 06 May 2011 17:24:48 -0700
changeset 2338 63a4d56416c6
parent 2321 5741d6cd0988
child 2339 aa5954c06b9d
permissions -rw-r--r--
18240 zone proxy needed 18265 pkg.sysrepo has weird notions about maximum port and cache size
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
547
9a267e76a197 3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff changeset
     1
#
9a267e76a197 3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff changeset
     2
# CDDL HEADER START
9a267e76a197 3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff changeset
     3
#
9a267e76a197 3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff changeset
     4
# The contents of this file are subject to the terms of the
9a267e76a197 3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff changeset
     5
# Common Development and Distribution License (the "License").
9a267e76a197 3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff changeset
     6
# You may not use this file except in compliance with the License.
9a267e76a197 3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff changeset
     7
#
9a267e76a197 3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff changeset
     8
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9a267e76a197 3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff changeset
     9
# or http://www.opensolaris.org/os/licensing.
9a267e76a197 3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff changeset
    10
# See the License for the specific language governing permissions
9a267e76a197 3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff changeset
    11
# and limitations under the License.
9a267e76a197 3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff changeset
    12
#
9a267e76a197 3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff changeset
    13
# When distributing Covered Code, include this CDDL HEADER in each
9a267e76a197 3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff changeset
    14
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
9a267e76a197 3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff changeset
    15
# If applicable, add the following below this CDDL HEADER, with the
9a267e76a197 3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff changeset
    16
# fields enclosed by brackets "[]" replaced with your own identifying
9a267e76a197 3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff changeset
    17
# information: Portions Copyright [yyyy] [name of copyright owner]
9a267e76a197 3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff changeset
    18
#
9a267e76a197 3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff changeset
    19
# CDDL HEADER END
9a267e76a197 3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff changeset
    20
#
1879
7dc50f542f19 14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents: 1709
diff changeset
    21
547
9a267e76a197 3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff changeset
    22
#
2173
3f44e4b7f94f 16274 nit in error message from common.ksh:fail_zonepath_in_rootds()
Dan Price <daniel.price@oracle.com>
parents: 2163
diff changeset
    23
# Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
547
9a267e76a197 3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff changeset
    24
#
9a267e76a197 3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff changeset
    25
2235
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
    26
#
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
    27
# Only change PATH if you give full consideration to GNU or other variants
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
    28
# of common commands having different arguments and output.  Setting PATH is
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
    29
# and not using the full path to executables provides a performance improvement
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
    30
# by using the ksh builtin equivalent of many common commands.
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
    31
#
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
    32
export PATH=/usr/bin:/usr/sbin
1483
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
    33
unset LD_LIBRARY_PATH
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
    34
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
    35
. /usr/lib/brand/shared/common.ksh
547
9a267e76a197 3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff changeset
    36
9a267e76a197 3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff changeset
    37
PROP_PARENT="org.opensolaris.libbe:parentbe"
9a267e76a197 3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff changeset
    38
PROP_ACTIVE="org.opensolaris.libbe:active"
2235
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
    39
PROP_BE_HANDLE="com.oracle.libbe:nbe_handle"
547
9a267e76a197 3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff changeset
    40
1483
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
    41
f_incompat_options=$(gettext "cannot specify both %s and %s options")
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
    42
f_sanity_detail=$(gettext  "Missing %s at %s")
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
    43
f_sanity_sparse=$(gettext  "Is this a sparse zone image?  The image must be whole-root.")
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
    44
sanity_ok=$(gettext     "  Sanity Check: Passed.  Looks like an OpenSolaris system.")
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
    45
sanity_fail=$(gettext   "  Sanity Check: FAILED (see log for details).")
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
    46
sanity_fail_vers=$(gettext  "  Sanity Check: the Solaris image (release %s) is not an OpenSolaris image and cannot be installed in this type of branded zone.")
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
    47
install_fail=$(gettext  "        Result: *** Installation FAILED ***")
2173
3f44e4b7f94f 16274 nit in error message from common.ksh:fail_zonepath_in_rootds()
Dan Price <daniel.price@oracle.com>
parents: 2163
diff changeset
    48
f_zfs_in_root=$(gettext "Installing a zone inside of the root pool's 'ROOT' dataset is unsupported.")
547
9a267e76a197 3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff changeset
    49
f_root_create=$(gettext "Unable to create the zone's ZFS dataset mountpoint.")
1483
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
    50
f_no_gzbe=$(gettext "unable to determine global zone boot environment.")
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
    51
f_multiple_ds=$(gettext "multiple active datasets.")
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
    52
f_no_active_ds=$(gettext "no active dataset.")
1493
625950c12e71 3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents: 1483
diff changeset
    53
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")
547
9a267e76a197 3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff changeset
    54
f_zfs_mount=$(gettext "Unable to mount the zone's ZFS dataset.")
9a267e76a197 3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff changeset
    55
1111
26c3e2407c53 8570 zone installer needs support for ssl certs & keys
Dan Price <dp@eng.sun.com>
parents: 1091
diff changeset
    56
f_safedir=$(gettext "Expected %s to be a directory.")
26c3e2407c53 8570 zone installer needs support for ssl certs & keys
Dan Price <dp@eng.sun.com>
parents: 1091
diff changeset
    57
f_cp=$(gettext "Failed to cp %s %s.")
26c3e2407c53 8570 zone installer needs support for ssl certs & keys
Dan Price <dp@eng.sun.com>
parents: 1091
diff changeset
    58
f_cp_unsafe=$(gettext "Failed to safely copy %s to %s.")
26c3e2407c53 8570 zone installer needs support for ssl certs & keys
Dan Price <dp@eng.sun.com>
parents: 1091
diff changeset
    59
2338
63a4d56416c6 18240 zone proxy needed
johansen <johansen@opensolaris.org>
parents: 2321
diff changeset
    60
f_sysrepo_fail=$(gettext "Unable to enable svc:/application/pkg/system-repository, please enable the service manually.")
63a4d56416c6 18240 zone proxy needed
johansen <johansen@opensolaris.org>
parents: 2321
diff changeset
    61
f_zones_proxyd_fail=$(gettext "Unable to enable svc:/system/zones-proxyd, please enable the service manually.")
63a4d56416c6 18240 zone proxy needed
johansen <johansen@opensolaris.org>
parents: 2321
diff changeset
    62
f_set_sysrepo_prop_fail=$(gettext "Unable to set the use-system-repo property.")
63a4d56416c6 18240 zone proxy needed
johansen <johansen@opensolaris.org>
parents: 2321
diff changeset
    63
1483
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
    64
m_brnd_usage=$(gettext "brand-specific usage: ")
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
    65
1493
625950c12e71 3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents: 1483
diff changeset
    66
v_unconfig=$(gettext "Performing zone sys-unconfig")
625950c12e71 3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents: 1483
diff changeset
    67
e_unconfig=$(gettext "sys-unconfig failed")
625950c12e71 3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents: 1483
diff changeset
    68
v_mounting=$(gettext "Mounting the zone")
625950c12e71 3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents: 1483
diff changeset
    69
e_badmount=$(gettext "Zone mount failed")
625950c12e71 3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents: 1483
diff changeset
    70
v_unmount=$(gettext "Unmounting zone")
625950c12e71 3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents: 1483
diff changeset
    71
e_badunmount=$(gettext "Zone unmount failed")
625950c12e71 3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents: 1483
diff changeset
    72
e_exitfail=$(gettext "Postprocessing failed.")
2243
526fc99bbf2d 17959 p2v of older ipkg images fails
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2235
diff changeset
    73
v_update_format=$(gettext "Updating image format")
526fc99bbf2d 17959 p2v of older ipkg images fails
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2235
diff changeset
    74
e_update_format=$(gettext "Updating image format failed")
1493
625950c12e71 3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents: 1483
diff changeset
    75
1483
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
    76
m_complete=$(gettext    "        Done: Installation completed in %s seconds.")
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
    77
m_postnote=$(gettext    "  Next Steps: Boot the zone, then log into the zone console (zlogin -C)")
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
    78
m_postnote2=$(gettext "              to complete the configuration process.")
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
    79
1493
625950c12e71 3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents: 1483
diff changeset
    80
is_brand_labeled() {
2235
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
    81
	if [[ -z $ALTROOT ]]; then
2027
f2e9f684e5be 16805 mount of ipkg zone in alternate root fails
Susan Kamm-Worrell <Susan.Kamm-Worrell@Sun.COM>
parents: 1879
diff changeset
    82
		AR_OPTIONS=""
f2e9f684e5be 16805 mount of ipkg zone in alternate root fails
Susan Kamm-Worrell <Susan.Kamm-Worrell@Sun.COM>
parents: 1879
diff changeset
    83
	else
f2e9f684e5be 16805 mount of ipkg zone in alternate root fails
Susan Kamm-Worrell <Susan.Kamm-Worrell@Sun.COM>
parents: 1879
diff changeset
    84
		AR_OPTIONS="-R $ALTROOT"
f2e9f684e5be 16805 mount of ipkg zone in alternate root fails
Susan Kamm-Worrell <Susan.Kamm-Worrell@Sun.COM>
parents: 1879
diff changeset
    85
	fi
f2e9f684e5be 16805 mount of ipkg zone in alternate root fails
Susan Kamm-Worrell <Susan.Kamm-Worrell@Sun.COM>
parents: 1879
diff changeset
    86
	brand=$(/usr/sbin/zoneadm $AR_OPTIONS -z $ZONENAME \
f2e9f684e5be 16805 mount of ipkg zone in alternate root fails
Susan Kamm-Worrell <Susan.Kamm-Worrell@Sun.COM>
parents: 1879
diff changeset
    87
		list -p | awk -F: '{print $6}')
1493
625950c12e71 3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents: 1483
diff changeset
    88
	[[ $brand == "labeled" ]] && return 1
625950c12e71 3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents: 1483
diff changeset
    89
	return 0
625950c12e71 3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents: 1483
diff changeset
    90
}
625950c12e71 3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents: 1483
diff changeset
    91
1879
7dc50f542f19 14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents: 1709
diff changeset
    92
sanity_check() {
1483
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
    93
	typeset dir="$1"
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
    94
	shift
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
    95
	res=0
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
    96
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
    97
	#
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
    98
	# Check for some required directories and make sure this isn't a
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
    99
	# sparse zone image from SXCE.
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
   100
	#
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
   101
	checks="etc etc/svc var var/svc"
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
   102
	for x in $checks; do
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
   103
		if [[ ! -e $dir/$x ]]; then
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
   104
			log "$f_sanity_detail" "$x" "$dir"
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
   105
			res=1
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
   106
		fi
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
   107
	done
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
   108
	if (( $res != 0 )); then
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
   109
		log "$f_sanity_sparse"
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
   110
		log "$sanity_fail"
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
   111
		fatal "$install_fail" "$ZONENAME"
1504
265a1d6b86bd 9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents: 1493
diff changeset
   112
	fi
1483
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
   113
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
   114
	# Check for existence of pkg command.
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
   115
	if [[ ! -x $dir/usr/bin/pkg ]]; then
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
   116
		log "$f_sanity_detail" "usr/bin/pkg" "$dir"
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
   117
		log "$sanity_fail"
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
   118
		fatal "$install_fail" "$ZONENAME"
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
   119
	fi
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
   120
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
   121
	#
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
   122
	# XXX There should be a better way to do this.
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
   123
	# Check image release.  We only work on the same minor release as the
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
   124
	# system is running.  The INST_RELEASE file doesn't exist with IPS on
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
   125
	# OpenSolaris, so its presence means we have an earlier Solaris
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
   126
	# (i.e. non-OpenSolaris) image.
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
   127
	#
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
   128
	if [[ -f "$dir/var/sadm/system/admin/INST_RELEASE" ]]; then
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
   129
		image_vers=$(nawk -F= '{if ($1 == "VERSION") print $2}' \
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
   130
		    $dir/var/sadm/system/admin/INST_RELEASE)
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
   131
		vlog "$sanity_fail_vers" "$image_vers"
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
   132
		fatal "$install_fail" "$ZONENAME"
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
   133
	fi
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
   134
	
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
   135
	vlog "$sanity_ok"
547
9a267e76a197 3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff changeset
   136
}
9a267e76a197 3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff changeset
   137
2235
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   138
function get_current_gzbe {
547
9a267e76a197 3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff changeset
   139
	#
2027
f2e9f684e5be 16805 mount of ipkg zone in alternate root fails
Susan Kamm-Worrell <Susan.Kamm-Worrell@Sun.COM>
parents: 1879
diff changeset
   140
	# If there is no alternate root (normal case) then set the
f2e9f684e5be 16805 mount of ipkg zone in alternate root fails
Susan Kamm-Worrell <Susan.Kamm-Worrell@Sun.COM>
parents: 1879
diff changeset
   141
	# global zone boot environment by finding the boot environment
f2e9f684e5be 16805 mount of ipkg zone in alternate root fails
Susan Kamm-Worrell <Susan.Kamm-Worrell@Sun.COM>
parents: 1879
diff changeset
   142
	# that is active now.
f2e9f684e5be 16805 mount of ipkg zone in alternate root fails
Susan Kamm-Worrell <Susan.Kamm-Worrell@Sun.COM>
parents: 1879
diff changeset
   143
	# If a zone exists in a boot environment mounted on an alternate root,
f2e9f684e5be 16805 mount of ipkg zone in alternate root fails
Susan Kamm-Worrell <Susan.Kamm-Worrell@Sun.COM>
parents: 1879
diff changeset
   144
	# then find the boot environment where the alternate root is mounted.
547
9a267e76a197 3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff changeset
   145
	#
2235
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   146
	CURRENT_GZBE=$(beadm list -H | nawk -v alt=$ALTROOT -F\; '{
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   147
		if (length(alt) == 0) {
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   148
		    # Field 3 is the BE status.  'N' is the active BE.
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   149
		    if ($3 !~ "N")
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   150
			next
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   151
		} else {
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   152
		    # Field 4 is the BE mountpoint.
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   153
		    if ($4 != alt)
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   154
		next
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   155
		}
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   156
		# Field 2 is the BE UUID
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   157
		print $2
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   158
	    }')
547
9a267e76a197 3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff changeset
   159
	if [ -z "$CURRENT_GZBE" ]; then
2235
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   160
		return 1
547
9a267e76a197 3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff changeset
   161
	fi
2235
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   162
	return 0
547
9a267e76a197 3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff changeset
   163
}
1091
fc73bc2d78ce 7490 ipkg brand attach needs similar logic to pkgcreatezone for 'entire' incorporation
Dan Price <dp@eng.sun.com>
parents: 954
diff changeset
   164
fc73bc2d78ce 7490 ipkg brand attach needs similar logic to pkgcreatezone for 'entire' incorporation
Dan Price <dp@eng.sun.com>
parents: 954
diff changeset
   165
#
2235
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   166
# get_active_be zone
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   167
#
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   168
# Finds the active boot environment for the given zone.
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   169
#
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   170
# Arguments:
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   171
#
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   172
#  zone		zone structure initialized with init_zone
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   173
#
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   174
# Globals:
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   175
#
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   176
#  CURRENT_GZBE	Current global zone boot environment.  If not already set,
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   177
#		it will be set.
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   178
#
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   179
# Returns:
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   180
#
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   181
#  0 on success, else 1.
1493
625950c12e71 3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents: 1483
diff changeset
   182
#
2235
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   183
function get_active_be {
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   184
	typeset -n zone=$1
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   185
	typeset active_ds=
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   186
	typeset tab=$(printf "\t")
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   187
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   188
	[[ -z "$CURRENT_GZBE" ]] && get_current_gzbe
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   189
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   190
	typeset name parent active
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   191
	zfs list -H -r -d 1 -t filesystem -o name,$PROP_PARENT,$PROP_ACTIVE \
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   192
	    ${zone.ROOT_ds} | while IFS=$tab read name parent active ; do
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   193
		[[ $parent == "$CURRENT_GZBE" ]] || continue
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   194
		[[ $active == on ]] || continue
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   195
		vlog "Found active dataset %s" "$name"
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   196
		if [[ -n "$active_ds" ]] ; then
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   197
			error "$f_multiple_ds"
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   198
			return 1
1493
625950c12e71 3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents: 1483
diff changeset
   199
		fi
2235
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   200
		active_ds=$name
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   201
	done
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   202
	if [[ -z $active_ds ]]; then
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   203
		error "$f_no_active_ds"
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   204
		return 1
1493
625950c12e71 3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents: 1483
diff changeset
   205
	fi
625950c12e71 3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents: 1483
diff changeset
   206
2235
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   207
	zone.active_ds=$active_ds
1493
625950c12e71 3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents: 1483
diff changeset
   208
}
625950c12e71 3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents: 1483
diff changeset
   209
2235
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   210
function set_active_be {
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   211
	typeset -n zone="$1"
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   212
	typeset be="$2"
1483
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
   213
2235
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   214
	[[ -z "$CURRENT_GZBE" ]] && get_current_gzbe
1483
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
   215
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
   216
	#
2235
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   217
	# Turn off the active property on BE's with the same GZBE
1483
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
   218
	#
2235
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   219
	zfs list -H -r -d 1 -t filesystem -o name,$PROP_PARENT,$PROP_ACTIVE \
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   220
	    ${zone.ROOT_ds} | while IFS=$tab read name parent active ; do
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   221
		[[ $parent == "$CURRENT_GZBE" ]] || continue
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   222
		[[ $active == on ]] || continue
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   223
		[[ $name ==  "${zone.ROOT_ds}/$be" ]] && continue
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   224
		vlog "Deactivating active dataset %s" "$name"
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   225
		zfs set $PROP_ACTIVE=off "$name" || return 1
1483
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
   226
	done
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
   227
2235
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   228
	zone.active_ds="${zone.ROOT_ds}/$be"
1483
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
   229
2235
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   230
	zfs set "$PROP_PARENT=$CURRENT_GZBE" ${zone.active_ds} \
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   231
	    || return 1
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   232
	zfs set "$PROP_ACTIVE=on" ${zone.active_ds} || return 1
1483
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
   233
2235
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   234
	zfs set "$PROP_BE_HANDLE=on" "${zone.rpool_ds}" || return 1
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   235
1f446820dcb0 17791 ipkg brand needs to be in sync with revised dataset layout
Mike Gerdts <mike.gerdts@oracle.com>
parents: 2219
diff changeset
   236
	return 0
1483
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
   237
}
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
   238
2276b6786711 6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents: 1327
diff changeset
   239
#
1493
625950c12e71 3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents: 1483
diff changeset
   240
# Run sys-unconfig on the zone.
625950c12e71 3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents: 1483
diff changeset
   241
#
625950c12e71 3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents: 1483
diff changeset
   242
unconfigure_zone() {
625950c12e71 3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents: 1483
diff changeset
   243
	vlog "$v_unconfig"
625950c12e71 3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents: 1483
diff changeset
   244
625950c12e71 3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents: 1483
diff changeset
   245
	vlog "$v_mounting"
625950c12e71 3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents: 1483
diff changeset
   246
	ZONE_IS_MOUNTED=1
625950c12e71 3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents: 1483
diff changeset
   247
	zoneadm -z $ZONENAME mount -f || fatal "$e_badmount"
625950c12e71 3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents: 1483
diff changeset
   248
2321
5741d6cd0988 17995 Add packages required by SC to pkgcreatezone
Susan Kamm-Worrell <Susan.Kamm-Worrell@Sun.COM>
parents: 2315
diff changeset
   249
	# If unconfig service exists and is online then use sysconfig
5741d6cd0988 17995 Add packages required by SC to pkgcreatezone
Susan Kamm-Worrell <Susan.Kamm-Worrell@Sun.COM>
parents: 2315
diff changeset
   250
	SC_ONLINE=$(svcprop -p restarter/state \
5741d6cd0988 17995 Add packages required by SC to pkgcreatezone
Susan Kamm-Worrell <Susan.Kamm-Worrell@Sun.COM>
parents: 2315
diff changeset
   251
	    svc:/milestone/unconfig:default 2> /dev/null)
5741d6cd0988 17995 Add packages required by SC to pkgcreatezone
Susan Kamm-Worrell <Susan.Kamm-Worrell@Sun.COM>
parents: 2315
diff changeset
   252
	if (( $? == 0 )) && [[ $SC_ONLINE == "online" ]]; then
5741d6cd0988 17995 Add packages required by SC to pkgcreatezone
Susan Kamm-Worrell <Susan.Kamm-Worrell@Sun.COM>
parents: 2315
diff changeset
   253
		zlogin -S $ZONENAME "export _UNCONFIG_ALT_ROOT=/a; \
5741d6cd0988 17995 Add packages required by SC to pkgcreatezone
Susan Kamm-Worrell <Susan.Kamm-Worrell@Sun.COM>
parents: 2315
diff changeset
   254
		    /usr/sbin/sysconfig unconfigure -g system; \
5741d6cd0988 17995 Add packages required by SC to pkgcreatezone
Susan Kamm-Worrell <Susan.Kamm-Worrell@Sun.COM>
parents: 2315
diff changeset
   255
		    export _UNCONFIG_ALT_ROOT= ;" \
5741d6cd0988 17995 Add packages required by SC to pkgcreatezone
Susan Kamm-Worrell <Susan.Kamm-Worrell@Sun.COM>
parents: 2315
diff changeset
   256
		    </dev/null >/dev/null 2>&1
5741d6cd0988 17995 Add packages required by SC to pkgcreatezone
Susan Kamm-Worrell <Susan.Kamm-Worrell@Sun.COM>
parents: 2315
diff changeset
   257
	else
5741d6cd0988 17995 Add packages required by SC to pkgcreatezone
Susan Kamm-Worrell <Susan.Kamm-Worrell@Sun.COM>
parents: 2315
diff changeset
   258
		zlogin -S $ZONENAME /usr/sbin/sys-unconfig -R /a \
5741d6cd0988 17995 Add packages required by SC to pkgcreatezone
Susan Kamm-Worrell <Susan.Kamm-Worrell@Sun.COM>
parents: 2315
diff changeset
   259
		    </dev/null >/dev/null 2>&1
5741d6cd0988 17995 Add packages required by SC to pkgcreatezone
Susan Kamm-Worrell <Susan.Kamm-Worrell@Sun.COM>
parents: 2315
diff changeset
   260
	fi
5741d6cd0988 17995 Add packages required by SC to pkgcreatezone
Susan Kamm-Worrell <Susan.Kamm-Worrell@Sun.COM>
parents: 2315
diff changeset
   261
1879
7dc50f542f19 14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents: 1709
diff changeset
   262
	if (( $? != 0 )); then
7dc50f542f19 14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents: 1709
diff changeset
   263
		error "$e_unconfig"
1493
625950c12e71 3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents: 1483
diff changeset
   264
		failed=1
1879
7dc50f542f19 14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents: 1709
diff changeset
   265
	fi
1493
625950c12e71 3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents: 1483
diff changeset
   266
625950c12e71 3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents: 1483
diff changeset
   267
	vlog "$v_unmount"
625950c12e71 3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents: 1483
diff changeset
   268
	zoneadm -z $ZONENAME unmount || fatal "$e_badunmount"
625950c12e71 3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents: 1483
diff changeset
   269
	ZONE_IS_MOUNTED=0
625950c12e71 3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents: 1483
diff changeset
   270
625950c12e71 3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents: 1483
diff changeset
   271
	[[ -n $failed ]] && fatal "$e_exitfail"
625950c12e71 3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents: 1483
diff changeset
   272
}
625950c12e71 3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents: 1483
diff changeset
   273
625950c12e71 3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents: 1483
diff changeset
   274
#
1879
7dc50f542f19 14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents: 1709
diff changeset
   275
# Emits to stdout the fmri for the supplied package,
7dc50f542f19 14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents: 1709
diff changeset
   276
# stripped of publisher name and other junk.
7dc50f542f19 14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents: 1709
diff changeset
   277
#
7dc50f542f19 14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents: 1709
diff changeset
   278
get_pkg_fmri() {
7dc50f542f19 14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents: 1709
diff changeset
   279
	typeset pname=$1
7dc50f542f19 14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents: 1709
diff changeset
   280
	typeset pkg_fmri=
7dc50f542f19 14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents: 1709
diff changeset
   281
	typeset info_out=
7dc50f542f19 14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents: 1709
diff changeset
   282
7dc50f542f19 14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents: 1709
diff changeset
   283
	info_out=$(LC_ALL=C $PKG info pkg:/$pname 2>/dev/null)
7dc50f542f19 14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents: 1709
diff changeset
   284
	if [[ $? -ne 0 ]]; then
7dc50f542f19 14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents: 1709
diff changeset
   285
		return 1
7dc50f542f19 14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents: 1709
diff changeset
   286
	fi
7dc50f542f19 14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents: 1709
diff changeset
   287
	pkg_fmri=$(echo $info_out | grep FMRI | cut -d'@' -f 2)
7dc50f542f19 14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents: 1709
diff changeset
   288
	echo "$pname@$pkg_fmri"
7dc50f542f19 14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents: 1709
diff changeset
   289
	return 0
7dc50f542f19 14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents: 1709
diff changeset
   290
}
7dc50f542f19 14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents: 1709
diff changeset
   291
7dc50f542f19 14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents: 1709
diff changeset
   292
#
1091
fc73bc2d78ce 7490 ipkg brand attach needs similar logic to pkgcreatezone for 'entire' incorporation
Dan Price <dp@eng.sun.com>
parents: 954
diff changeset
   293
# Emits to stdout the entire incorporation for this image,
fc73bc2d78ce 7490 ipkg brand attach needs similar logic to pkgcreatezone for 'entire' incorporation
Dan Price <dp@eng.sun.com>
parents: 954
diff changeset
   294
# stripped of publisher name and other junk.
fc73bc2d78ce 7490 ipkg brand attach needs similar logic to pkgcreatezone for 'entire' incorporation
Dan Price <dp@eng.sun.com>
parents: 954
diff changeset
   295
#
fc73bc2d78ce 7490 ipkg brand attach needs similar logic to pkgcreatezone for 'entire' incorporation
Dan Price <dp@eng.sun.com>
parents: 954
diff changeset
   296
get_entire_incorp() {
1879
7dc50f542f19 14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents: 1709
diff changeset
   297
	get_pkg_fmri entire
7dc50f542f19 14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents: 1709
diff changeset
   298
	return $?
1091
fc73bc2d78ce 7490 ipkg brand attach needs similar logic to pkgcreatezone for 'entire' incorporation
Dan Price <dp@eng.sun.com>
parents: 954
diff changeset
   299
}
fc73bc2d78ce 7490 ipkg brand attach needs similar logic to pkgcreatezone for 'entire' incorporation
Dan Price <dp@eng.sun.com>
parents: 954
diff changeset
   300
fc73bc2d78ce 7490 ipkg brand attach needs similar logic to pkgcreatezone for 'entire' incorporation
Dan Price <dp@eng.sun.com>
parents: 954
diff changeset
   301
#
1535
a6278def0881 12995 can't install zone on b128
<gerald.jelinek@sun.com>
parents: 1504
diff changeset
   302
# Handle pkg exit code.  Exit 0 means Command succeeded, exit 4 means
a6278def0881 12995 can't install zone on b128
<gerald.jelinek@sun.com>
parents: 1504
diff changeset
   303
# No changes were made - nothing to do.  Any other exit code is an error.
a6278def0881 12995 can't install zone on b128
<gerald.jelinek@sun.com>
parents: 1504
diff changeset
   304
#
a6278def0881 12995 can't install zone on b128
<gerald.jelinek@sun.com>
parents: 1504
diff changeset
   305
pkg_err_check() {
1879
7dc50f542f19 14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents: 1709
diff changeset
   306
	typeset res=$?
1535
a6278def0881 12995 can't install zone on b128
<gerald.jelinek@sun.com>
parents: 1504
diff changeset
   307
	(( $res != 0 && $res != 4 )) && fail_fatal "$1"
a6278def0881 12995 can't install zone on b128
<gerald.jelinek@sun.com>
parents: 1504
diff changeset
   308
}
2338
63a4d56416c6 18240 zone proxy needed
johansen <johansen@opensolaris.org>
parents: 2321
diff changeset
   309
63a4d56416c6 18240 zone proxy needed
johansen <johansen@opensolaris.org>
parents: 2321
diff changeset
   310
#
63a4d56416c6 18240 zone proxy needed
johansen <johansen@opensolaris.org>
parents: 2321
diff changeset
   311
# Enable the services needed to perform packaging operations inside a zone.
63a4d56416c6 18240 zone proxy needed
johansen <johansen@opensolaris.org>
parents: 2321
diff changeset
   312
#
63a4d56416c6 18240 zone proxy needed
johansen <johansen@opensolaris.org>
parents: 2321
diff changeset
   313
enable_zones_services() {                                                       
63a4d56416c6 18240 zone proxy needed
johansen <johansen@opensolaris.org>
parents: 2321
diff changeset
   314
	/usr/sbin/svcadm enable -t -s /application/pkg/system-repository
63a4d56416c6 18240 zone proxy needed
johansen <johansen@opensolaris.org>
parents: 2321
diff changeset
   315
	if [[ $? -ne 0 ]]; then
63a4d56416c6 18240 zone proxy needed
johansen <johansen@opensolaris.org>
parents: 2321
diff changeset
   316
		error "$f_sysrepo_fail"
63a4d56416c6 18240 zone proxy needed
johansen <johansen@opensolaris.org>
parents: 2321
diff changeset
   317
		return 1
63a4d56416c6 18240 zone proxy needed
johansen <johansen@opensolaris.org>
parents: 2321
diff changeset
   318
	fi
63a4d56416c6 18240 zone proxy needed
johansen <johansen@opensolaris.org>
parents: 2321
diff changeset
   319
	/usr/sbin/svcadm enable -t -s /system/zones-proxyd
63a4d56416c6 18240 zone proxy needed
johansen <johansen@opensolaris.org>
parents: 2321
diff changeset
   320
	if [[ $? -ne 0 ]]; then
63a4d56416c6 18240 zone proxy needed
johansen <johansen@opensolaris.org>
parents: 2321
diff changeset
   321
		error "$f_zones_proxyd_fail"
63a4d56416c6 18240 zone proxy needed
johansen <johansen@opensolaris.org>
parents: 2321
diff changeset
   322
		return 1
63a4d56416c6 18240 zone proxy needed
johansen <johansen@opensolaris.org>
parents: 2321
diff changeset
   323
	fi
63a4d56416c6 18240 zone proxy needed
johansen <johansen@opensolaris.org>
parents: 2321
diff changeset
   324
	return 0
63a4d56416c6 18240 zone proxy needed
johansen <johansen@opensolaris.org>
parents: 2321
diff changeset
   325
}