author | <gerald.jelinek@sun.com> |
Wed, 02 Dec 2009 14:56:24 -0700 | |
changeset 1535 | a6278def0881 |
parent 1504 | 265a1d6b86bd |
child 1709 | 28592bd37c9d |
permissions | -rw-r--r-- |
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 |
# |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
21 |
# |
954
8614b0c63fb3
4771 zone operations fail with package inventory errors when authority changes
Dan Price <dp@eng.sun.com>
parents:
547
diff
changeset
|
22 |
# Copyright 2009 Sun Microsystems, Inc. All rights reserved. |
547
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
23 |
# Use is subject to license terms. |
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 |
|
1483
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
26 |
unset LD_LIBRARY_PATH |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
27 |
PATH=/usr/bin:/usr/sbin |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
28 |
export PATH |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
29 |
|
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
30 |
. /usr/lib/brand/shared/common.ksh |
547
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
31 |
|
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
32 |
PROP_PARENT="org.opensolaris.libbe:parentbe" |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
33 |
PROP_ACTIVE="org.opensolaris.libbe:active" |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
34 |
|
1483
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
35 |
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
|
36 |
f_sanity_detail=$(gettext "Missing %s at %s") |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
37 |
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
|
38 |
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
|
39 |
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
|
40 |
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
|
41 |
install_fail=$(gettext " Result: *** Installation FAILED ***") |
547
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
42 |
f_zfs_in_root=$(gettext "Installing a zone in the ROOT pool is unsupported.") |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
43 |
f_zfs_create=$(gettext "Unable to create the zone's ZFS dataset.") |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
44 |
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
|
45 |
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
|
46 |
f_no_ds=$(gettext "the zonepath must be a ZFS dataset.\nThe parent directory of the zonepath must be a ZFS dataset so that the\nzonepath ZFS dataset can be created properly.") |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
47 |
f_multiple_ds=$(gettext "multiple active datasets.") |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
48 |
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
|
49 |
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
|
50 |
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
|
51 |
|
1111
26c3e2407c53
8570 zone installer needs support for ssl certs & keys
Dan Price <dp@eng.sun.com>
parents:
1091
diff
changeset
|
52 |
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
|
53 |
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
|
54 |
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
|
55 |
|
1483
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
56 |
m_brnd_usage=$(gettext "brand-specific usage: ") |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
57 |
|
1493
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
58 |
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
|
59 |
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
|
60 |
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
|
61 |
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
|
62 |
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
|
63 |
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
|
64 |
e_exitfail=$(gettext "Postprocessing failed.") |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
65 |
|
1483
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
66 |
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
|
67 |
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
|
68 |
m_postnote2=$(gettext " to complete the configuration process.") |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
69 |
|
547
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
70 |
fail_incomplete() { |
954
8614b0c63fb3
4771 zone operations fail with package inventory errors when authority changes
Dan Price <dp@eng.sun.com>
parents:
547
diff
changeset
|
71 |
printf "ERROR: " 1>&2 |
8614b0c63fb3
4771 zone operations fail with package inventory errors when authority changes
Dan Price <dp@eng.sun.com>
parents:
547
diff
changeset
|
72 |
printf "$@" 1>&2 |
8614b0c63fb3
4771 zone operations fail with package inventory errors when authority changes
Dan Price <dp@eng.sun.com>
parents:
547
diff
changeset
|
73 |
printf "\n" 1>&2 |
547
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
74 |
exit $ZONE_SUBPROC_INCOMPLETE |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
75 |
} |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
76 |
|
1483
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
77 |
fail_usage() { |
954
8614b0c63fb3
4771 zone operations fail with package inventory errors when authority changes
Dan Price <dp@eng.sun.com>
parents:
547
diff
changeset
|
78 |
printf "$@" 1>&2 |
8614b0c63fb3
4771 zone operations fail with package inventory errors when authority changes
Dan Price <dp@eng.sun.com>
parents:
547
diff
changeset
|
79 |
printf "\n" 1>&2 |
1483
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
80 |
printf "$m_brnd_usage" 1>&2 |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
81 |
printf "$m_usage\n" 1>&2 |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
82 |
exit $ZONE_SUBPROC_USAGE |
547
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
83 |
} |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
84 |
|
1493
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
85 |
is_brand_labeled() { |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
86 |
brand=$(/usr/sbin/zoneadm -z $ZONENAME list -p | awk -F: '{print $6}') |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
87 |
[[ $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
|
88 |
return 0 |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
89 |
} |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
90 |
|
1483
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
91 |
sanity_check() |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
92 |
{ |
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 |
|
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
138 |
get_current_gzbe() { |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
139 |
# |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
140 |
# If there is no beadm command then the system doesn't really |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
141 |
# support multiple boot environments. We still want zones to work, |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
142 |
# so simulate the existence of a single boot environment. |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
143 |
# |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
144 |
if [ -x /usr/sbin/beadm ]; then |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
145 |
CURRENT_GZBE=`/usr/sbin/beadm list -H | /usr/bin/nawk -F\; '{ |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
146 |
# Field 3 is the BE status. 'N' is the active BE. |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
147 |
if ($3 ~ "N") |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
148 |
# Field 2 is the BE UUID |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
149 |
print $2 |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
150 |
}'` |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
151 |
else |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
152 |
CURRENT_GZBE="opensolaris" |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
153 |
fi |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
154 |
|
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
155 |
if [ -z "$CURRENT_GZBE" ]; then |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
156 |
fail_fatal "$f_no_gzbe" |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
157 |
fi |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
158 |
} |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
159 |
|
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
160 |
# Find the active dataset under the zonepath dataset to mount on zonepath/root. |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
161 |
# $1 CURRENT_GZBE |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
162 |
# $2 ZONEPATH_DS |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
163 |
get_active_ds() { |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
164 |
ACTIVE_DS=`/usr/sbin/zfs list -H -r -t filesystem \ |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
165 |
-o name,$PROP_PARENT,$PROP_ACTIVE $2/ROOT | \ |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
166 |
/usr/bin/nawk -v gzbe=$1 ' { |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
167 |
if ($1 ~ /ROOT\/[^\/]+$/ && $2 == gzbe && $3 == "on") { |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
168 |
print $1 |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
169 |
if (found == 1) |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
170 |
exit 1 |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
171 |
found = 1 |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
172 |
} |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
173 |
}'` |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
174 |
|
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
175 |
if [ $? -ne 0 ]; then |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
176 |
fail_fatal "$f_multiple_ds" |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
177 |
fi |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
178 |
|
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
179 |
if [ -z "$ACTIVE_DS" ]; then |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
180 |
fail_fatal "$f_no_active_ds" |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
181 |
fi |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
182 |
} |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
183 |
|
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
184 |
# Check that zone is not in the ROOT dataset. |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
185 |
fail_zonepath_in_rootds() { |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
186 |
case $1 in |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
187 |
rpool/ROOT/*) |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
188 |
fail_fatal "$f_zfs_in_root" |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
189 |
break; |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
190 |
;; |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
191 |
*) |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
192 |
break; |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
193 |
;; |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
194 |
esac |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
195 |
} |
1091
fc73bc2d78ce
7490 ipkg brand attach needs similar logic to pkgcreatezone for 'entire' incorporation
Dan Price <dp@eng.sun.com>
parents:
954
diff
changeset
|
196 |
|
fc73bc2d78ce
7490 ipkg brand attach needs similar logic to pkgcreatezone for 'entire' incorporation
Dan Price <dp@eng.sun.com>
parents:
954
diff
changeset
|
197 |
# |
1493
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
198 |
# Make sure the active dataset is mounted for the zone. There are several |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
199 |
# cases to consider: |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
200 |
# 1) First boot of the zone, nothing is mounted |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
201 |
# 2) Zone is halting, active dataset remains the same. |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
202 |
# 3) Zone is halting, there is a new active dataset to mount. |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
203 |
# |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
204 |
mount_active_ds() { |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
205 |
mount -p | cut -d' ' -f3 | egrep -s "^$ZONEPATH/root$" |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
206 |
if (( $? == 0 )); then |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
207 |
# Umount current dataset on the root (it might be an old BE). |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
208 |
umount $ZONEPATH/root |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
209 |
if (( $? != 0 )); then |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
210 |
# The umount failed, leave the old BE mounted. |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
211 |
# Warn about gz process preventing umount. |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
212 |
printf "$f_zfs_unmount" "$ZONEPATH/root" |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
213 |
return |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
214 |
fi |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
215 |
fi |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
216 |
|
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
217 |
# Mount active dataset on the root. |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
218 |
get_current_gzbe |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
219 |
get_zonepath_ds $ZONEPATH |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
220 |
get_active_ds $CURRENT_GZBE $ZONEPATH_DS |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
221 |
|
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
222 |
mount -F zfs $ACTIVE_DS $ZONEPATH/root || fail_fatal "$f_zfs_mount" |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
223 |
} |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
224 |
|
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
225 |
# |
1483
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
226 |
# Set up ZFS dataset hierarchy for the zone root dataset. |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
227 |
# |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
228 |
create_active_ds() { |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
229 |
get_current_gzbe |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
230 |
|
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
231 |
# |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
232 |
# Find the zone's current dataset. This should have been created by |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
233 |
# zoneadm. |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
234 |
# |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
235 |
get_zonepath_ds $zonepath |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
236 |
|
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
237 |
# Check that zone is not in the ROOT dataset. |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
238 |
fail_zonepath_in_rootds $ZONEPATH_DS |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
239 |
|
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
240 |
# |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
241 |
# From here on, errors should cause the zone to be incomplete. |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
242 |
# |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
243 |
int_code=$ZONE_SUBPROC_FATAL |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
244 |
|
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
245 |
# |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
246 |
# We need to tolerate errors while creating the datasets and making the |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
247 |
# mountpoint, since these could already exist from some other BE. |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
248 |
# |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
249 |
|
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
250 |
/usr/sbin/zfs list -H -o name $ZONEPATH_DS/ROOT >/dev/null 2>&1 |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
251 |
if (( $? != 0 )); then |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
252 |
/usr/sbin/zfs create -o mountpoint=legacy \ |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
253 |
-o zoned=on $ZONEPATH_DS/ROOT |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
254 |
if (( $? != 0 )); then |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
255 |
fail_fatal "$f_zfs_create" |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
256 |
fi |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
257 |
fi |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
258 |
|
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
259 |
BENAME=zbe |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
260 |
BENUM=0 |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
261 |
# Try 100 different names before giving up. |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
262 |
while [ $BENUM -lt 100 ]; do |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
263 |
/usr/sbin/zfs create -o $PROP_ACTIVE=on \ |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
264 |
-o $PROP_PARENT=$CURRENT_GZBE \ |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
265 |
-o canmount=noauto $ZONEPATH_DS/ROOT/$BENAME >/dev/null 2>&1 |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
266 |
if (( $? == 0 )); then |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
267 |
break |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
268 |
fi |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
269 |
BENUM=`expr $BENUM + 1` |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
270 |
BENAME="zbe-$BENUM" |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
271 |
done |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
272 |
|
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
273 |
if [ $BENUM -ge 100 ]; then |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
274 |
fail_fatal "$f_zfs_create" |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
275 |
fi |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
276 |
|
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
277 |
if [ ! -d $ZONEROOT ]; then |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
278 |
/usr/bin/mkdir $ZONEROOT |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
279 |
fi |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
280 |
|
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
281 |
/usr/sbin/mount -F zfs $ZONEPATH_DS/ROOT/$BENAME $ZONEROOT || \ |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
282 |
fail_incomplete "$f_zfs_mount" |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
283 |
} |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
284 |
|
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
285 |
# |
1493
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
286 |
# 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
|
287 |
# |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
288 |
unconfigure_zone() { |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
289 |
vlog "$v_unconfig" |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
290 |
|
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
291 |
vlog "$v_mounting" |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
292 |
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
|
293 |
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
|
294 |
|
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
295 |
zlogin -S $ZONENAME /usr/sbin/sys-unconfig -R /a \ |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
296 |
</dev/null >/dev/null 2>&1 |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
297 |
if (( $? != 0 )); then |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
298 |
error "$e_unconfig" |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
299 |
failed=1 |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
300 |
fi |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
301 |
|
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
302 |
vlog "$v_unmount" |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
303 |
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
|
304 |
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
|
305 |
|
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
306 |
[[ -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
|
307 |
} |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
308 |
|
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
309 |
# |
1091
fc73bc2d78ce
7490 ipkg brand attach needs similar logic to pkgcreatezone for 'entire' incorporation
Dan Price <dp@eng.sun.com>
parents:
954
diff
changeset
|
310 |
# 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
|
311 |
# 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
|
312 |
# |
fc73bc2d78ce
7490 ipkg brand attach needs similar logic to pkgcreatezone for 'entire' incorporation
Dan Price <dp@eng.sun.com>
parents:
954
diff
changeset
|
313 |
get_entire_incorp() { |
fc73bc2d78ce
7490 ipkg brand attach needs similar logic to pkgcreatezone for 'entire' incorporation
Dan Price <dp@eng.sun.com>
parents:
954
diff
changeset
|
314 |
typeset entire_fmri |
fc73bc2d78ce
7490 ipkg brand attach needs similar logic to pkgcreatezone for 'entire' incorporation
Dan Price <dp@eng.sun.com>
parents:
954
diff
changeset
|
315 |
entire_fmri=$($PKG list -Hv entire | nawk '{print $1}') |
fc73bc2d78ce
7490 ipkg brand attach needs similar logic to pkgcreatezone for 'entire' incorporation
Dan Price <dp@eng.sun.com>
parents:
954
diff
changeset
|
316 |
if [[ $? -ne 0 ]]; then |
fc73bc2d78ce
7490 ipkg brand attach needs similar logic to pkgcreatezone for 'entire' incorporation
Dan Price <dp@eng.sun.com>
parents:
954
diff
changeset
|
317 |
return 1 |
fc73bc2d78ce
7490 ipkg brand attach needs similar logic to pkgcreatezone for 'entire' incorporation
Dan Price <dp@eng.sun.com>
parents:
954
diff
changeset
|
318 |
fi |
fc73bc2d78ce
7490 ipkg brand attach needs similar logic to pkgcreatezone for 'entire' incorporation
Dan Price <dp@eng.sun.com>
parents:
954
diff
changeset
|
319 |
entire_fmri=$(echo $entire_fmri | sed 's@^pkg://[^/]*/@@') |
fc73bc2d78ce
7490 ipkg brand attach needs similar logic to pkgcreatezone for 'entire' incorporation
Dan Price <dp@eng.sun.com>
parents:
954
diff
changeset
|
320 |
entire_fmri=$(echo $entire_fmri | sed 's@^pkg:/@@') |
fc73bc2d78ce
7490 ipkg brand attach needs similar logic to pkgcreatezone for 'entire' incorporation
Dan Price <dp@eng.sun.com>
parents:
954
diff
changeset
|
321 |
echo $entire_fmri |
fc73bc2d78ce
7490 ipkg brand attach needs similar logic to pkgcreatezone for 'entire' incorporation
Dan Price <dp@eng.sun.com>
parents:
954
diff
changeset
|
322 |
return 0 |
fc73bc2d78ce
7490 ipkg brand attach needs similar logic to pkgcreatezone for 'entire' incorporation
Dan Price <dp@eng.sun.com>
parents:
954
diff
changeset
|
323 |
} |
fc73bc2d78ce
7490 ipkg brand attach needs similar logic to pkgcreatezone for 'entire' incorporation
Dan Price <dp@eng.sun.com>
parents:
954
diff
changeset
|
324 |
|
fc73bc2d78ce
7490 ipkg brand attach needs similar logic to pkgcreatezone for 'entire' incorporation
Dan Price <dp@eng.sun.com>
parents:
954
diff
changeset
|
325 |
# |
1504
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
326 |
# Emits to stdout the preferred publisher's prefix followed by a '=', and |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
327 |
# then the list of the requested URLs separated by spaces, followed by a |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
328 |
# newline after each unique publisher. It expects two parameters, publisher |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
329 |
# type ("preferred" or "all") and URL type ("mirror" or |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
330 |
# "origin". |
1091
fc73bc2d78ce
7490 ipkg brand attach needs similar logic to pkgcreatezone for 'entire' incorporation
Dan Price <dp@eng.sun.com>
parents:
954
diff
changeset
|
331 |
# |
1504
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
332 |
get_publisher_urls() { |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
333 |
ptype=$1 |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
334 |
utype=$2 |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
335 |
|
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
336 |
pub_opts="-H" |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
337 |
if [ "$ptype" == "preferred" ]; then |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
338 |
pub_opts="${pub_opts}P" |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
339 |
fi |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
340 |
|
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
341 |
__pub_prefix="" |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
342 |
__publisher_urls="" |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
343 |
|
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
344 |
LC_ALL=C $PKG publisher $pub_opts | nawk '$2 == "'"$utype"'" && \ |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
345 |
$3 == "online" {printf "%s %s\n", $1, $4;}' | { |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
346 |
while IFS=" " read __publisher __publisher_url; do |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
347 |
if [[ -n "$__pub_prefix" && \ |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
348 |
"$__pub_prefix" != "$__publisher" ]]; then |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
349 |
# Different publisher so emit accumulation and |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
350 |
# clear existing data. |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
351 |
echo $__pub_prefix=$__publisher_urls |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
352 |
__publisher_urls="" |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
353 |
fi |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
354 |
__pub_prefix=$__publisher |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
355 |
__publisher_urls="$__publisher_urls$__publisher_url " |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
356 |
done |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
357 |
} |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
358 |
|
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
359 |
if [[ -n "$__pub_prefix" && -n "$__publisher_urls" ]]; then |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
360 |
echo $__pub_prefix=$__publisher_urls |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
361 |
fi |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
362 |
|
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
363 |
return 0 |
1091
fc73bc2d78ce
7490 ipkg brand attach needs similar logic to pkgcreatezone for 'entire' incorporation
Dan Price <dp@eng.sun.com>
parents:
954
diff
changeset
|
364 |
} |
1111
26c3e2407c53
8570 zone installer needs support for ssl certs & keys
Dan Price <dp@eng.sun.com>
parents:
1091
diff
changeset
|
365 |
|
26c3e2407c53
8570 zone installer needs support for ssl certs & keys
Dan Price <dp@eng.sun.com>
parents:
1091
diff
changeset
|
366 |
# |
26c3e2407c53
8570 zone installer needs support for ssl certs & keys
Dan Price <dp@eng.sun.com>
parents:
1091
diff
changeset
|
367 |
# Emit to stdout the key and cert associated with the publisher |
26c3e2407c53
8570 zone installer needs support for ssl certs & keys
Dan Price <dp@eng.sun.com>
parents:
1091
diff
changeset
|
368 |
# name provided. Returns 'None' if no information is present. |
1327
6c5e04bdd8b2
10428 pkgcreatezone "Failed to find cert %s" if global zone publisher has mirror
Darren Moffat <Darren.Moffat@Sun.COM>
parents:
1111
diff
changeset
|
369 |
# For now we assume that the mirrors all use the same key and cert |
6c5e04bdd8b2
10428 pkgcreatezone "Failed to find cert %s" if global zone publisher has mirror
Darren Moffat <Darren.Moffat@Sun.COM>
parents:
1111
diff
changeset
|
370 |
# as the main publisher. |
1111
26c3e2407c53
8570 zone installer needs support for ssl certs & keys
Dan Price <dp@eng.sun.com>
parents:
1091
diff
changeset
|
371 |
# |
26c3e2407c53
8570 zone installer needs support for ssl certs & keys
Dan Price <dp@eng.sun.com>
parents:
1091
diff
changeset
|
372 |
get_pub_secinfo() { |
1327
6c5e04bdd8b2
10428 pkgcreatezone "Failed to find cert %s" if global zone publisher has mirror
Darren Moffat <Darren.Moffat@Sun.COM>
parents:
1111
diff
changeset
|
373 |
key=$(LC_ALL=C $PKG publisher $1 | |
6c5e04bdd8b2
10428 pkgcreatezone "Failed to find cert %s" if global zone publisher has mirror
Darren Moffat <Darren.Moffat@Sun.COM>
parents:
1111
diff
changeset
|
374 |
nawk -F': ' '/SSL Key/ {print $2; exit 0}') |
6c5e04bdd8b2
10428 pkgcreatezone "Failed to find cert %s" if global zone publisher has mirror
Darren Moffat <Darren.Moffat@Sun.COM>
parents:
1111
diff
changeset
|
375 |
cert=$(LC_ALL=C $PKG publisher $1 | |
6c5e04bdd8b2
10428 pkgcreatezone "Failed to find cert %s" if global zone publisher has mirror
Darren Moffat <Darren.Moffat@Sun.COM>
parents:
1111
diff
changeset
|
376 |
nawk -F': ' '/SSL Cert/ {print $2; exit 0}') |
1111
26c3e2407c53
8570 zone installer needs support for ssl certs & keys
Dan Price <dp@eng.sun.com>
parents:
1091
diff
changeset
|
377 |
print $key $cert |
26c3e2407c53
8570 zone installer needs support for ssl certs & keys
Dan Price <dp@eng.sun.com>
parents:
1091
diff
changeset
|
378 |
} |
1535 | 379 |
|
380 |
# |
|
381 |
# Handle pkg exit code. Exit 0 means Command succeeded, exit 4 means |
|
382 |
# No changes were made - nothing to do. Any other exit code is an error. |
|
383 |
# |
|
384 |
pkg_err_check() { |
|
385 |
res=$? |
|
386 |
(( $res != 0 && $res != 4 )) && fail_fatal "$1" |
|
387 |
} |