author | Shawn Walker <shawn.walker@oracle.com> |
Wed, 09 Feb 2011 18:43:21 -0800 | |
changeset 2219 | 60ad60f7592c |
parent 2173 | 3f44e4b7f94f |
child 2235 | 1f446820dcb0 |
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 |
# |
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 |
|
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 ***") |
2173
3f44e4b7f94f
16274 nit in error message from common.ksh:fail_zonepath_in_rootds()
Dan Price <daniel.price@oracle.com>
parents:
2163
diff
changeset
|
42 |
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
|
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 |
2163
3b0b0b163508
6978131 zoneadm install does not fail if underlying pkg commands fail
Mike Gerdts <mike.gerdts@oracle.com>
parents:
2027
diff
changeset
|
74 |
exit $ZONE_SUBPROC_NOTCOMPLETE |
547
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() { |
2027
f2e9f684e5be
16805 mount of ipkg zone in alternate root fails
Susan Kamm-Worrell <Susan.Kamm-Worrell@Sun.COM>
parents:
1879
diff
changeset
|
86 |
if [ -z $ALTROOT ]; then |
f2e9f684e5be
16805 mount of ipkg zone in alternate root fails
Susan Kamm-Worrell <Susan.Kamm-Worrell@Sun.COM>
parents:
1879
diff
changeset
|
87 |
AR_OPTIONS="" |
f2e9f684e5be
16805 mount of ipkg zone in alternate root fails
Susan Kamm-Worrell <Susan.Kamm-Worrell@Sun.COM>
parents:
1879
diff
changeset
|
88 |
else |
f2e9f684e5be
16805 mount of ipkg zone in alternate root fails
Susan Kamm-Worrell <Susan.Kamm-Worrell@Sun.COM>
parents:
1879
diff
changeset
|
89 |
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
|
90 |
fi |
f2e9f684e5be
16805 mount of ipkg zone in alternate root fails
Susan Kamm-Worrell <Susan.Kamm-Worrell@Sun.COM>
parents:
1879
diff
changeset
|
91 |
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
|
92 |
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
|
93 |
[[ $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
|
94 |
return 0 |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
95 |
} |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
96 |
|
1879
7dc50f542f19
14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1709
diff
changeset
|
97 |
sanity_check() { |
1483
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
98 |
typeset dir="$1" |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
99 |
shift |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
100 |
res=0 |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
101 |
|
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
102 |
# |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
103 |
# 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
|
104 |
# sparse zone image from SXCE. |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
105 |
# |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
106 |
checks="etc etc/svc var var/svc" |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
107 |
for x in $checks; do |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
108 |
if [[ ! -e $dir/$x ]]; then |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
109 |
log "$f_sanity_detail" "$x" "$dir" |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
110 |
res=1 |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
111 |
fi |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
112 |
done |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
113 |
if (( $res != 0 )); then |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
114 |
log "$f_sanity_sparse" |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
115 |
log "$sanity_fail" |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
116 |
fatal "$install_fail" "$ZONENAME" |
1504
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
117 |
fi |
1483
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
118 |
|
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
119 |
# Check for existence of pkg command. |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
120 |
if [[ ! -x $dir/usr/bin/pkg ]]; then |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
121 |
log "$f_sanity_detail" "usr/bin/pkg" "$dir" |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
122 |
log "$sanity_fail" |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
123 |
fatal "$install_fail" "$ZONENAME" |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
124 |
fi |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
125 |
|
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
126 |
# |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
127 |
# 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
|
128 |
# 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
|
129 |
# 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
|
130 |
# 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
|
131 |
# (i.e. non-OpenSolaris) image. |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
132 |
# |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
133 |
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
|
134 |
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
|
135 |
$dir/var/sadm/system/admin/INST_RELEASE) |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
136 |
vlog "$sanity_fail_vers" "$image_vers" |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
137 |
fatal "$install_fail" "$ZONENAME" |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
138 |
fi |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
139 |
|
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
140 |
vlog "$sanity_ok" |
547
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
141 |
} |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
142 |
|
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
143 |
get_current_gzbe() { |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
144 |
# |
2027
f2e9f684e5be
16805 mount of ipkg zone in alternate root fails
Susan Kamm-Worrell <Susan.Kamm-Worrell@Sun.COM>
parents:
1879
diff
changeset
|
145 |
# 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
|
146 |
# 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
|
147 |
# 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
|
148 |
# 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
|
149 |
# 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
|
150 |
# |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
151 |
if [ -x /usr/sbin/beadm ]; then |
2027
f2e9f684e5be
16805 mount of ipkg zone in alternate root fails
Susan Kamm-Worrell <Susan.Kamm-Worrell@Sun.COM>
parents:
1879
diff
changeset
|
152 |
CURRENT_GZBE=`/usr/sbin/beadm list -H | /usr/bin/nawk \ |
f2e9f684e5be
16805 mount of ipkg zone in alternate root fails
Susan Kamm-Worrell <Susan.Kamm-Worrell@Sun.COM>
parents:
1879
diff
changeset
|
153 |
-v alt=$ALTROOT -F\; '{ |
f2e9f684e5be
16805 mount of ipkg zone in alternate root fails
Susan Kamm-Worrell <Susan.Kamm-Worrell@Sun.COM>
parents:
1879
diff
changeset
|
154 |
if (length(alt) == 0) { |
f2e9f684e5be
16805 mount of ipkg zone in alternate root fails
Susan Kamm-Worrell <Susan.Kamm-Worrell@Sun.COM>
parents:
1879
diff
changeset
|
155 |
# Field 3 is the BE status. 'N' is the active BE. |
f2e9f684e5be
16805 mount of ipkg zone in alternate root fails
Susan Kamm-Worrell <Susan.Kamm-Worrell@Sun.COM>
parents:
1879
diff
changeset
|
156 |
if ($3 !~ "N") |
f2e9f684e5be
16805 mount of ipkg zone in alternate root fails
Susan Kamm-Worrell <Susan.Kamm-Worrell@Sun.COM>
parents:
1879
diff
changeset
|
157 |
next |
f2e9f684e5be
16805 mount of ipkg zone in alternate root fails
Susan Kamm-Worrell <Susan.Kamm-Worrell@Sun.COM>
parents:
1879
diff
changeset
|
158 |
} else { |
f2e9f684e5be
16805 mount of ipkg zone in alternate root fails
Susan Kamm-Worrell <Susan.Kamm-Worrell@Sun.COM>
parents:
1879
diff
changeset
|
159 |
# Field 4 is the BE mountpoint. |
f2e9f684e5be
16805 mount of ipkg zone in alternate root fails
Susan Kamm-Worrell <Susan.Kamm-Worrell@Sun.COM>
parents:
1879
diff
changeset
|
160 |
if ($4 != alt) |
f2e9f684e5be
16805 mount of ipkg zone in alternate root fails
Susan Kamm-Worrell <Susan.Kamm-Worrell@Sun.COM>
parents:
1879
diff
changeset
|
161 |
next |
f2e9f684e5be
16805 mount of ipkg zone in alternate root fails
Susan Kamm-Worrell <Susan.Kamm-Worrell@Sun.COM>
parents:
1879
diff
changeset
|
162 |
} |
f2e9f684e5be
16805 mount of ipkg zone in alternate root fails
Susan Kamm-Worrell <Susan.Kamm-Worrell@Sun.COM>
parents:
1879
diff
changeset
|
163 |
# Field 2 is the BE UUID |
f2e9f684e5be
16805 mount of ipkg zone in alternate root fails
Susan Kamm-Worrell <Susan.Kamm-Worrell@Sun.COM>
parents:
1879
diff
changeset
|
164 |
print $2 |
547
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
165 |
}'` |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
166 |
else |
2027
f2e9f684e5be
16805 mount of ipkg zone in alternate root fails
Susan Kamm-Worrell <Susan.Kamm-Worrell@Sun.COM>
parents:
1879
diff
changeset
|
167 |
# If there is no beadm command then the system doesn't really |
f2e9f684e5be
16805 mount of ipkg zone in alternate root fails
Susan Kamm-Worrell <Susan.Kamm-Worrell@Sun.COM>
parents:
1879
diff
changeset
|
168 |
# support multiple boot environments. We still want zones to |
f2e9f684e5be
16805 mount of ipkg zone in alternate root fails
Susan Kamm-Worrell <Susan.Kamm-Worrell@Sun.COM>
parents:
1879
diff
changeset
|
169 |
# work so simulate the existence of a single boot environment. |
547
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
170 |
CURRENT_GZBE="opensolaris" |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
171 |
fi |
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 |
if [ -z "$CURRENT_GZBE" ]; then |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
174 |
fail_fatal "$f_no_gzbe" |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
175 |
fi |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
176 |
} |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
177 |
|
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
178 |
# 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
|
179 |
# $1 CURRENT_GZBE |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
180 |
# $2 ZONEPATH_DS |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
181 |
get_active_ds() { |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
182 |
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
|
183 |
-o name,$PROP_PARENT,$PROP_ACTIVE $2/ROOT | \ |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
184 |
/usr/bin/nawk -v gzbe=$1 ' { |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
185 |
if ($1 ~ /ROOT\/[^\/]+$/ && $2 == gzbe && $3 == "on") { |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
186 |
print $1 |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
187 |
if (found == 1) |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
188 |
exit 1 |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
189 |
found = 1 |
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 |
|
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
193 |
if [ $? -ne 0 ]; then |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
194 |
fail_fatal "$f_multiple_ds" |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
195 |
fi |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
196 |
|
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
197 |
if [ -z "$ACTIVE_DS" ]; then |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
198 |
fail_fatal "$f_no_active_ds" |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
199 |
fi |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
200 |
} |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
201 |
|
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
202 |
# 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
|
203 |
fail_zonepath_in_rootds() { |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
204 |
case $1 in |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
205 |
rpool/ROOT/*) |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
206 |
fail_fatal "$f_zfs_in_root" |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
207 |
break; |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
208 |
;; |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
209 |
*) |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
210 |
break; |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
211 |
;; |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
212 |
esac |
9a267e76a197
3454 initial ipkg brand enhancements for SNAP support
<gerald.jelinek@sun.com>
parents:
diff
changeset
|
213 |
} |
1091
fc73bc2d78ce
7490 ipkg brand attach needs similar logic to pkgcreatezone for 'entire' incorporation
Dan Price <dp@eng.sun.com>
parents:
954
diff
changeset
|
214 |
|
fc73bc2d78ce
7490 ipkg brand attach needs similar logic to pkgcreatezone for 'entire' incorporation
Dan Price <dp@eng.sun.com>
parents:
954
diff
changeset
|
215 |
# |
1493
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
216 |
# 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
|
217 |
# cases to consider: |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
218 |
# 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
|
219 |
# 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
|
220 |
# 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
|
221 |
# |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
222 |
mount_active_ds() { |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
223 |
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
|
224 |
if (( $? == 0 )); then |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
225 |
# 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
|
226 |
umount $ZONEPATH/root |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
227 |
if (( $? != 0 )); then |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
228 |
# 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
|
229 |
# 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
|
230 |
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
|
231 |
return |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
232 |
fi |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
233 |
fi |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
234 |
|
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
235 |
# 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
|
236 |
get_current_gzbe |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
237 |
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
|
238 |
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
|
239 |
|
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
240 |
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
|
241 |
} |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
242 |
|
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
243 |
# |
1483
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
244 |
# 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
|
245 |
# |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
246 |
create_active_ds() { |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
247 |
get_current_gzbe |
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 |
# 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
|
251 |
# zoneadm. |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
252 |
# |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
253 |
get_zonepath_ds $zonepath |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
254 |
|
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
255 |
# 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
|
256 |
fail_zonepath_in_rootds $ZONEPATH_DS |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
257 |
|
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 |
# 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
|
260 |
# |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
261 |
int_code=$ZONE_SUBPROC_FATAL |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
262 |
|
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
263 |
# |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
264 |
# 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
|
265 |
# 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
|
266 |
# |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
267 |
|
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
268 |
/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
|
269 |
if (( $? != 0 )); then |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
270 |
/usr/sbin/zfs create -o mountpoint=legacy \ |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
271 |
-o zoned=on $ZONEPATH_DS/ROOT |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
272 |
if (( $? != 0 )); then |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
273 |
fail_fatal "$f_zfs_create" |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
274 |
fi |
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 |
BENAME=zbe |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
278 |
BENUM=0 |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
279 |
# Try 100 different names before giving up. |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
280 |
while [ $BENUM -lt 100 ]; do |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
281 |
/usr/sbin/zfs create -o $PROP_ACTIVE=on \ |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
282 |
-o $PROP_PARENT=$CURRENT_GZBE \ |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
283 |
-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
|
284 |
if (( $? == 0 )); then |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
285 |
break |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
286 |
fi |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
287 |
BENUM=`expr $BENUM + 1` |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
288 |
BENAME="zbe-$BENUM" |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
289 |
done |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
290 |
|
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
291 |
if [ $BENUM -ge 100 ]; then |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
292 |
fail_fatal "$f_zfs_create" |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
293 |
fi |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
294 |
|
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
295 |
if [ ! -d $ZONEROOT ]; then |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
296 |
/usr/bin/mkdir $ZONEROOT |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
297 |
fi |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
298 |
|
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
299 |
/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
|
300 |
fail_incomplete "$f_zfs_mount" |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
301 |
} |
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
302 |
|
2276b6786711
6793 p2v support for ipkg-branded zones
<gerald.jelinek@sun.com>
parents:
1327
diff
changeset
|
303 |
# |
1493
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
304 |
# 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
|
305 |
# |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
306 |
unconfigure_zone() { |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
307 |
vlog "$v_unconfig" |
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 |
vlog "$v_mounting" |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
310 |
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
|
311 |
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
|
312 |
|
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
313 |
zlogin -S $ZONENAME /usr/sbin/sys-unconfig -R /a \ |
1879
7dc50f542f19
14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1709
diff
changeset
|
314 |
</dev/null >/dev/null 2>&1 |
7dc50f542f19
14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1709
diff
changeset
|
315 |
if (( $? != 0 )); then |
7dc50f542f19
14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1709
diff
changeset
|
316 |
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
|
317 |
failed=1 |
1879
7dc50f542f19
14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1709
diff
changeset
|
318 |
fi |
1493
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
319 |
|
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
320 |
vlog "$v_unmount" |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
321 |
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
|
322 |
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
|
323 |
|
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
324 |
[[ -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
|
325 |
} |
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
326 |
|
625950c12e71
3979 zone fs only available from Global zone, when zone is booted
<gerald.jelinek@sun.com>
parents:
1483
diff
changeset
|
327 |
# |
1879
7dc50f542f19
14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1709
diff
changeset
|
328 |
# 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
|
329 |
# 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
|
330 |
# |
7dc50f542f19
14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1709
diff
changeset
|
331 |
get_pkg_fmri() { |
7dc50f542f19
14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1709
diff
changeset
|
332 |
typeset pname=$1 |
7dc50f542f19
14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1709
diff
changeset
|
333 |
typeset pkg_fmri= |
7dc50f542f19
14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1709
diff
changeset
|
334 |
typeset info_out= |
7dc50f542f19
14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1709
diff
changeset
|
335 |
|
7dc50f542f19
14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1709
diff
changeset
|
336 |
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
|
337 |
if [[ $? -ne 0 ]]; then |
7dc50f542f19
14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1709
diff
changeset
|
338 |
return 1 |
7dc50f542f19
14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1709
diff
changeset
|
339 |
fi |
7dc50f542f19
14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1709
diff
changeset
|
340 |
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
|
341 |
echo "$pname@$pkg_fmri" |
7dc50f542f19
14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1709
diff
changeset
|
342 |
return 0 |
7dc50f542f19
14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1709
diff
changeset
|
343 |
} |
7dc50f542f19
14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1709
diff
changeset
|
344 |
|
7dc50f542f19
14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1709
diff
changeset
|
345 |
# |
1091
fc73bc2d78ce
7490 ipkg brand attach needs similar logic to pkgcreatezone for 'entire' incorporation
Dan Price <dp@eng.sun.com>
parents:
954
diff
changeset
|
346 |
# 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
|
347 |
# 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
|
348 |
# |
fc73bc2d78ce
7490 ipkg brand attach needs similar logic to pkgcreatezone for 'entire' incorporation
Dan Price <dp@eng.sun.com>
parents:
954
diff
changeset
|
349 |
get_entire_incorp() { |
1879
7dc50f542f19
14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1709
diff
changeset
|
350 |
get_pkg_fmri entire |
7dc50f542f19
14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1709
diff
changeset
|
351 |
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
|
352 |
} |
fc73bc2d78ce
7490 ipkg brand attach needs similar logic to pkgcreatezone for 'entire' incorporation
Dan Price <dp@eng.sun.com>
parents:
954
diff
changeset
|
353 |
|
fc73bc2d78ce
7490 ipkg brand attach needs similar logic to pkgcreatezone for 'entire' incorporation
Dan Price <dp@eng.sun.com>
parents:
954
diff
changeset
|
354 |
# |
1709
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
355 |
# Emits to stdout the extended attributes for a publisher. The |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
356 |
# attributes are emitted in the order "sticky preferred enabled". It |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
357 |
# expects two parameters: publisher name and URL type which can be |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
358 |
# ("mirror" or "origin"). |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
359 |
# |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
360 |
get_publisher_attrs() { |
1879
7dc50f542f19
14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1709
diff
changeset
|
361 |
typeset pname=$1 |
7dc50f542f19
14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1709
diff
changeset
|
362 |
typeset utype=$2 |
1709
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
363 |
|
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
364 |
LC_ALL=C $PKG publisher -HF tsv| \ |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2173
diff
changeset
|
365 |
nawk '($5 == "'"$utype"'" || \ |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2173
diff
changeset
|
366 |
("'"$utype"'" == "origin" && $5 == "")) \ |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2173
diff
changeset
|
367 |
&& $1 == "'"$pname"'" \ |
1709
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
368 |
{printf "%s %s %s\n", $2, $3, $4;}' |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
369 |
return 0 |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
370 |
} |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
371 |
|
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
372 |
# |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
373 |
# Emits to stdout the extended attribute arguments for a publisher. It |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
374 |
# expects two parameters: publisher name and URL type which can be |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
375 |
# ("mirror" or "origin"). |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
376 |
# |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
377 |
get_publisher_attr_args() { |
1879
7dc50f542f19
14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1709
diff
changeset
|
378 |
typeset args= |
7dc50f542f19
14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1709
diff
changeset
|
379 |
typeset sticky= |
7dc50f542f19
14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1709
diff
changeset
|
380 |
typeset preferred= |
7dc50f542f19
14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1709
diff
changeset
|
381 |
typeset enabled= |
1709
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
382 |
|
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
383 |
get_publisher_attrs $1 $2 | |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
384 |
while IFS=" " read sticky preferred enabled; do |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
385 |
if [ $sticky == "true" ]; then |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
386 |
args="--sticky" |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
387 |
else |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
388 |
args="--non-sticky" |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
389 |
fi |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
390 |
|
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
391 |
if [ $preferred == "true" ]; then |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
392 |
args="$args -P" |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
393 |
fi |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
394 |
|
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
395 |
if [ $enabled == "true" ]; then |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
396 |
args="$args --enable" |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
397 |
else |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
398 |
args="$args --disable" |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
399 |
fi |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
400 |
done |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
401 |
echo $args |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
402 |
|
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
403 |
return 0 |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
404 |
} |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
405 |
|
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
406 |
# |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
407 |
# Emits to stdout the publisher's prefix followed by a '=', and then |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
408 |
# the list of the requested URLs separated by spaces, followed by a |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
409 |
# newline after each unique publisher. It expects two parameters, |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
410 |
# publisher type ("all", "preferred", "non-preferred") and URL type |
1879
7dc50f542f19
14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1709
diff
changeset
|
411 |
# ("mirror" or "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
|
412 |
# |
1504
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
413 |
get_publisher_urls() { |
1879
7dc50f542f19
14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1709
diff
changeset
|
414 |
typeset ptype=$1 |
7dc50f542f19
14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1709
diff
changeset
|
415 |
typeset utype=$2 |
7dc50f542f19
14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1709
diff
changeset
|
416 |
typeset __pub_prefix= |
7dc50f542f19
14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1709
diff
changeset
|
417 |
typeset __publisher_urls= |
7dc50f542f19
14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1709
diff
changeset
|
418 |
typeset ptype_filter= |
1504
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
419 |
|
1709
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
420 |
if [ "$ptype" == "all" ] |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
421 |
then |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
422 |
ptype_filter="" |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
423 |
elif [ "$ptype" == "preferred" ] |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
424 |
then |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
425 |
ptype_filter="true" |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
426 |
elif [ "$ptype" == "non-preferred" ] |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
427 |
then |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
428 |
ptype_filter="false" |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
429 |
fi |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
430 |
|
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
431 |
LC_ALL=C $PKG publisher -HF tsv | \ |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2173
diff
changeset
|
432 |
nawk '($5 == "'"$utype"'" || \ |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2173
diff
changeset
|
433 |
("'"$utype"'" == "origin" && $5 == "")) && \ |
1709
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
434 |
( "'"$ptype_filter"'" == "" || $3 == "'"$ptype_filter"'" ) \ |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
435 |
{printf "%s %s\n", $1, $7;}' | |
1504
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
436 |
while IFS=" " read __publisher __publisher_url; do |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2173
diff
changeset
|
437 |
if [[ "$utype" == "origin" && \ |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2173
diff
changeset
|
438 |
-z "$__publisher_url" ]]; then |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2173
diff
changeset
|
439 |
# Publisher without origins. |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2173
diff
changeset
|
440 |
__publisher_url="None" |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2173
diff
changeset
|
441 |
fi |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2173
diff
changeset
|
442 |
|
1504
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
443 |
if [[ -n "$__pub_prefix" && \ |
1709
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1535
diff
changeset
|
444 |
"$__pub_prefix" != "$__publisher" ]]; then |
1504
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
445 |
# Different publisher so emit accumulation and |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
446 |
# clear existing data. |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
447 |
echo $__pub_prefix=$__publisher_urls |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
448 |
__publisher_urls="" |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
449 |
fi |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
450 |
__pub_prefix=$__publisher |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
451 |
__publisher_urls="$__publisher_urls$__publisher_url " |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
452 |
done |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
453 |
|
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
454 |
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
|
455 |
echo $__pub_prefix=$__publisher_urls |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
456 |
fi |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
457 |
|
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1493
diff
changeset
|
458 |
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
|
459 |
} |
1111
26c3e2407c53
8570 zone installer needs support for ssl certs & keys
Dan Price <dp@eng.sun.com>
parents:
1091
diff
changeset
|
460 |
|
26c3e2407c53
8570 zone installer needs support for ssl certs & keys
Dan Price <dp@eng.sun.com>
parents:
1091
diff
changeset
|
461 |
# |
26c3e2407c53
8570 zone installer needs support for ssl certs & keys
Dan Price <dp@eng.sun.com>
parents:
1091
diff
changeset
|
462 |
# 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
|
463 |
# 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
|
464 |
# 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
|
465 |
# 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
|
466 |
# |
26c3e2407c53
8570 zone installer needs support for ssl certs & keys
Dan Price <dp@eng.sun.com>
parents:
1091
diff
changeset
|
467 |
get_pub_secinfo() { |
1879
7dc50f542f19
14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1709
diff
changeset
|
468 |
typeset key= |
7dc50f542f19
14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1709
diff
changeset
|
469 |
typeset cert= |
7dc50f542f19
14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1709
diff
changeset
|
470 |
|
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
|
471 |
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
|
472 |
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
|
473 |
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
|
474 |
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
|
475 |
print $key $cert |
26c3e2407c53
8570 zone installer needs support for ssl certs & keys
Dan Price <dp@eng.sun.com>
parents:
1091
diff
changeset
|
476 |
} |
1535 | 477 |
|
478 |
# |
|
479 |
# Handle pkg exit code. Exit 0 means Command succeeded, exit 4 means |
|
480 |
# No changes were made - nothing to do. Any other exit code is an error. |
|
481 |
# |
|
482 |
pkg_err_check() { |
|
1879
7dc50f542f19
14684 zone attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1709
diff
changeset
|
483 |
typeset res=$? |
1535 | 484 |
(( $res != 0 && $res != 4 )) && fail_fatal "$1" |
485 |
} |