author | jv227347 <Jordan.Vaughan@Sun.com> |
Tue, 18 May 2010 12:28:09 -0700 | |
changeset 12433 | a15cace5f27d |
parent 10840 | 7df556caf412 |
child 12773 | f0d486d64936 |
permissions | -rw-r--r-- |
8759 | 1 |
#!/bin/ksh -p |
2 |
# |
|
3 |
# CDDL HEADER START |
|
4 |
# |
|
5 |
# The contents of this file are subject to the terms of the |
|
6 |
# Common Development and Distribution License (the "License"). |
|
7 |
# You may not use this file except in compliance with the License. |
|
8 |
# |
|
9 |
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
|
10 |
# or http://www.opensolaris.org/os/licensing. |
|
11 |
# See the License for the specific language governing permissions |
|
12 |
# and limitations under the License. |
|
13 |
# |
|
14 |
# When distributing Covered Code, include this CDDL HEADER in each |
|
15 |
# file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
|
16 |
# If applicable, add the following below this CDDL HEADER, with the |
|
17 |
# fields enclosed by brackets "[]" replaced with your own identifying |
|
18 |
# information: Portions Copyright [yyyy] [name of copyright owner] |
|
19 |
# |
|
20 |
# CDDL HEADER END |
|
21 |
# |
|
12433
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
22 |
# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. |
8759 | 23 |
# |
24 |
||
25 |
# NOTE: this script runs in the global zone and touches the non-global |
|
26 |
# zone, so care should be taken to validate any modifications so that they |
|
27 |
# are safe. |
|
28 |
||
10840
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
29 |
. /usr/lib/brand/solaris10/common.ksh |
8759 | 30 |
|
31 |
LOGFILE= |
|
32 |
MSG_PREFIX="p2v: " |
|
33 |
EXIT_CODE=1 |
|
34 |
||
35 |
usage() |
|
36 |
{ |
|
37 |
echo "$0 [-s] [-m msgprefix] [-u] [-v] [-b patchid]* zonename" >&2 |
|
38 |
exit $EXIT_CODE |
|
39 |
} |
|
40 |
||
41 |
# Clean up on interrupt |
|
42 |
trap_cleanup() |
|
43 |
{ |
|
44 |
msg=$(gettext "Postprocessing cancelled due to interrupt.") |
|
45 |
error "$msg" |
|
46 |
||
47 |
if (( $zone_is_running != 0 )); then |
|
48 |
error "$e_shutdown" "$ZONENAME" |
|
49 |
/usr/sbin/zoneadm -z $ZONENAME halt |
|
50 |
fi |
|
51 |
||
12433
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
52 |
# |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
53 |
# Delete temporary files created during the hollow package removal |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
54 |
# process. |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
55 |
# |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
56 |
rm -f $hollow_pkgs $hollow_file_list $hollow_dir_list |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
57 |
|
8759 | 58 |
exit $EXIT_CODE |
59 |
} |
|
60 |
||
61 |
# |
|
10840
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
62 |
# Disable any existing live-upgrade configuration. |
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
63 |
# We have already called safe_dir to validate the etc/lu directory. |
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
64 |
# |
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
65 |
fix_lu() |
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
66 |
{ |
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
67 |
ludir=$ZONEROOT/etc/lu |
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
68 |
|
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
69 |
[[ ! -d $ludir ]] && return |
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
70 |
|
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
71 |
safe_rm etc/lutab |
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
72 |
safe_rm etc/lu/.BE_CONFIG |
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
73 |
safe_rm etc/lu/.CURR_VARS |
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
74 |
safe_rm etc/lu/ludb.local.xml |
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
75 |
for i in $ludir/ICF* $ludir/vtoc* $ludir/GRUB* |
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
76 |
do |
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
77 |
nm=`basename $i` |
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
78 |
safe_rm etc/lu/$nm |
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
79 |
done |
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
80 |
} |
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
81 |
|
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
82 |
# |
8759 | 83 |
# For an exclusive stack zone, fix up the network configuration files. |
84 |
# We need to do this even if unconfiguring the zone so sys-unconfig works |
|
85 |
# correctly. |
|
86 |
# |
|
87 |
fix_net() |
|
88 |
{ |
|
89 |
[[ "$STACK_TYPE" == "shared" ]] && return |
|
90 |
||
91 |
NETIF_CNT=$(/usr/bin/ls $ZONEROOT/etc/hostname.* 2>/dev/null | \ |
|
92 |
/usr/bin/wc -l) |
|
93 |
if (( $NETIF_CNT != 1 )); then |
|
94 |
vlog "$v_nonetfix" |
|
95 |
return |
|
96 |
fi |
|
97 |
||
98 |
NET=$(LC_ALL=C /usr/sbin/zonecfg -z $ZONENAME info net) |
|
99 |
if (( $? != 0 )); then |
|
100 |
error "$e_badinfo" "net" |
|
101 |
return |
|
102 |
fi |
|
103 |
||
104 |
NETIF=$(echo $NET | /usr/bin/nawk '{ |
|
105 |
for (i = 1; i < NF; i++) { |
|
106 |
if ($i == "physical:") { |
|
107 |
if (length(net) == 0) { |
|
108 |
i++ |
|
109 |
net = $i |
|
110 |
} else { |
|
111 |
multiple=1 |
|
112 |
} |
|
113 |
} |
|
114 |
} |
|
115 |
} |
|
116 |
END { if (!multiple) |
|
117 |
print net |
|
118 |
}') |
|
119 |
||
120 |
if [[ -z "$NETIF" ]]; then |
|
121 |
vlog "$v_nonetfix" |
|
122 |
return |
|
123 |
fi |
|
124 |
||
125 |
OLD_HOSTNET=$(/usr/bin/ls $ZONEROOT/etc/hostname.*) |
|
126 |
if [[ "$OLD_HOSTNET" != "$ZONEROOT/etc/hostname.$NETIF" ]]; then |
|
127 |
safe_move $OLD_HOSTNET $ZONEROOT/etc/hostname.$NETIF |
|
128 |
fi |
|
129 |
} |
|
130 |
||
131 |
# |
|
132 |
# Disable all of the shares since the zone cannot be an NFS server. |
|
133 |
# Note that we disable the various instances of the svc:/network/shares/group |
|
134 |
# SMF service in the fix_smf function. |
|
135 |
# |
|
136 |
fix_nfs() |
|
137 |
{ |
|
138 |
zonedfs=$ZONEROOT/etc/dfs |
|
139 |
||
10840
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
140 |
[[ ! -d $zonedfs ]] && return |
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
141 |
|
8759 | 142 |
if [[ -h $zonedfs/dfstab || ! -f $zonedfs/dfstab ]]; then |
143 |
error "$e_badfile" "/etc/dfs/dfstab" |
|
144 |
return |
|
145 |
fi |
|
146 |
||
10840
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
147 |
tmpfile=$(mktemp -t) |
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
148 |
if [[ $? == 1 || -z "$tmpfile" ]]; then |
8759 | 149 |
error "$e_tmpfile" |
150 |
return |
|
151 |
fi |
|
152 |
||
153 |
/usr/bin/nawk '{ |
|
154 |
if (substr($1, 0, 1) == "#") { |
|
155 |
print $0 |
|
156 |
} else { |
|
157 |
print "#", $0 |
|
158 |
modified=1 |
|
159 |
} |
|
160 |
} |
|
161 |
END { |
|
162 |
if (modified == 1) { |
|
163 |
printf("# Modified by p2v ") |
|
164 |
system("/usr/bin/date") |
|
165 |
exit 0 |
|
166 |
} |
|
167 |
exit 1 |
|
168 |
}' $zonedfs/dfstab >>$tmpfile |
|
169 |
||
170 |
if (( $? == 0 )); then |
|
171 |
if [[ ! -f $zonedfs/dfstab.pre_p2v ]]; then |
|
172 |
safe_copy $zonedfs/dfstab $zonedfs/dfstab.pre_p2v |
|
173 |
fi |
|
174 |
safe_copy $tmpfile $zonedfs/dfstab |
|
10840
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
175 |
chown root:sys $zonedfs/dfstab || \ |
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
176 |
fail_fatal "$f_chown" "$zonedfs/dfstab" |
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
177 |
chmod 644 $zonedfs/dfstab || \ |
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
178 |
fail_fatal "$f_chmod" "$zonedfs/dfstab" |
8759 | 179 |
fi |
180 |
/usr/bin/rm -f $tmpfile |
|
181 |
} |
|
182 |
||
183 |
# |
|
184 |
# Comment out most of the old mounts since they are either unneeded or |
|
185 |
# likely incorrect within a zone. Specific mounts can be manually |
|
186 |
# reenabled if the corresponding device is added to the zone. |
|
187 |
# |
|
188 |
fix_vfstab() |
|
189 |
{ |
|
190 |
if [[ -h $ZONEROOT/etc/vfstab || ! -f $ZONEROOT/etc/vfstab ]]; then |
|
191 |
error "$e_badfile" "/etc/vfstab" |
|
192 |
return |
|
193 |
fi |
|
194 |
||
10840
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
195 |
tmpfile=$(mktemp -t) |
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
196 |
if [[ $? == 1 || -z "$tmpfile" ]]; then |
8759 | 197 |
error "$e_tmpfile" |
198 |
return |
|
199 |
fi |
|
200 |
||
201 |
/usr/bin/nawk '{ |
|
202 |
if (substr($1, 0, 1) == "#") { |
|
203 |
print $0 |
|
204 |
} else if ($1 == "fd" || $1 == "/proc" || $1 == "swap" || |
|
205 |
$1 == "ctfs" || $1 == "objfs" || $1 == "sharefs" || |
|
206 |
$4 == "nfs" || $4 == "lofs") { |
|
207 |
print $0 |
|
208 |
} else { |
|
209 |
print "#", $0 |
|
210 |
modified=1 |
|
211 |
} |
|
212 |
} |
|
213 |
END { |
|
214 |
if (modified == 1) { |
|
215 |
printf("# Modified by p2v ") |
|
216 |
system("/usr/bin/date") |
|
217 |
exit 0 |
|
218 |
} |
|
219 |
exit 1 |
|
220 |
}' $ZONEROOT/etc/vfstab >>$tmpfile |
|
221 |
||
222 |
if (( $? == 0 )); then |
|
223 |
if [[ ! -f $ZONEROOT/etc/vfstab.pre_p2v ]]; then |
|
224 |
safe_copy $ZONEROOT/etc/vfstab \ |
|
225 |
$ZONEROOT/etc/vfstab.pre_p2v |
|
226 |
fi |
|
227 |
safe_copy $tmpfile $ZONEROOT/etc/vfstab |
|
10840
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
228 |
chown root:sys $ZONEROOT/etc/vfstab || \ |
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
229 |
fail_fatal "$f_chown" "$ZONEROOT/etc/vfstab" |
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
230 |
chmod 644 $ZONEROOT/etc/vfstab || \ |
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
231 |
fail_fatal "$f_chmod" "$ZONEROOT/etc/vfstab" |
8759 | 232 |
fi |
233 |
/usr/bin/rm -f $tmpfile |
|
234 |
} |
|
235 |
||
236 |
# |
|
10840
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
237 |
# Collect the data needed to delete SMF services. Since we're p2v-ing a |
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
238 |
# physical image there are SMF services which must be deleted. |
8759 | 239 |
# |
8994
3f12cbbe75b6
6810950 p2v needs to handle cross-arch svc cleanup
<gerald.jelinek@sun.com>
parents:
8759
diff
changeset
|
240 |
fix_smf_pre_uoa() |
8759 | 241 |
{ |
242 |
# |
|
243 |
# Start by getting the svc manifests that are delivered by hollow |
|
244 |
# pkgs then use 'svccfg inventory' to get the names of the svcs |
|
245 |
# delivered by those manifests. The svc names are saved into a |
|
8994
3f12cbbe75b6
6810950 p2v needs to handle cross-arch svc cleanup
<gerald.jelinek@sun.com>
parents:
8759
diff
changeset
|
246 |
# temporary file. |
8759 | 247 |
# |
248 |
||
10840
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
249 |
SMFTMPFILE=$(mktemp -t smf.XXXXXX) |
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
250 |
if [[ $? == 1 || -z "$SMFTMPFILE" ]]; then |
8759 | 251 |
error "$e_tmpfile" |
252 |
return |
|
253 |
fi |
|
254 |
||
8994
3f12cbbe75b6
6810950 p2v needs to handle cross-arch svc cleanup
<gerald.jelinek@sun.com>
parents:
8759
diff
changeset
|
255 |
for i in $ZONEROOT/var/sadm/pkg/* |
8759 | 256 |
do |
257 |
pkg=$(/usr/bin/basename $i) |
|
8994
3f12cbbe75b6
6810950 p2v needs to handle cross-arch svc cleanup
<gerald.jelinek@sun.com>
parents:
8759
diff
changeset
|
258 |
[[ ! -f $ZONEROOT/var/sadm/pkg/$pkg/save/pspool/$pkg/pkgmap ]] \ |
3f12cbbe75b6
6810950 p2v needs to handle cross-arch svc cleanup
<gerald.jelinek@sun.com>
parents:
8759
diff
changeset
|
259 |
&& continue |
8759 | 260 |
|
8994
3f12cbbe75b6
6810950 p2v needs to handle cross-arch svc cleanup
<gerald.jelinek@sun.com>
parents:
8759
diff
changeset
|
261 |
/usr/bin/egrep -s "SUNW_PKG_HOLLOW=true" \ |
3f12cbbe75b6
6810950 p2v needs to handle cross-arch svc cleanup
<gerald.jelinek@sun.com>
parents:
8759
diff
changeset
|
262 |
$ZONEROOT/var/sadm/pkg/$pkg/pkginfo || continue |
3f12cbbe75b6
6810950 p2v needs to handle cross-arch svc cleanup
<gerald.jelinek@sun.com>
parents:
8759
diff
changeset
|
263 |
|
3f12cbbe75b6
6810950 p2v needs to handle cross-arch svc cleanup
<gerald.jelinek@sun.com>
parents:
8759
diff
changeset
|
264 |
for j in $(/usr/bin/nawk '{if ($2 == "f" && |
8759 | 265 |
substr($4, 1, 17) == "var/svc/manifest/") print $4}' \ |
8994
3f12cbbe75b6
6810950 p2v needs to handle cross-arch svc cleanup
<gerald.jelinek@sun.com>
parents:
8759
diff
changeset
|
266 |
$ZONEROOT/var/sadm/pkg/$pkg/save/pspool/$pkg/pkgmap) |
3f12cbbe75b6
6810950 p2v needs to handle cross-arch svc cleanup
<gerald.jelinek@sun.com>
parents:
8759
diff
changeset
|
267 |
do |
3f12cbbe75b6
6810950 p2v needs to handle cross-arch svc cleanup
<gerald.jelinek@sun.com>
parents:
8759
diff
changeset
|
268 |
svcs=$(SVCCFG_NOVALIDATE=1 \ |
3f12cbbe75b6
6810950 p2v needs to handle cross-arch svc cleanup
<gerald.jelinek@sun.com>
parents:
8759
diff
changeset
|
269 |
SVCCFG_REPOSITORY=$ZONEROOT/etc/svc/repository.db \ |
3f12cbbe75b6
6810950 p2v needs to handle cross-arch svc cleanup
<gerald.jelinek@sun.com>
parents:
8759
diff
changeset
|
270 |
/usr/sbin/svccfg inventory $ZONEROOT/$j) |
3f12cbbe75b6
6810950 p2v needs to handle cross-arch svc cleanup
<gerald.jelinek@sun.com>
parents:
8759
diff
changeset
|
271 |
for k in $svcs |
8759 | 272 |
do |
8994
3f12cbbe75b6
6810950 p2v needs to handle cross-arch svc cleanup
<gerald.jelinek@sun.com>
parents:
8759
diff
changeset
|
273 |
echo $k /$j >> $SMFTMPFILE |
8759 | 274 |
done |
8994
3f12cbbe75b6
6810950 p2v needs to handle cross-arch svc cleanup
<gerald.jelinek@sun.com>
parents:
8759
diff
changeset
|
275 |
done |
8759 | 276 |
done |
8994
3f12cbbe75b6
6810950 p2v needs to handle cross-arch svc cleanup
<gerald.jelinek@sun.com>
parents:
8759
diff
changeset
|
277 |
} |
8759 | 278 |
|
8994
3f12cbbe75b6
6810950 p2v needs to handle cross-arch svc cleanup
<gerald.jelinek@sun.com>
parents:
8759
diff
changeset
|
279 |
# |
3f12cbbe75b6
6810950 p2v needs to handle cross-arch svc cleanup
<gerald.jelinek@sun.com>
parents:
8759
diff
changeset
|
280 |
# Delete or disable SMF services. |
3f12cbbe75b6
6810950 p2v needs to handle cross-arch svc cleanup
<gerald.jelinek@sun.com>
parents:
8759
diff
changeset
|
281 |
# Zone is booted to milestone=none when this function is called. |
3f12cbbe75b6
6810950 p2v needs to handle cross-arch svc cleanup
<gerald.jelinek@sun.com>
parents:
8759
diff
changeset
|
282 |
# Use the SMF data collected by fix_smf_pre_uoa() to delete the services. |
3f12cbbe75b6
6810950 p2v needs to handle cross-arch svc cleanup
<gerald.jelinek@sun.com>
parents:
8759
diff
changeset
|
283 |
# |
3f12cbbe75b6
6810950 p2v needs to handle cross-arch svc cleanup
<gerald.jelinek@sun.com>
parents:
8759
diff
changeset
|
284 |
fix_smf() |
3f12cbbe75b6
6810950 p2v needs to handle cross-arch svc cleanup
<gerald.jelinek@sun.com>
parents:
8759
diff
changeset
|
285 |
{ |
8759 | 286 |
# |
287 |
# Zone was already booted to milestone=none, wait until SMF door exists. |
|
288 |
# |
|
289 |
for i in 0 1 2 3 4 5 6 7 8 9 |
|
290 |
do |
|
291 |
[[ -r $ZONEROOT/etc/svc/volatile/repository_door ]] && break |
|
292 |
sleep 5 |
|
293 |
done |
|
294 |
||
295 |
if [[ $i -eq 9 && ! -r $ZONEROOT/etc/svc/volatile/repository_door ]]; |
|
296 |
then |
|
297 |
error "$e_nosmf" |
|
8994
3f12cbbe75b6
6810950 p2v needs to handle cross-arch svc cleanup
<gerald.jelinek@sun.com>
parents:
8759
diff
changeset
|
298 |
/usr/bin/rm -f $SMFTMPFILE |
8759 | 299 |
return |
300 |
fi |
|
301 |
||
10840
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
302 |
insttmpfile=$(mktemp -t instsmf.XXXXXX) |
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
303 |
if [[ $? == 1 || -z "$insttmpfile" ]]; then |
8759 | 304 |
error "$e_tmpfile" |
8994
3f12cbbe75b6
6810950 p2v needs to handle cross-arch svc cleanup
<gerald.jelinek@sun.com>
parents:
8759
diff
changeset
|
305 |
/usr/bin/rm -f $SMFTMPFILE |
8759 | 306 |
return |
307 |
fi |
|
308 |
||
8994
3f12cbbe75b6
6810950 p2v needs to handle cross-arch svc cleanup
<gerald.jelinek@sun.com>
parents:
8759
diff
changeset
|
309 |
vlog "$v_rmhollowsvcs" |
3f12cbbe75b6
6810950 p2v needs to handle cross-arch svc cleanup
<gerald.jelinek@sun.com>
parents:
8759
diff
changeset
|
310 |
while read fmri mfst |
3f12cbbe75b6
6810950 p2v needs to handle cross-arch svc cleanup
<gerald.jelinek@sun.com>
parents:
8759
diff
changeset
|
311 |
do |
3f12cbbe75b6
6810950 p2v needs to handle cross-arch svc cleanup
<gerald.jelinek@sun.com>
parents:
8759
diff
changeset
|
312 |
# Delete the svc. |
3f12cbbe75b6
6810950 p2v needs to handle cross-arch svc cleanup
<gerald.jelinek@sun.com>
parents:
8759
diff
changeset
|
313 |
vlog "$v_delsvc" "$fmri" |
3f12cbbe75b6
6810950 p2v needs to handle cross-arch svc cleanup
<gerald.jelinek@sun.com>
parents:
8759
diff
changeset
|
314 |
echo "/usr/sbin/svccfg delete -f $fmri" |
3f12cbbe75b6
6810950 p2v needs to handle cross-arch svc cleanup
<gerald.jelinek@sun.com>
parents:
8759
diff
changeset
|
315 |
echo "/usr/sbin/svccfg delhash -d $mfst" |
3f12cbbe75b6
6810950 p2v needs to handle cross-arch svc cleanup
<gerald.jelinek@sun.com>
parents:
8759
diff
changeset
|
316 |
echo "rm -f $mfst" |
3f12cbbe75b6
6810950 p2v needs to handle cross-arch svc cleanup
<gerald.jelinek@sun.com>
parents:
8759
diff
changeset
|
317 |
done < $SMFTMPFILE > $ZONEROOT/tmp/smf_rm |
3f12cbbe75b6
6810950 p2v needs to handle cross-arch svc cleanup
<gerald.jelinek@sun.com>
parents:
8759
diff
changeset
|
318 |
|
3f12cbbe75b6
6810950 p2v needs to handle cross-arch svc cleanup
<gerald.jelinek@sun.com>
parents:
8759
diff
changeset
|
319 |
/usr/sbin/zlogin -S $ZONENAME /bin/sh /tmp/smf_rm >/dev/null 2>&1 |
3f12cbbe75b6
6810950 p2v needs to handle cross-arch svc cleanup
<gerald.jelinek@sun.com>
parents:
8759
diff
changeset
|
320 |
|
3f12cbbe75b6
6810950 p2v needs to handle cross-arch svc cleanup
<gerald.jelinek@sun.com>
parents:
8759
diff
changeset
|
321 |
/usr/bin/rm -f $SMFTMPFILE |
3f12cbbe75b6
6810950 p2v needs to handle cross-arch svc cleanup
<gerald.jelinek@sun.com>
parents:
8759
diff
changeset
|
322 |
|
3f12cbbe75b6
6810950 p2v needs to handle cross-arch svc cleanup
<gerald.jelinek@sun.com>
parents:
8759
diff
changeset
|
323 |
# Get a list of the svcs that now exist in the zone. |
10840
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
324 |
LANG=C /usr/sbin/zlogin -S $ZONENAME /usr/bin/svcs -aH | \ |
8759 | 325 |
/usr/bin/nawk '{print $3}' >>$insttmpfile |
326 |
||
327 |
[[ -n $LOGFILE ]] && \ |
|
328 |
printf "[$(date)] ${MSG_PREFIX}${v_svcsinzone}\n" >&2 |
|
329 |
[[ -n $LOGFILE ]] && cat $insttmpfile >&2 |
|
330 |
||
331 |
# |
|
332 |
# Fix network services if shared stack. |
|
333 |
# |
|
334 |
if [[ "$STACK_TYPE" == "shared" ]]; then |
|
335 |
vlog "$v_fixnetsvcs" |
|
336 |
||
337 |
NETPHYSDEF="svc:/network/physical:default" |
|
338 |
NETPHYSNWAM="svc:/network/physical:nwam" |
|
339 |
||
340 |
/usr/bin/egrep -s "$NETPHYSDEF" $insttmpfile |
|
341 |
if (( $? == 0 )); then |
|
342 |
vlog "$v_enblsvc" "$NETPHYSDEF" |
|
343 |
/usr/sbin/zlogin -S $ZONENAME \ |
|
344 |
/usr/sbin/svcadm enable $NETPHYSDEF || \ |
|
345 |
error "$e_dissvc" "$NETPHYSDEF" |
|
346 |
fi |
|
347 |
||
348 |
/usr/bin/egrep -s "$NETPHYSNWAM" $insttmpfile |
|
349 |
if (( $? == 0 )); then |
|
350 |
vlog "$v_dissvc" "$NETPHYSNWAM" |
|
351 |
/usr/sbin/zlogin -S $ZONENAME \ |
|
352 |
/usr/sbin/svcadm disable $NETPHYSNWAM || \ |
|
353 |
error "$e_enblsvc" "$NETPHYSNWAM" |
|
354 |
fi |
|
355 |
||
356 |
for i in $(/usr/bin/egrep network/routing $insttmpfile) |
|
357 |
do |
|
358 |
# Disable the svc. |
|
359 |
vlog "$v_dissvc" "$i" |
|
360 |
/usr/sbin/zlogin -S $ZONENAME \ |
|
361 |
/usr/sbin/svcadm disable $i || \ |
|
362 |
error "$e_dissvc" $i |
|
363 |
done |
|
364 |
fi |
|
365 |
||
366 |
# |
|
367 |
# Disable well-known services that don't run in a zone. |
|
368 |
# |
|
369 |
vlog "$v_rminvalidsvcs" |
|
370 |
for i in $(/usr/bin/egrep -hv "^#" \ |
|
10840
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
371 |
/usr/lib/brand/solaris10/smf_disable.lst \ |
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
372 |
/etc/brand/solaris10/smf_disable.conf) |
8759 | 373 |
do |
374 |
# Skip svcs not installed in the zone. |
|
375 |
/usr/bin/egrep -s "$i:" $insttmpfile || continue |
|
376 |
||
377 |
# Disable the svc. |
|
378 |
vlog "$v_dissvc" "$i" |
|
379 |
/usr/sbin/zlogin -S $ZONENAME /usr/sbin/svcadm disable $i || \ |
|
380 |
error "$e_dissvc" $i |
|
381 |
done |
|
382 |
||
383 |
# |
|
384 |
# Since zones can't be NFS servers, disable all of the instances of |
|
385 |
# the shares svc. |
|
386 |
# |
|
387 |
for i in $(/usr/bin/egrep network/shares/group $insttmpfile) |
|
388 |
do |
|
389 |
vlog "$v_dissvc" "$i" |
|
390 |
/usr/sbin/zlogin -S $ZONENAME /usr/sbin/svcadm disable $i || \ |
|
391 |
error "$e_dissvc" $i |
|
392 |
done |
|
393 |
||
394 |
/usr/bin/rm -f $insttmpfile |
|
395 |
} |
|
396 |
||
397 |
# |
|
398 |
# Remove well-known pkgs that do not work inside a zone. |
|
399 |
# |
|
400 |
rm_pkgs() |
|
401 |
{ |
|
402 |
/usr/bin/cat <<-EOF > $ZONEROOT/tmp/admin || fatal "$e_adminf" |
|
403 |
mail= |
|
404 |
instance=overwrite |
|
405 |
partial=nocheck |
|
406 |
runlevel=nocheck |
|
407 |
idepend=nocheck |
|
408 |
rdepend=nocheck |
|
409 |
space=nocheck |
|
410 |
setuid=nocheck |
|
411 |
conflict=nocheck |
|
412 |
action=nocheck |
|
413 |
basedir=default |
|
414 |
EOF |
|
415 |
||
10840
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
416 |
for i in $(/usr/bin/egrep -hv "^#" /usr/lib/brand/solaris10/pkgrm.lst \ |
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
417 |
/etc/brand/solaris10/pkgrm.conf) |
8759 | 418 |
do |
419 |
[[ ! -d $ZONEROOT/var/sadm/pkg/$i ]] && continue |
|
420 |
||
421 |
vlog "$v_rmpkg" "$i" |
|
422 |
/usr/sbin/zlogin -S $ZONENAME \ |
|
423 |
/usr/sbin/pkgrm -na /tmp/admin $i >&2 || error "$e_rmpkg" $i |
|
424 |
done |
|
425 |
} |
|
426 |
||
427 |
# |
|
428 |
# Zoneadmd writes a one-line index file into the zone when the zone boots, |
|
429 |
# so any information about installed zones from the original system will |
|
430 |
# be lost at that time. Here we'll warn the sysadmin about any pre-existing |
|
431 |
# zones that they might want to clean up by hand, but we'll leave the zonepaths |
|
432 |
# in place in case they're on shared storage and will be migrated to |
|
433 |
# a new host. |
|
434 |
# |
|
435 |
warn_zones() |
|
436 |
{ |
|
437 |
zoneconfig=$ZONEROOT/etc/zones |
|
438 |
||
10840
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
439 |
[[ ! -d $zoneconfig ]] && return |
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
440 |
|
8759 | 441 |
if [[ -h $zoneconfig/index || ! -f $zoneconfig/index ]]; then |
442 |
error "$e_badfile" "/etc/zones/index" |
|
443 |
return |
|
444 |
fi |
|
445 |
||
446 |
NGZ=$(/usr/bin/nawk -F: '{ |
|
447 |
if (substr($1, 0, 1) == "#" || $1 == "global") |
|
448 |
continue |
|
449 |
||
450 |
if ($2 == "installed") |
|
451 |
printf("%s ", $1) |
|
452 |
}' $zoneconfig/index) |
|
453 |
||
454 |
# Return if there are no installed zones to warn about. |
|
455 |
[[ -z "$NGZ" ]] && return |
|
456 |
||
457 |
log "$v_rmzones" "$NGZ" |
|
458 |
||
459 |
NGZP=$(/usr/bin/nawk -F: '{ |
|
460 |
if (substr($1, 0, 1) == "#" || $1 == "global") |
|
461 |
continue |
|
462 |
||
463 |
if ($2 == "installed") |
|
464 |
printf("%s ", $3) |
|
465 |
}' $zoneconfig/index) |
|
466 |
||
467 |
log "$v_rmzonepaths" |
|
468 |
||
469 |
for i in $NGZP |
|
470 |
do |
|
471 |
log " %s" "$i" |
|
472 |
done |
|
473 |
} |
|
474 |
||
475 |
# |
|
476 |
# ^C Should cleanup; if the zone is running, it should try to halt it. |
|
477 |
# |
|
478 |
zone_is_running=0 |
|
479 |
trap trap_cleanup INT |
|
480 |
||
481 |
# |
|
482 |
# Parse the command line options. |
|
483 |
# |
|
484 |
OPT_U= |
|
485 |
OPT_V= |
|
486 |
OPT_M= |
|
487 |
OPT_L= |
|
10840
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
488 |
while getopts "uvm:l:" opt |
8759 | 489 |
do |
490 |
case "$opt" in |
|
491 |
u) OPT_U="-u";; |
|
492 |
v) OPT_V="-v";; |
|
493 |
m) MSG_PREFIX="$OPTARG"; OPT_M="-m \"$OPTARG\"";; |
|
494 |
l) LOGFILE="$OPTARG"; OPT_L="-l \"$OPTARG\"";; |
|
495 |
*) usage;; |
|
496 |
esac |
|
497 |
done |
|
498 |
shift OPTIND-1 |
|
499 |
||
500 |
(( $# < 1 )) && usage |
|
501 |
||
502 |
(( $# > 2 )) && usage |
|
503 |
||
504 |
[[ -n $LOGFILE ]] && exec 2>>$LOGFILE |
|
505 |
||
506 |
ZONENAME=$1 |
|
507 |
ZONEPATH=$2 |
|
10840
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
508 |
# XXX shared/common script currently uses lower case zonename & zonepath |
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
509 |
zonename="$ZONENAME" |
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
510 |
zonepath="$ZONEPATH" |
8759 | 511 |
ZONEROOT=$ZONEPATH/root |
512 |
||
513 |
e_badinfo=$(gettext "Failed to get '%s' zone resource") |
|
514 |
e_badfile=$(gettext "Invalid '%s' file within the zone") |
|
515 |
v_mkdirs=$(gettext "Creating mount points") |
|
516 |
v_nonetfix=$(gettext "Cannot update /etc/hostname.{net} file") |
|
517 |
v_adjust=$(gettext "Updating the image to run within a zone") |
|
518 |
v_stacktype=$(gettext "Stack type '%s'") |
|
519 |
v_booting=$(gettext "Booting zone to single user mode") |
|
10840
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
520 |
e_nosmf=$(gettext "SMF repository unavailable.") |
8759 | 521 |
v_svcsinzone=$(gettext "The following SMF services are installed:") |
522 |
v_rmhollowsvcs=$(gettext "Deleting SMF services from hollow packages") |
|
523 |
v_fixnetsvcs=$(gettext "Adjusting network SMF services") |
|
524 |
v_rminvalidsvcs=$(gettext "Disabling invalid SMF services") |
|
525 |
v_delsvc=$(gettext "Delete SMF svc '%s'") |
|
526 |
e_delsvc=$(gettext "deleting SMF svc '%s'") |
|
527 |
v_enblsvc=$(gettext "Enable SMF svc '%s'") |
|
528 |
e_enblsvc=$(gettext "enabling SMF svc '%s'") |
|
529 |
v_dissvc=$(gettext "Disable SMF svc '%s'") |
|
530 |
e_dissvc=$(gettext "disabling SMF svc '%s'") |
|
531 |
e_adminf=$(gettext "Unable to create admin file") |
|
532 |
v_rmpkg=$(gettext "Remove package '%s'") |
|
533 |
e_rmpkg=$(gettext "removing package '%s'") |
|
534 |
v_rmzones=$(gettext "The following zones in this image will be unusable: %s") |
|
535 |
v_rmzonepaths=$(gettext "These zonepaths could be removed from this image:") |
|
536 |
v_halting=$(gettext "Halting zone") |
|
537 |
e_shutdown=$(gettext "Shutting down zone %s...") |
|
538 |
e_badhalt=$(gettext "Zone halt failed") |
|
539 |
v_exitgood=$(gettext "Postprocessing successful.") |
|
540 |
e_exitfail=$(gettext "Postprocessing failed.") |
|
541 |
||
542 |
# |
|
543 |
# Do some validation on the paths we'll be accessing |
|
544 |
# |
|
10840
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
545 |
safe_dir /etc |
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
546 |
safe_dir /var |
12433
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
547 |
safe_dir /var/sadm |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
548 |
safe_dir /var/sadm/install |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
549 |
safe_dir /var/sadm/pkg |
10840
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
550 |
safe_opt_dir /etc/dfs |
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
551 |
safe_opt_dir /etc/lu |
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
552 |
safe_opt_dir /etc/zones |
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
553 |
|
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
554 |
mk_zone_dirs |
8759 | 555 |
|
556 |
# Now do the work to update the zone. |
|
557 |
||
558 |
# Check for zones inside of image. |
|
559 |
warn_zones |
|
8994
3f12cbbe75b6
6810950 p2v needs to handle cross-arch svc cleanup
<gerald.jelinek@sun.com>
parents:
8759
diff
changeset
|
560 |
fix_smf_pre_uoa |
8759 | 561 |
|
562 |
log "$v_adjust" |
|
563 |
||
564 |
# |
|
565 |
# Any errors in these functions are not considered fatal. The zone can be |
|
566 |
# be fixed up manually afterwards and it may need some additional manual |
|
567 |
# cleanup in any case. |
|
568 |
# |
|
569 |
||
570 |
STACK_TYPE=$(/usr/sbin/zoneadm -z $ZONENAME list -p | \ |
|
571 |
/usr/bin/nawk -F: '{print $7}') |
|
572 |
if (( $? != 0 )); then |
|
573 |
error "$e_badinfo" "stacktype" |
|
574 |
fi |
|
575 |
vlog "$v_stacktype" "$STACK_TYPE" |
|
576 |
||
10840
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
577 |
fix_lu |
8759 | 578 |
fix_net |
579 |
fix_nfs |
|
580 |
fix_vfstab |
|
581 |
||
582 |
vlog "$v_booting" |
|
583 |
||
584 |
# |
|
585 |
# Boot the zone so that we can do all of the SMF updates needed on the zone's |
|
586 |
# repository. |
|
587 |
# |
|
588 |
||
589 |
zone_is_running=1 |
|
590 |
||
591 |
/usr/sbin/zoneadm -z $ZONENAME boot -f -- -m milestone=none |
|
592 |
if (( $? != 0 )); then |
|
593 |
error "$e_badboot" |
|
8994
3f12cbbe75b6
6810950 p2v needs to handle cross-arch svc cleanup
<gerald.jelinek@sun.com>
parents:
8759
diff
changeset
|
594 |
/usr/bin/rm -f $SMFTMPFILE |
8759 | 595 |
fatal "$e_exitfail" |
596 |
fi |
|
597 |
||
12433
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
598 |
# |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
599 |
# Remove all files and directories installed by hollow packages. Such files |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
600 |
# and directories shouldn't exist inside zones. |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
601 |
# |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
602 |
hollow_pkgs=$(mktemp -t .hollow.pkgs.XXXXXX) |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
603 |
hollow_file_list=$(mktemp $ZONEROOT/.hollow.pkgs.files.XXXXXX) |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
604 |
hollow_dir_list=$(mktemp $ZONEROOT/.hollow.pkgs.dirs.XXXXXX) |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
605 |
[ -f "$hollow_pkgs" -a -f "$hollow_file_list" -a -f "$hollow_dir_list" ] || { |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
606 |
error "$e_tmpfile" |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
607 |
rm -f $hollow_pkgs $hollow_file_list $hollow_dir_list |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
608 |
fatal "$e_exitfail" |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
609 |
} |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
610 |
for pkg_name in $ZONEROOT/var/sadm/pkg/*; do |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
611 |
grep 'SUNW_PKG_HOLLOW=true' $pkg_name/pkginfo >/dev/null 2>&1 && \ |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
612 |
basename $pkg_name >>$hollow_pkgs |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
613 |
done |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
614 |
/usr/bin/nawk -v hollowpkgs=$hollow_pkgs -v filelist=$hollow_file_list \ |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
615 |
-v dirlist=$hollow_dir_list ' |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
616 |
BEGIN { |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
617 |
while (getline p <hollowpkgs > 0) |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
618 |
pkgs[p] = 1; |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
619 |
close(hollowpkgs); |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
620 |
} |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
621 |
{ |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
622 |
# fld is the field where the pkg names begin. |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
623 |
# nm is the file/dir entry name. |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
624 |
if ($2 == "f") { |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
625 |
fld=10; |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
626 |
nm=$1; |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
627 |
} else if ($2 == "d") { |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
628 |
fld=7; |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
629 |
nm=$1; |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
630 |
} else if ($2 == "s" || $2 == "l") { |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
631 |
fld=4; |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
632 |
split($1, a, "="); |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
633 |
nm=a[1]; |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
634 |
} else { |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
635 |
next; |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
636 |
} |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
637 |
|
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
638 |
# Determine whether the file or directory is delivered by any |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
639 |
# non-hollow packages. Files and directories can be |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
640 |
# delivered by multiple pkgs. The file or directory should only |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
641 |
# be removed if it is only delivered by hollow packages. |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
642 |
for (i = fld; i <= NF; i++) { |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
643 |
if (pkgs[get_pkg_name($i)] != 1) { |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
644 |
# We encountered a non-hollow package. Skip |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
645 |
# this entry. |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
646 |
next; |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
647 |
} |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
648 |
} |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
649 |
|
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
650 |
# The file or directory is only delivered by hollow packages. |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
651 |
# Mark it for removal. |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
652 |
if (fld != 7) |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
653 |
print nm >>filelist |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
654 |
else |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
655 |
print nm >>dirlist |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
656 |
} |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
657 |
|
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
658 |
# Get the clean pkg name from the fld entry. |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
659 |
function get_pkg_name(fld) { |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
660 |
# Remove any pkg control prefix (e.g. *, !) |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
661 |
first = substr(fld, 1, 1) |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
662 |
if (match(first, /[A-Za-z]/)) { |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
663 |
pname = fld |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
664 |
} else { |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
665 |
pname = substr(fld, 2) |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
666 |
} |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
667 |
|
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
668 |
# Then remove any class action script name |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
669 |
pos = index(pname, ":") |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
670 |
if (pos != 0) |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
671 |
pname = substr(pname, 1, pos - 1) |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
672 |
return (pname) |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
673 |
} |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
674 |
' $ZONEROOT/var/sadm/install/contents |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
675 |
/usr/sbin/zlogin -S $ZONENAME "cat /$(basename $hollow_file_list) | xargs rm -f" |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
676 |
/usr/sbin/zlogin -S $ZONENAME "sort -r /$(basename $hollow_dir_list) | \ |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
677 |
xargs rmdir >/dev/null 2>&1" |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
678 |
rm -f $hollow_pkgs $hollow_file_list $hollow_dir_list |
a15cace5f27d
6909222 reboot of system upgraded from 128 to build 129 generated error from an s10 zone due to boot-archive
jv227347 <Jordan.Vaughan@Sun.com>
parents:
10840
diff
changeset
|
679 |
|
8759 | 680 |
# cleanup SMF services |
681 |
fix_smf |
|
682 |
||
683 |
# remove invalid pkgs |
|
684 |
rm_pkgs |
|
685 |
||
10840
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
686 |
if [[ -z $failed && -n $OPT_U ]]; then |
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
687 |
vlog "$v_unconfig" |
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
688 |
|
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
689 |
sysunconfig_zone |
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
690 |
if (( $? != 0 )); then |
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
691 |
failed=1 |
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
692 |
fi |
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
693 |
fi |
7df556caf412
PSARC 2009/253 S10C
Gerald Jelinek <Gerald.Jelinek@Sun.COM>
parents:
8994
diff
changeset
|
694 |
|
8759 | 695 |
vlog "$v_halting" |
696 |
/usr/sbin/zoneadm -z $ZONENAME halt |
|
697 |
if (( $? != 0 )); then |
|
698 |
error "$e_badhalt" |
|
699 |
failed=1 |
|
700 |
fi |
|
701 |
zone_is_running=0 |
|
702 |
||
703 |
if [[ -n $failed ]]; then |
|
704 |
fatal "$e_exitfail" |
|
705 |
fi |
|
706 |
||
707 |
vlog "$v_exitgood" |
|
708 |
exit 0 |