1e71ca95cSGerald Jelinek#!/bin/ksh -p
2e71ca95cSGerald Jelinek#
3e71ca95cSGerald Jelinek# CDDL HEADER START
4e71ca95cSGerald Jelinek#
5e71ca95cSGerald Jelinek# The contents of this file are subject to the terms of the
6e71ca95cSGerald Jelinek# Common Development and Distribution License (the "License").
7e71ca95cSGerald Jelinek# You may not use this file except in compliance with the License.
8e71ca95cSGerald Jelinek#
9e71ca95cSGerald Jelinek# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10e71ca95cSGerald Jelinek# or http://www.opensolaris.org/os/licensing.
11e71ca95cSGerald Jelinek# See the License for the specific language governing permissions
12e71ca95cSGerald Jelinek# and limitations under the License.
13e71ca95cSGerald Jelinek#
14e71ca95cSGerald Jelinek# When distributing Covered Code, include this CDDL HEADER in each
15e71ca95cSGerald Jelinek# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16e71ca95cSGerald Jelinek# If applicable, add the following below this CDDL HEADER, with the
17e71ca95cSGerald Jelinek# fields enclosed by brackets "[]" replaced with your own identifying
18e71ca95cSGerald Jelinek# information: Portions Copyright [yyyy] [name of copyright owner]
19e71ca95cSGerald Jelinek#
20e71ca95cSGerald Jelinek# CDDL HEADER END
21e71ca95cSGerald Jelinek#
2298f4f4f6Sjv# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
23e71ca95cSGerald Jelinek#
24e71ca95cSGerald Jelinek
25e71ca95cSGerald Jelinek# NOTE: this script runs in the global zone and touches the non-global
26e71ca95cSGerald Jelinek# zone, so care should be taken to validate any modifications so that they
27e71ca95cSGerald Jelinek# are safe.
28e71ca95cSGerald Jelinek
29e71ca95cSGerald Jelinek. /usr/lib/brand/solaris10/common.ksh
30e71ca95cSGerald Jelinek
31e71ca95cSGerald JelinekLOGFILE=
32e71ca95cSGerald JelinekMSG_PREFIX="p2v: "
33e71ca95cSGerald JelinekEXIT_CODE=1
34e71ca95cSGerald Jelinek
35e71ca95cSGerald Jelinekusage()
36e71ca95cSGerald Jelinek{
37e71ca95cSGerald Jelinek	echo "$0 [-s] [-m msgprefix] [-u] [-v] [-b patchid]* zonename" >&2
38e71ca95cSGerald Jelinek	exit $EXIT_CODE
39e71ca95cSGerald Jelinek}
40e71ca95cSGerald Jelinek
41e71ca95cSGerald Jelinek# Clean up on interrupt
42e71ca95cSGerald Jelinektrap_cleanup()
43e71ca95cSGerald Jelinek{
44e71ca95cSGerald Jelinek	msg=$(gettext "Postprocessing cancelled due to interrupt.")
45e71ca95cSGerald Jelinek	error "$msg"
46e71ca95cSGerald Jelinek
47e71ca95cSGerald Jelinek	if (( $zone_is_running != 0 )); then
48e71ca95cSGerald Jelinek		error "$e_shutdown" "$ZONENAME"
49e71ca95cSGerald Jelinek		/usr/sbin/zoneadm -z $ZONENAME halt
50e71ca95cSGerald Jelinek	fi
51e71ca95cSGerald Jelinek
5298f4f4f6Sjv	#
5398f4f4f6Sjv	# Delete temporary files created during the hollow package removal
5498f4f4f6Sjv	# process.
5598f4f4f6Sjv	#
5698f4f4f6Sjv	rm -f $hollow_pkgs $hollow_file_list $hollow_dir_list
5798f4f4f6Sjv
58e71ca95cSGerald Jelinek	exit $EXIT_CODE
59e71ca95cSGerald Jelinek}
60e71ca95cSGerald Jelinek
61e71ca95cSGerald Jelinek#
62e71ca95cSGerald Jelinek# Disable any existing live-upgrade configuration.
63e71ca95cSGerald Jelinek# We have already called safe_dir to validate the etc/lu directory.
64e71ca95cSGerald Jelinek#
65e71ca95cSGerald Jelinekfix_lu()
66e71ca95cSGerald Jelinek{
67e71ca95cSGerald Jelinek	ludir=$ZONEROOT/etc/lu
68e71ca95cSGerald Jelinek
69e71ca95cSGerald Jelinek	[[ ! -d $ludir ]] && return
70e71ca95cSGerald Jelinek
71e71ca95cSGerald Jelinek	safe_rm etc/lutab
72e71ca95cSGerald Jelinek	safe_rm etc/lu/.BE_CONFIG
73e71ca95cSGerald Jelinek	safe_rm etc/lu/.CURR_VARS
74e71ca95cSGerald Jelinek	safe_rm etc/lu/ludb.local.xml
75e71ca95cSGerald Jelinek	for i in $ludir/ICF* $ludir/vtoc* $ludir/GRUB*
76e71ca95cSGerald Jelinek	do
77e71ca95cSGerald Jelinek		nm=`basename $i`
78e71ca95cSGerald Jelinek		safe_rm etc/lu/$nm
79e71ca95cSGerald Jelinek	done
80e71ca95cSGerald Jelinek}
81e71ca95cSGerald Jelinek
82e71ca95cSGerald Jelinek#
83e71ca95cSGerald Jelinek# For an exclusive stack zone, fix up the network configuration files.
84e71ca95cSGerald Jelinek# We need to do this even if unconfiguring the zone so sys-unconfig works
85e71ca95cSGerald Jelinek# correctly.
86e71ca95cSGerald Jelinek#
87e71ca95cSGerald Jelinekfix_net()
88e71ca95cSGerald Jelinek{
89e71ca95cSGerald Jelinek	[[ "$STACK_TYPE" == "shared" ]] && return
90e71ca95cSGerald Jelinek
91e71ca95cSGerald Jelinek	NETIF_CNT=$(/usr/bin/ls $ZONEROOT/etc/hostname.* 2>/dev/null | \
92e71ca95cSGerald Jelinek	    /usr/bin/wc -l)
93e71ca95cSGerald Jelinek	if (( $NETIF_CNT != 1 )); then
94e71ca95cSGerald Jelinek		vlog "$v_nonetfix"
95e71ca95cSGerald Jelinek		return
96e71ca95cSGerald Jelinek	fi
97e71ca95cSGerald Jelinek
98e71ca95cSGerald Jelinek	NET=$(LC_ALL=C /usr/sbin/zonecfg -z $ZONENAME info net)
99e71ca95cSGerald Jelinek	if (( $? != 0 )); then
100e71ca95cSGerald Jelinek		error "$e_badinfo" "net"
101e71ca95cSGerald Jelinek		return
102e71ca95cSGerald Jelinek	fi
103e71ca95cSGerald Jelinek
104e71ca95cSGerald Jelinek	NETIF=$(echo $NET | /usr/bin/nawk '{
105e71ca95cSGerald Jelinek		for (i = 1; i < NF; i++) {
106e71ca95cSGerald Jelinek			if ($i == "physical:") {
107e71ca95cSGerald Jelinek				if (length(net) == 0) {
108e71ca95cSGerald Jelinek					i++
109e71ca95cSGerald Jelinek					net = $i
110e71ca95cSGerald Jelinek				} else {
111e71ca95cSGerald Jelinek					multiple=1
112e71ca95cSGerald Jelinek				}
113e71ca95cSGerald Jelinek			}
114e71ca95cSGerald Jelinek		}
115e71ca95cSGerald Jelinek	}
116e71ca95cSGerald Jelinek	END {	if (!multiple)
117e71ca95cSGerald Jelinek			print net
118e71ca95cSGerald Jelinek	}')
119e71ca95cSGerald Jelinek
120e71ca95cSGerald Jelinek	if [[ -z "$NETIF" ]]; then
121e71ca95cSGerald Jelinek		vlog "$v_nonetfix"
122e71ca95cSGerald Jelinek		return
123e71ca95cSGerald Jelinek	fi
124e71ca95cSGerald Jelinek
125e71ca95cSGerald Jelinek	OLD_HOSTNET=$(/usr/bin/ls $ZONEROOT/etc/hostname.*)
126e71ca95cSGerald Jelinek	if [[ "$OLD_HOSTNET" != "$ZONEROOT/etc/hostname.$NETIF" ]]; then
127e71ca95cSGerald Jelinek		safe_move $OLD_HOSTNET $ZONEROOT/etc/hostname.$NETIF
128e71ca95cSGerald Jelinek	fi
129e71ca95cSGerald Jelinek}
130e71ca95cSGerald Jelinek
131e71ca95cSGerald Jelinek#
132e71ca95cSGerald Jelinek# Disable all of the shares since the zone cannot be an NFS server.
133e71ca95cSGerald Jelinek# Note that we disable the various instances of the svc:/network/shares/group
134e71ca95cSGerald Jelinek# SMF service in the fix_smf function.
135e71ca95cSGerald Jelinek#
136e71ca95cSGerald Jelinekfix_nfs()
137e71ca95cSGerald Jelinek{
138e71ca95cSGerald Jelinek	zonedfs=$ZONEROOT/etc/dfs
139e71ca95cSGerald Jelinek
140e71ca95cSGerald Jelinek	[[ ! -d $zonedfs ]] && return
141e71ca95cSGerald Jelinek
142e71ca95cSGerald Jelinek	if [[ -h $zonedfs/dfstab || ! -f $zonedfs/dfstab ]]; then
143e71ca95cSGerald Jelinek		error "$e_badfile" "/etc/dfs/dfstab"
144e71ca95cSGerald Jelinek		return
145e71ca95cSGerald Jelinek	fi
146e71ca95cSGerald Jelinek
147e71ca95cSGerald Jelinek	tmpfile=$(mktemp -t)
148e71ca95cSGerald Jelinek	if [[ $? == 1 || -z "$tmpfile" ]]; then
149e71ca95cSGerald Jelinek		error "$e_tmpfile"
150e71ca95cSGerald Jelinek		return
151e71ca95cSGerald Jelinek	fi
152e71ca95cSGerald Jelinek
153e71ca95cSGerald Jelinek	/usr/bin/nawk '{
154e71ca95cSGerald Jelinek		if (substr($1, 0, 1) == "#") {
155e71ca95cSGerald Jelinek			print $0
156e71ca95cSGerald Jelinek		} else {
157e71ca95cSGerald Jelinek			print "#", $0
158e71ca95cSGerald Jelinek			modified=1
159e71ca95cSGerald Jelinek		}
160e71ca95cSGerald Jelinek	}
161e71ca95cSGerald Jelinek	END {
162e71ca95cSGerald Jelinek		if (modified == 1) {
163e71ca95cSGerald Jelinek			printf("# Modified by p2v ")
164e71ca95cSGerald Jelinek			system("/usr/bin/date")
165e71ca95cSGerald Jelinek			exit 0
166e71ca95cSGerald Jelinek		}
167e71ca95cSGerald Jelinek		exit 1
168e71ca95cSGerald Jelinek	}' $zonedfs/dfstab >>$tmpfile
169e71ca95cSGerald Jelinek
170e71ca95cSGerald Jelinek	if (( $? == 0 )); then
171e71ca95cSGerald Jelinek		if [[ ! -f $zonedfs/dfstab.pre_p2v ]]; then
172e71ca95cSGerald Jelinek			safe_copy $zonedfs/dfstab $zonedfs/dfstab.pre_p2v
173e71ca95cSGerald Jelinek		fi
174e71ca95cSGerald Jelinek		safe_copy $tmpfile $zonedfs/dfstab
175e71ca95cSGerald Jelinek		chown root:sys $zonedfs/dfstab || \
176e71ca95cSGerald Jelinek		    fail_fatal "$f_chown" "$zonedfs/dfstab"
177e71ca95cSGerald Jelinek		chmod 644 $zonedfs/dfstab || \
178e71ca95cSGerald Jelinek		    fail_fatal "$f_chmod" "$zonedfs/dfstab"
179e71ca95cSGerald Jelinek	fi
180e71ca95cSGerald Jelinek	/usr/bin/rm -f $tmpfile
181e71ca95cSGerald Jelinek}
182e71ca95cSGerald Jelinek
183e71ca95cSGerald Jelinek#
184e71ca95cSGerald Jelinek# Comment out most of the old mounts since they are either unneeded or
185e71ca95cSGerald Jelinek# likely incorrect within a zone.  Specific mounts can be manually
186e71ca95cSGerald Jelinek# reenabled if the corresponding device is added to the zone.
187e71ca95cSGerald Jelinek#
188e71ca95cSGerald Jelinekfix_vfstab()
189e71ca95cSGerald Jelinek{
190e71ca95cSGerald Jelinek	if [[ -h $ZONEROOT/etc/vfstab || ! -f $ZONEROOT/etc/vfstab ]]; then
191e71ca95cSGerald Jelinek		error "$e_badfile" "/etc/vfstab"
192e71ca95cSGerald Jelinek		return
193e71ca95cSGerald Jelinek	fi
194e71ca95cSGerald Jelinek
195e71ca95cSGerald Jelinek	tmpfile=$(mktemp -t)
196e71ca95cSGerald Jelinek	if [[ $? == 1 || -z "$tmpfile" ]]; then
197e71ca95cSGerald Jelinek		error "$e_tmpfile"
198e71ca95cSGerald Jelinek		return
199e71ca95cSGerald Jelinek	fi
200e71ca95cSGerald Jelinek
201e71ca95cSGerald Jelinek	/usr/bin/nawk '{
202e71ca95cSGerald Jelinek		if (substr($1, 0, 1) == "#") {
203e71ca95cSGerald Jelinek			print $0
204e71ca95cSGerald Jelinek		} else if ($1 == "fd" || $1 == "/proc" || $1 == "swap" ||
205e71ca95cSGerald Jelinek		    $1 == "ctfs" || $1 == "objfs" || $1 == "sharefs" ||
206e71ca95cSGerald Jelinek		    $4 == "nfs" || $4 == "lofs") {
207e71ca95cSGerald Jelinek			print $0
208e71ca95cSGerald Jelinek		} else {
209e71ca95cSGerald Jelinek			print "#", $0
210e71ca95cSGerald Jelinek			modified=1
211e71ca95cSGerald Jelinek		}
212e71ca95cSGerald Jelinek	}
213e71ca95cSGerald Jelinek	END {
214e71ca95cSGerald Jelinek		if (modified == 1) {
215e71ca95cSGerald Jelinek			printf("# Modified by p2v ")
216e71ca95cSGerald Jelinek			system("/usr/bin/date")
217e71ca95cSGerald Jelinek			exit 0
218e71ca95cSGerald Jelinek		}
219e71ca95cSGerald Jelinek		exit 1
220e71ca95cSGerald Jelinek	}' $ZONEROOT/etc/vfstab >>$tmpfile
221e71ca95cSGerald Jelinek
222e71ca95cSGerald Jelinek	if (( $? == 0 )); then
223e71ca95cSGerald Jelinek		if [[ ! -f $ZONEROOT/etc/vfstab.pre_p2v ]]; then
224e71ca95cSGerald Jelinek			safe_copy $ZONEROOT/etc/vfstab \
225e71ca95cSGerald Jelinek			    $ZONEROOT/etc/vfstab.pre_p2v
226e71ca95cSGerald Jelinek		fi
227e71ca95cSGerald Jelinek		safe_copy $tmpfile $ZONEROOT/etc/vfstab
228e71ca95cSGerald Jelinek		chown root:sys $ZONEROOT/etc/vfstab || \
229e71ca95cSGerald Jelinek		    fail_fatal "$f_chown" "$ZONEROOT/etc/vfstab"
230e71ca95cSGerald Jelinek		chmod 644 $ZONEROOT/etc/vfstab || \
231e71ca95cSGerald Jelinek		    fail_fatal "$f_chmod" "$ZONEROOT/etc/vfstab"
232e71ca95cSGerald Jelinek	fi
233e71ca95cSGerald Jelinek	/usr/bin/rm -f $tmpfile
234e71ca95cSGerald Jelinek}
235e71ca95cSGerald Jelinek
236e71ca95cSGerald Jelinek#
237e71ca95cSGerald Jelinek# Collect the data needed to delete SMF services.  Since we're p2v-ing a
238e71ca95cSGerald Jelinek# physical image there are SMF services which must be deleted.
239e71ca95cSGerald Jelinek#
240e71ca95cSGerald Jelinekfix_smf_pre_uoa()
241e71ca95cSGerald Jelinek{
242e71ca95cSGerald Jelinek	#
243e71ca95cSGerald Jelinek	# Start by getting the svc manifests that are delivered by hollow
244e71ca95cSGerald Jelinek	# pkgs then use 'svccfg inventory' to get the names of the svcs
245e71ca95cSGerald Jelinek	# delivered by those manifests.  The svc names are saved into a
246e71ca95cSGerald Jelinek	# temporary file.
247e71ca95cSGerald Jelinek	#
248e71ca95cSGerald Jelinek
249e71ca95cSGerald Jelinek	SMFTMPFILE=$(mktemp -t smf.XXXXXX)
250e71ca95cSGerald Jelinek	if [[ $? == 1 || -z "$SMFTMPFILE" ]]; then
251e71ca95cSGerald Jelinek		error "$e_tmpfile"
252e71ca95cSGerald Jelinek		return
253e71ca95cSGerald Jelinek	fi
254e71ca95cSGerald Jelinek
255e71ca95cSGerald Jelinek	for i in $ZONEROOT/var/sadm/pkg/*
256e71ca95cSGerald Jelinek	do
257e71ca95cSGerald Jelinek		pkg=$(/usr/bin/basename $i)
258e71ca95cSGerald Jelinek		[[ ! -f $ZONEROOT/var/sadm/pkg/$pkg/save/pspool/$pkg/pkgmap ]] \
259e71ca95cSGerald Jelinek		    && continue
260e71ca95cSGerald Jelinek
261e71ca95cSGerald Jelinek		/usr/bin/egrep -s "SUNW_PKG_HOLLOW=true" \
262e71ca95cSGerald Jelinek		    $ZONEROOT/var/sadm/pkg/$pkg/pkginfo || continue
263e71ca95cSGerald Jelinek
264e71ca95cSGerald Jelinek		for j in $(/usr/bin/nawk '{if ($2 == "f" &&
265e71ca95cSGerald Jelinek		    substr($4, 1, 17) == "var/svc/manifest/") print $4}' \
266e71ca95cSGerald Jelinek		    $ZONEROOT/var/sadm/pkg/$pkg/save/pspool/$pkg/pkgmap)
267e71ca95cSGerald Jelinek		do
268e71ca95cSGerald Jelinek			svcs=$(SVCCFG_NOVALIDATE=1 \
269e71ca95cSGerald Jelinek			    SVCCFG_REPOSITORY=$ZONEROOT/etc/svc/repository.db \
270e71ca95cSGerald Jelinek			    /usr/sbin/svccfg inventory $ZONEROOT/$j)
271e71ca95cSGerald Jelinek			for k in $svcs
272e71ca95cSGerald Jelinek			do
273e71ca95cSGerald Jelinek				echo $k /$j >> $SMFTMPFILE
274e71ca95cSGerald Jelinek			done
275e71ca95cSGerald Jelinek		done
276e71ca95cSGerald Jelinek	done
277e71ca95cSGerald Jelinek}
278e71ca95cSGerald Jelinek
279e71ca95cSGerald Jelinek#
280e71ca95cSGerald Jelinek# Delete or disable SMF services.
281e71ca95cSGerald Jelinek# Zone is booted to milestone=none when this function is called.
282e71ca95cSGerald Jelinek# Use the SMF data collected by fix_smf_pre_uoa() to delete the services.
283e71ca95cSGerald Jelinek#
284e71ca95cSGerald Jelinekfix_smf()
285e71ca95cSGerald Jelinek{
286e71ca95cSGerald Jelinek	#
287e71ca95cSGerald Jelinek	# Zone was already booted to milestone=none, wait until SMF door exists.
288e71ca95cSGerald Jelinek	#
289e71ca95cSGerald Jelinek	for i in 0 1 2 3 4 5 6 7 8 9
290e71ca95cSGerald Jelinek	do
291e71ca95cSGerald Jelinek		[[ -r $ZONEROOT/etc/svc/volatile/repository_door ]] && break
292e71ca95cSGerald Jelinek		sleep 5
293e71ca95cSGerald Jelinek	done
294e71ca95cSGerald Jelinek
295e71ca95cSGerald Jelinek	if [[ $i -eq 9 && ! -r $ZONEROOT/etc/svc/volatile/repository_door ]];
296e71ca95cSGerald Jelinek	then
29719b77901S		#
29819b77901S		# The zone never booted, something is wrong.
29919b77901S		#
300e71ca95cSGerald Jelinek		error "$e_nosmf"
30119b77901S		error "$e_bootfail"
302e71ca95cSGerald Jelinek		/usr/bin/rm -f $SMFTMPFILE
30319b77901S		return 1
304e71ca95cSGerald Jelinek	fi
305e71ca95cSGerald Jelinek
306e71ca95cSGerald Jelinek	insttmpfile=$(mktemp -t instsmf.XXXXXX)
307e71ca95cSGerald Jelinek	if [[ $? == 1 || -z "$insttmpfile" ]]; then
308e71ca95cSGerald Jelinek		error "$e_tmpfile"
309e71ca95cSGerald Jelinek		/usr/bin/rm -f $SMFTMPFILE
31019b77901S		return 1
311e71ca95cSGerald Jelinek	fi
312e71ca95cSGerald Jelinek
313e71ca95cSGerald Jelinek	vlog "$v_rmhollowsvcs"
314e71ca95cSGerald Jelinek        while read fmri mfst
315e71ca95cSGerald Jelinek	do
316e71ca95cSGerald Jelinek		# Delete the svc.
317e71ca95cSGerald Jelinek		vlog "$v_delsvc" "$fmri"
318e71ca95cSGerald Jelinek		echo "/usr/sbin/svccfg delete -f $fmri"
319e71ca95cSGerald Jelinek		echo "/usr/sbin/svccfg delhash -d $mfst"
320e71ca95cSGerald Jelinek		echo "rm -f $mfst"
321e71ca95cSGerald Jelinek	done < $SMFTMPFILE > $ZONEROOT/tmp/smf_rm
322e71ca95cSGerald Jelinek
323e71ca95cSGerald Jelinek	/usr/sbin/zlogin -S $ZONENAME /bin/sh /tmp/smf_rm >/dev/null 2>&1
324e71ca95cSGerald Jelinek
325e71ca95cSGerald Jelinek	/usr/bin/rm -f $SMFTMPFILE
326e71ca95cSGerald Jelinek
327e71ca95cSGerald Jelinek	# Get a list of the svcs that now exist in the zone.
328e71ca95cSGerald Jelinek	LANG=C /usr/sbin/zlogin -S $ZONENAME /usr/bin/svcs -aH | \
329e71ca95cSGerald Jelinek	    /usr/bin/nawk '{print $3}' >>$insttmpfile
330e71ca95cSGerald Jelinek
331e71ca95cSGerald Jelinek	[[ -n $LOGFILE ]] && \
332e71ca95cSGerald Jelinek	    printf "[$(date)] ${MSG_PREFIX}${v_svcsinzone}\n" >&2
333e71ca95cSGerald Jelinek	[[ -n $LOGFILE ]] && cat $insttmpfile >&2
334e71ca95cSGerald Jelinek
3356f773e29SBaban Kenkre	#
3366f773e29SBaban Kenkre	# Import ip-interface-management service in S10C, network
3376f773e29SBaban Kenkre	# loopback service requires ipmgmtd in exclusive stack zones.
3386f773e29SBaban Kenkre	#
3396f773e29SBaban Kenkre	/usr/sbin/zlogin -S $ZONENAME /usr/sbin/svccfg import \
3406f773e29SBaban Kenkre	    $ZONEROOT/var/svc/manifest/network/network-ipmgmt.xml
3416f773e29SBaban Kenkre
342e71ca95cSGerald Jelinek	#
343e71ca95cSGerald Jelinek	# Fix network services if shared stack.
344e71ca95cSGerald Jelinek	#
345e71ca95cSGerald Jelinek	if [[ "$STACK_TYPE" == "shared" ]]; then
346e71ca95cSGerald Jelinek		vlog "$v_fixnetsvcs"
347e71ca95cSGerald Jelinek
348e71ca95cSGerald Jelinek		NETPHYSDEF="svc:/network/physical:default"
349e71ca95cSGerald Jelinek		NETPHYSNWAM="svc:/network/physical:nwam"
350e71ca95cSGerald Jelinek
351e71ca95cSGerald Jelinek		/usr/bin/egrep -s "$NETPHYSDEF" $insttmpfile
352e71ca95cSGerald Jelinek		if (( $? == 0 )); then
353e71ca95cSGerald Jelinek			vlog "$v_enblsvc" "$NETPHYSDEF"
354e71ca95cSGerald Jelinek			/usr/sbin/zlogin -S $ZONENAME \
355e71ca95cSGerald Jelinek			    /usr/sbin/svcadm enable $NETPHYSDEF || \
356e71ca95cSGerald Jelinek			    error "$e_dissvc" "$NETPHYSDEF"
357e71ca95cSGerald Jelinek		fi
358e71ca95cSGerald Jelinek
359e71ca95cSGerald Jelinek		/usr/bin/egrep -s "$NETPHYSNWAM" $insttmpfile
360e71ca95cSGerald Jelinek		if (( $? == 0 )); then
361e71ca95cSGerald Jelinek			vlog "$v_dissvc" "$NETPHYSNWAM"
362e71ca95cSGerald Jelinek			/usr/sbin/zlogin -S $ZONENAME \
363e71ca95cSGerald Jelinek			    /usr/sbin/svcadm disable $NETPHYSNWAM || \
364e71ca95cSGerald Jelinek			    error "$e_enblsvc" "$NETPHYSNWAM"
365e71ca95cSGerald Jelinek		fi
366e71ca95cSGerald Jelinek
367e71ca95cSGerald Jelinek		for i in $(/usr/bin/egrep network/routing $insttmpfile)
368e71ca95cSGerald Jelinek		do
369e71ca95cSGerald Jelinek			# Disable the svc.
370e71ca95cSGerald Jelinek			vlog "$v_dissvc" "$i"
371e71ca95cSGerald Jelinek			/usr/sbin/zlogin -S $ZONENAME \
372e71ca95cSGerald Jelinek			    /usr/sbin/svcadm disable $i || \
373e71ca95cSGerald Jelinek			    error "$e_dissvc" $i
374e71ca95cSGerald Jelinek		done
375e71ca95cSGerald Jelinek	fi
376e71ca95cSGerald Jelinek
377e71ca95cSGerald Jelinek	#
378e71ca95cSGerald Jelinek	# Disable well-known services that don't run in a zone.
379e71ca95cSGerald Jelinek	#
380e71ca95cSGerald Jelinek	vlog "$v_rminvalidsvcs"
381e71ca95cSGerald Jelinek	for i in $(/usr/bin/egrep -hv "^#" \
382e71ca95cSGerald Jelinek	    /usr/lib/brand/solaris10/smf_disable.lst \
383e71ca95cSGerald Jelinek	    /etc/brand/solaris10/smf_disable.conf)
384e71ca95cSGerald Jelinek	do
385e71ca95cSGerald Jelinek		# Skip svcs not installed in the zone.
386e71ca95cSGerald Jelinek		/usr/bin/egrep -s "$i:" $insttmpfile || continue
387e71ca95cSGerald Jelinek
388e71ca95cSGerald Jelinek		# Disable the svc.
389e71ca95cSGerald Jelinek		vlog "$v_dissvc" "$i"
390e71ca95cSGerald Jelinek		/usr/sbin/zlogin -S $ZONENAME /usr/sbin/svcadm disable $i || \
391e71ca95cSGerald Jelinek		    error "$e_dissvc" $i
392e71ca95cSGerald Jelinek	done
393e71ca95cSGerald Jelinek
394e71ca95cSGerald Jelinek	#
395e71ca95cSGerald Jelinek	# Since zones can't be NFS servers, disable all of the instances of
396e71ca95cSGerald Jelinek	# the shares svc.
397e71ca95cSGerald Jelinek	#
398e71ca95cSGerald Jelinek	for i in $(/usr/bin/egrep network/shares/group $insttmpfile)
399e71ca95cSGerald Jelinek	do
400e71ca95cSGerald Jelinek		vlog "$v_dissvc" "$i"
401e71ca95cSGerald Jelinek		/usr/sbin/zlogin -S $ZONENAME /usr/sbin/svcadm disable $i || \
402e71ca95cSGerald Jelinek		    error "$e_dissvc" $i
403e71ca95cSGerald Jelinek	done
404e71ca95cSGerald Jelinek
405e71ca95cSGerald Jelinek	/usr/bin/rm -f $insttmpfile
40619b77901S
40719b77901S	return 0
408e71ca95cSGerald Jelinek}
409e71ca95cSGerald Jelinek
410e71ca95cSGerald Jelinek#
411e71ca95cSGerald Jelinek# Remove well-known pkgs that do not work inside a zone.
412e71ca95cSGerald Jelinek#
413e71ca95cSGerald Jelinekrm_pkgs()
414e71ca95cSGerald Jelinek{
415e71ca95cSGerald Jelinek	/usr/bin/cat <<-EOF > $ZONEROOT/tmp/admin || fatal "$e_adminf"
416e71ca95cSGerald Jelinek	mail=
417e71ca95cSGerald Jelinek	instance=overwrite
418e71ca95cSGerald Jelinek	partial=nocheck
419e71ca95cSGerald Jelinek	runlevel=nocheck
420e71ca95cSGerald Jelinek	idepend=nocheck
421e71ca95cSGerald Jelinek	rdepend=nocheck
422e71ca95cSGerald Jelinek	space=nocheck
423e71ca95cSGerald Jelinek	setuid=nocheck
424e71ca95cSGerald Jelinek	conflict=nocheck
425e71ca95cSGerald Jelinek	action=nocheck
426e71ca95cSGerald Jelinek	basedir=default
427e71ca95cSGerald Jelinek	EOF
428e71ca95cSGerald Jelinek
429e71ca95cSGerald Jelinek	for i in $(/usr/bin/egrep -hv "^#" /usr/lib/brand/solaris10/pkgrm.lst \
430e71ca95cSGerald Jelinek	    /etc/brand/solaris10/pkgrm.conf)
431e71ca95cSGerald Jelinek	do
432e71ca95cSGerald Jelinek		[[ ! -d $ZONEROOT/var/sadm/pkg/$i ]] && continue
433e71ca95cSGerald Jelinek
434e71ca95cSGerald Jelinek		vlog "$v_rmpkg" "$i"
435e71ca95cSGerald Jelinek		/usr/sbin/zlogin -S $ZONENAME \
436e71ca95cSGerald Jelinek		    /usr/sbin/pkgrm -na /tmp/admin $i >&2 || error "$e_rmpkg" $i
437e71ca95cSGerald Jelinek	done
438e71ca95cSGerald Jelinek}
439e71ca95cSGerald Jelinek
440e71ca95cSGerald Jelinek#
441e71ca95cSGerald Jelinek# Zoneadmd writes a one-line index file into the zone when the zone boots,
442e71ca95cSGerald Jelinek# so any information about installed zones from the original system will
443e71ca95cSGerald Jelinek# be lost at that time.  Here we'll warn the sysadmin about any pre-existing
444e71ca95cSGerald Jelinek# zones that they might want to clean up by hand, but we'll leave the zonepaths
445e71ca95cSGerald Jelinek# in place in case they're on shared storage and will be migrated to
446e71ca95cSGerald Jelinek# a new host.
447e71ca95cSGerald Jelinek#
448e71ca95cSGerald Jelinekwarn_zones()
449e71ca95cSGerald Jelinek{
450e71ca95cSGerald Jelinek	zoneconfig=$ZONEROOT/etc/zones
451e71ca95cSGerald Jelinek
452e71ca95cSGerald Jelinek	[[ ! -d $zoneconfig ]] && return
453e71ca95cSGerald Jelinek
454e71ca95cSGerald Jelinek	if [[ -h $zoneconfig/index || ! -f $zoneconfig/index ]]; then
455e71ca95cSGerald Jelinek		error "$e_badfile" "/etc/zones/index"
456e71ca95cSGerald Jelinek		return
457e71ca95cSGerald Jelinek	fi
458e71ca95cSGerald Jelinek
459e71ca95cSGerald Jelinek	NGZ=$(/usr/bin/nawk -F: '{
460e71ca95cSGerald Jelinek		if (substr($1, 0, 1) == "#" || $1 == "global")
461*ac05f74fSCody Peter Mello			next
462e71ca95cSGerald Jelinek
463e71ca95cSGerald Jelinek		if ($2 == "installed")
464e71ca95cSGerald Jelinek			printf("%s ", $1)
465e71ca95cSGerald Jelinek	}' $zoneconfig/index)
466e71ca95cSGerald Jelinek
467e71ca95cSGerald Jelinek	# Return if there are no installed zones to warn about.
468e71ca95cSGerald Jelinek	[[ -z "$NGZ" ]] && return
469e71ca95cSGerald Jelinek
470e71ca95cSGerald Jelinek	log "$v_rmzones" "$NGZ"
471e71ca95cSGerald Jelinek
472e71ca95cSGerald Jelinek	NGZP=$(/usr/bin/nawk -F: '{
473e71ca95cSGerald Jelinek		if (substr($1, 0, 1) == "#" || $1 == "global")
474e71ca95cSGerald Jelinek			continue
475e71ca95cSGerald Jelinek
476e71ca95cSGerald Jelinek		if ($2 == "installed")
477e71ca95cSGerald Jelinek			printf("%s ", $3)
478e71ca95cSGerald Jelinek	}' $zoneconfig/index)
479e71ca95cSGerald Jelinek
480e71ca95cSGerald Jelinek	log "$v_rmzonepaths"
481e71ca95cSGerald Jelinek
482e71ca95cSGerald Jelinek	for i in $NGZP
483e71ca95cSGerald Jelinek	do
484e71ca95cSGerald Jelinek		log "    %s" "$i"
485e71ca95cSGerald Jelinek	done
486e71ca95cSGerald Jelinek}
487e71ca95cSGerald Jelinek
488e71ca95cSGerald Jelinek#
489e71ca95cSGerald Jelinek# ^C Should cleanup; if the zone is running, it should try to halt it.
490e71ca95cSGerald Jelinek#
491e71ca95cSGerald Jelinekzone_is_running=0
492e71ca95cSGerald Jelinektrap trap_cleanup INT
493e71ca95cSGerald Jelinek
494e71ca95cSGerald Jelinek#
495e71ca95cSGerald Jelinek# Parse the command line options.
496e71ca95cSGerald Jelinek#
497e71ca95cSGerald JelinekOPT_U=
498e71ca95cSGerald JelinekOPT_V=
499e71ca95cSGerald JelinekOPT_M=
500e71ca95cSGerald JelinekOPT_L=
501e71ca95cSGerald Jelinekwhile getopts "uvm:l:" opt
502e71ca95cSGerald Jelinekdo
503e71ca95cSGerald Jelinek	case "$opt" in
504e71ca95cSGerald Jelinek		u)	OPT_U="-u";;
505e71ca95cSGerald Jelinek		v)	OPT_V="-v";;
506e71ca95cSGerald Jelinek		m)	MSG_PREFIX="$OPTARG"; OPT_M="-m \"$OPTARG\"";;
507e71ca95cSGerald Jelinek		l)	LOGFILE="$OPTARG"; OPT_L="-l \"$OPTARG\"";;
508e71ca95cSGerald Jelinek		*)	usage;;
509e71ca95cSGerald Jelinek	esac
510e71ca95cSGerald Jelinekdone
511e71ca95cSGerald Jelinekshift OPTIND-1
512e71ca95cSGerald Jelinek
513e71ca95cSGerald Jelinek(( $# < 1 )) && usage
514e71ca95cSGerald Jelinek
515e71ca95cSGerald Jelinek(( $# > 2 )) && usage
516e71ca95cSGerald Jelinek
517e71ca95cSGerald Jelinek[[ -n $LOGFILE ]] && exec 2>>$LOGFILE
518e71ca95cSGerald Jelinek
519e71ca95cSGerald JelinekZONENAME=$1
520e71ca95cSGerald JelinekZONEPATH=$2
521e71ca95cSGerald Jelinek# XXX shared/common script currently uses lower case zonename & zonepath
522e71ca95cSGerald Jelinekzonename="$ZONENAME"
523e71ca95cSGerald Jelinekzonepath="$ZONEPATH"
524e71ca95cSGerald JelinekZONEROOT=$ZONEPATH/root
525e71ca95cSGerald Jelinek
526e71ca95cSGerald Jelineke_badinfo=$(gettext "Failed to get '%s' zone resource")
527e71ca95cSGerald Jelineke_badfile=$(gettext "Invalid '%s' file within the zone")
528e71ca95cSGerald Jelinekv_mkdirs=$(gettext "Creating mount points")
529e71ca95cSGerald Jelinekv_nonetfix=$(gettext "Cannot update /etc/hostname.{net} file")
530e71ca95cSGerald Jelinekv_adjust=$(gettext "Updating the image to run within a zone")
531e71ca95cSGerald Jelinekv_stacktype=$(gettext "Stack type '%s'")
532e71ca95cSGerald Jelinekv_booting=$(gettext "Booting zone to single user mode")
53319b77901Se_bootfail=$(gettext "Failed to boot zone to single user mode.")
534e71ca95cSGerald Jelineke_nosmf=$(gettext "SMF repository unavailable.")
535e71ca95cSGerald Jelinekv_svcsinzone=$(gettext "The following SMF services are installed:")
536e71ca95cSGerald Jelinekv_rmhollowsvcs=$(gettext "Deleting SMF services from hollow packages")
537e71ca95cSGerald Jelinekv_fixnetsvcs=$(gettext "Adjusting network SMF services")
538e71ca95cSGerald Jelinekv_rminvalidsvcs=$(gettext "Disabling invalid SMF services")
539e71ca95cSGerald Jelinekv_delsvc=$(gettext "Delete SMF svc '%s'")
540e71ca95cSGerald Jelineke_delsvc=$(gettext "deleting SMF svc '%s'")
541e71ca95cSGerald Jelinekv_enblsvc=$(gettext "Enable SMF svc '%s'")
542e71ca95cSGerald Jelineke_enblsvc=$(gettext "enabling SMF svc '%s'")
543e71ca95cSGerald Jelinekv_dissvc=$(gettext "Disable SMF svc '%s'")
544e71ca95cSGerald Jelineke_dissvc=$(gettext "disabling SMF svc '%s'")
545e71ca95cSGerald Jelineke_adminf=$(gettext "Unable to create admin file")
546e71ca95cSGerald Jelinekv_rmpkg=$(gettext "Remove package '%s'")
547e71ca95cSGerald Jelineke_rmpkg=$(gettext "removing package '%s'")
548e71ca95cSGerald Jelinekv_rmzones=$(gettext "The following zones in this image will be unusable: %s")
549e71ca95cSGerald Jelinekv_rmzonepaths=$(gettext "These zonepaths could be removed from this image:")
550e71ca95cSGerald Jelinekv_halting=$(gettext "Halting zone")
551e71ca95cSGerald Jelineke_shutdown=$(gettext "Shutting down zone %s...")
552e71ca95cSGerald Jelineke_badhalt=$(gettext "Zone halt failed")
553e71ca95cSGerald Jelinekv_exitgood=$(gettext "Postprocessing successful.")
554e71ca95cSGerald Jelineke_exitfail=$(gettext "Postprocessing failed.")
555e71ca95cSGerald Jelinek
556e71ca95cSGerald Jelinek#
557e71ca95cSGerald Jelinek# Do some validation on the paths we'll be accessing
558e71ca95cSGerald Jelinek#
559e71ca95cSGerald Jelineksafe_dir /etc
560e71ca95cSGerald Jelineksafe_dir /var
56198f4f4f6Sjvsafe_dir /var/sadm
56298f4f4f6Sjvsafe_dir /var/sadm/install
56398f4f4f6Sjvsafe_dir /var/sadm/pkg
564e71ca95cSGerald Jelineksafe_opt_dir /etc/dfs
565e71ca95cSGerald Jelineksafe_opt_dir /etc/lu
566e71ca95cSGerald Jelineksafe_opt_dir /etc/zones
567e71ca95cSGerald Jelinek
568e71ca95cSGerald Jelinekmk_zone_dirs
569e71ca95cSGerald Jelinek
570e71ca95cSGerald Jelinek# Now do the work to update the zone.
571e71ca95cSGerald Jelinek
572e71ca95cSGerald Jelinek# Check for zones inside of image.
573e71ca95cSGerald Jelinekwarn_zones
574e71ca95cSGerald Jelinekfix_smf_pre_uoa
575e71ca95cSGerald Jelinek
576e71ca95cSGerald Jelineklog "$v_adjust"
577e71ca95cSGerald Jelinek
578e71ca95cSGerald Jelinek#
579e71ca95cSGerald Jelinek# Any errors in these functions are not considered fatal.  The zone can be
580e71ca95cSGerald Jelinek# be fixed up manually afterwards and it may need some additional manual
581e71ca95cSGerald Jelinek# cleanup in any case.
582e71ca95cSGerald Jelinek#
583e71ca95cSGerald Jelinek
584e71ca95cSGerald JelinekSTACK_TYPE=$(/usr/sbin/zoneadm -z $ZONENAME list -p | \
585e71ca95cSGerald Jelinek    /usr/bin/nawk -F: '{print $7}')
586e71ca95cSGerald Jelinekif (( $? != 0 )); then
587e71ca95cSGerald Jelinek	error "$e_badinfo" "stacktype"
588e71ca95cSGerald Jelinekfi
589e71ca95cSGerald Jelinekvlog "$v_stacktype" "$STACK_TYPE"
590e71ca95cSGerald Jelinek
591e71ca95cSGerald Jelinekfix_lu
592e71ca95cSGerald Jelinekfix_net
593e71ca95cSGerald Jelinekfix_nfs
594e71ca95cSGerald Jelinekfix_vfstab
595e71ca95cSGerald Jelinek
596e71ca95cSGerald Jelinekvlog "$v_booting"
597e71ca95cSGerald Jelinek
598e71ca95cSGerald Jelinek#
599e71ca95cSGerald Jelinek# Boot the zone so that we can do all of the SMF updates needed on the zone's
600e71ca95cSGerald Jelinek# repository.
601e71ca95cSGerald Jelinek#
602e71ca95cSGerald Jelinek
603e71ca95cSGerald Jelinekzone_is_running=1
604e71ca95cSGerald Jelinek
605e71ca95cSGerald Jelinek/usr/sbin/zoneadm -z $ZONENAME boot -f -- -m milestone=none
606e71ca95cSGerald Jelinekif (( $? != 0 )); then
607e71ca95cSGerald Jelinek	error "$e_badboot"
608e71ca95cSGerald Jelinek	/usr/bin/rm -f $SMFTMPFILE
609e71ca95cSGerald Jelinek	fatal "$e_exitfail"
610e71ca95cSGerald Jelinekfi
611e71ca95cSGerald Jelinek
61298f4f4f6Sjv#
61398f4f4f6Sjv# Remove all files and directories installed by hollow packages.  Such files
61498f4f4f6Sjv# and directories shouldn't exist inside zones.
61598f4f4f6Sjv#
61698f4f4f6Sjvhollow_pkgs=$(mktemp -t .hollow.pkgs.XXXXXX)
61798f4f4f6Sjvhollow_file_list=$(mktemp $ZONEROOT/.hollow.pkgs.files.XXXXXX)
61898f4f4f6Sjvhollow_dir_list=$(mktemp $ZONEROOT/.hollow.pkgs.dirs.XXXXXX)
61998f4f4f6Sjv[ -f "$hollow_pkgs" -a -f "$hollow_file_list" -a -f "$hollow_dir_list" ] || {
62098f4f4f6Sjv	error "$e_tmpfile"
62198f4f4f6Sjv	rm -f $hollow_pkgs $hollow_file_list $hollow_dir_list
62298f4f4f6Sjv	fatal "$e_exitfail"
62398f4f4f6Sjv}
62498f4f4f6Sjvfor pkg_name in $ZONEROOT/var/sadm/pkg/*; do
62598f4f4f6Sjv	grep 'SUNW_PKG_HOLLOW=true' $pkg_name/pkginfo >/dev/null 2>&1 && \
62698f4f4f6Sjv	    basename $pkg_name >>$hollow_pkgs
62798f4f4f6Sjvdone
62898f4f4f6Sjv/usr/bin/nawk -v hollowpkgs=$hollow_pkgs -v filelist=$hollow_file_list \
62998f4f4f6Sjv    -v dirlist=$hollow_dir_list '
63098f4f4f6Sjv	BEGIN {
63198f4f4f6Sjv		while (getline p <hollowpkgs > 0)
63298f4f4f6Sjv			pkgs[p] = 1;
63398f4f4f6Sjv		close(hollowpkgs);
63498f4f4f6Sjv	}
63598f4f4f6Sjv	{
63698f4f4f6Sjv		# fld is the field where the pkg names begin.
63798f4f4f6Sjv		# nm is the file/dir entry name.
63898f4f4f6Sjv		if ($2 == "f") {
63998f4f4f6Sjv			fld=10;
64098f4f4f6Sjv			nm=$1;
64198f4f4f6Sjv		} else if ($2 == "d") {
64298f4f4f6Sjv			fld=7;
64398f4f4f6Sjv			nm=$1;
64498f4f4f6Sjv		} else if ($2 == "s" || $2 == "l") {
64598f4f4f6Sjv			fld=4;
64698f4f4f6Sjv			split($1, a, "=");
64798f4f4f6Sjv			nm=a[1];
64898f4f4f6Sjv		} else {
64998f4f4f6Sjv			next;
65098f4f4f6Sjv		}
65198f4f4f6Sjv
65298f4f4f6Sjv		# Determine whether the file or directory is delivered by any
65398f4f4f6Sjv		# non-hollow packages.  Files and directories can be
65498f4f4f6Sjv		# delivered by multiple pkgs.  The file or directory should only
65598f4f4f6Sjv		# be removed if it is only delivered by hollow packages.
65698f4f4f6Sjv		for (i = fld; i <= NF; i++) {
65798f4f4f6Sjv			if (pkgs[get_pkg_name($i)] != 1) {
65898f4f4f6Sjv				# We encountered a non-hollow package.  Skip
65998f4f4f6Sjv				# this entry.
66098f4f4f6Sjv				next;
66198f4f4f6Sjv			}
66298f4f4f6Sjv		}
66398f4f4f6Sjv
66498f4f4f6Sjv		# The file or directory is only delivered by hollow packages.
66598f4f4f6Sjv		# Mark it for removal.
66698f4f4f6Sjv		if (fld != 7)
66798f4f4f6Sjv			print nm >>filelist
66898f4f4f6Sjv		else
66998f4f4f6Sjv			print nm >>dirlist
67098f4f4f6Sjv	}
67198f4f4f6Sjv
67298f4f4f6Sjv	# Get the clean pkg name from the fld entry.
67398f4f4f6Sjv	function get_pkg_name(fld) {
67498f4f4f6Sjv		# Remove any pkg control prefix (e.g. *, !)
67598f4f4f6Sjv		first = substr(fld, 1, 1)
67698f4f4f6Sjv		if (match(first, /[A-Za-z]/)) {
67798f4f4f6Sjv			pname = fld
67898f4f4f6Sjv		} else {
67998f4f4f6Sjv			pname = substr(fld, 2)
68098f4f4f6Sjv		}
68198f4f4f6Sjv
68298f4f4f6Sjv		# Then remove any class action script name
68398f4f4f6Sjv		pos = index(pname, ":")
68498f4f4f6Sjv		if (pos != 0)
68598f4f4f6Sjv			pname = substr(pname, 1, pos - 1)
68698f4f4f6Sjv                return (pname)
68798f4f4f6Sjv        }
68898f4f4f6Sjv' $ZONEROOT/var/sadm/install/contents
68998f4f4f6Sjv/usr/sbin/zlogin -S $ZONENAME "cat /$(basename $hollow_file_list) | xargs rm -f"
69098f4f4f6Sjv/usr/sbin/zlogin -S $ZONENAME "sort -r /$(basename $hollow_dir_list) | \
69198f4f4f6Sjv    xargs rmdir >/dev/null 2>&1"
69298f4f4f6Sjvrm -f $hollow_pkgs $hollow_file_list $hollow_dir_list
69398f4f4f6Sjv
694e71ca95cSGerald Jelinek# cleanup SMF services
69519b77901Sfix_smf || failed=1
696e71ca95cSGerald Jelinek
697e71ca95cSGerald Jelinek# remove invalid pkgs
69819b77901S[[ -z $failed ]] && rm_pkgs
699e71ca95cSGerald Jelinek
700e71ca95cSGerald Jelinekif [[ -z $failed && -n $OPT_U ]]; then
701e71ca95cSGerald Jelinek	vlog "$v_unconfig"
702e71ca95cSGerald Jelinek
703e71ca95cSGerald Jelinek	sysunconfig_zone
704e71ca95cSGerald Jelinek	if (( $? != 0 )); then
705e71ca95cSGerald Jelinek		failed=1
706e71ca95cSGerald Jelinek	fi
707e71ca95cSGerald Jelinekfi
708e71ca95cSGerald Jelinek
709e71ca95cSGerald Jelinekvlog "$v_halting"
710e71ca95cSGerald Jelinek/usr/sbin/zoneadm -z $ZONENAME halt
711e71ca95cSGerald Jelinekif (( $? != 0 )); then
712e71ca95cSGerald Jelinek	error "$e_badhalt"
713e71ca95cSGerald Jelinek	failed=1
714e71ca95cSGerald Jelinekfi
715e71ca95cSGerald Jelinekzone_is_running=0
716e71ca95cSGerald Jelinek
717e71ca95cSGerald Jelinekif [[ -n $failed ]]; then
718e71ca95cSGerald Jelinek	fatal "$e_exitfail"
719e71ca95cSGerald Jelinekfi
720e71ca95cSGerald Jelinek
721e71ca95cSGerald Jelinekvlog "$v_exitgood"
722e71ca95cSGerald Jelinekexit 0
723