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#
22e71ca95cSGerald Jelinek#
23ab5dfd5eS# Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
24e71ca95cSGerald Jelinek# Use is subject to license terms.
25e71ca95cSGerald Jelinek#
26e71ca95cSGerald Jelinek
27e71ca95cSGerald Jelinek. /usr/lib/brand/solaris10/common.ksh
28e71ca95cSGerald Jelinek
29e71ca95cSGerald Jelinekm_usage=$(gettext  "solaris10 brand usage: detach [-n].")
30e71ca95cSGerald Jelinek
31e71ca95cSGerald JelinekEXIT_CODE=$ZONE_SUBPROC_USAGE
32e71ca95cSGerald Jelinek
33e71ca95cSGerald Jelinek# If we weren't passed at least two arguments, exit now.
34e71ca95cSGerald Jelinek(( $# < 2 )) && exit $ZONE_SUBPROC_USAGE
35e71ca95cSGerald Jelinek
36e71ca95cSGerald JelinekZONENAME="$1"
37e71ca95cSGerald JelinekZONEPATH="$2"
38e71ca95cSGerald Jelinek# XXX shared/common script currently uses lower case zonename & zonepath
39e71ca95cSGerald Jelinekzonename="$ZONENAME"
40e71ca95cSGerald Jelinekzonepath="$ZONEPATH"
41e71ca95cSGerald Jelinek
42e71ca95cSGerald Jelinekshift; shift	# remove ZONENAME and ZONEPATH from arguments array
43e71ca95cSGerald Jelinek
44e71ca95cSGerald Jelineknoexecute=0
45e71ca95cSGerald Jelinek
46e71ca95cSGerald Jelinek# Other brand attach options are invalid for this brand.
47e71ca95cSGerald Jelinekwhile getopts "n" opt; do
48e71ca95cSGerald Jelinek	case $opt in
49e71ca95cSGerald Jelinek		n)	noexecute=1 ;;
50e71ca95cSGerald Jelinek		?)	printf "$m_usage\n"
51e71ca95cSGerald Jelinek			exit $ZONE_SUBPROC_USAGE;;
52e71ca95cSGerald Jelinek		*)	printf "$m_usage\n"
53e71ca95cSGerald Jelinek			exit $ZONE_SUBPROC_USAGE;;
54e71ca95cSGerald Jelinek	esac
55e71ca95cSGerald Jelinekdone
56e71ca95cSGerald Jelinekshift $((OPTIND-1))
57e71ca95cSGerald Jelinek
58e71ca95cSGerald Jelinekif [[ $noexecute == 1 ]]; then
59e71ca95cSGerald Jelinek	cat /etc/zones/$ZONENAME.xml
60e71ca95cSGerald Jelinek	exit $ZONE_SUBPROC_OK
61e71ca95cSGerald Jelinekfi
62e71ca95cSGerald Jelinek
63*090f667dSget_zonepath_ds $ZONEPATH
64*090f667dSget_active_ds $ZONEPATH_DS
65*090f667dSzfs set zoned=off $ACTIVE_DS >/dev/null 2>&1
66*090f667dSzfs set canmount=on $ACTIVE_DS >/dev/null 2>&1
67*090f667dSzfs set mountpoint=$ZONEPATH/root $ACTIVE_DS >/dev/null 2>&1
68*090f667dS
69e71ca95cSGerald Jelinekcp /etc/zones/$ZONENAME.xml $ZONEPATH/SUNWdetached.xml
70e71ca95cSGerald Jelinek
71ab5dfd5eS# Remove the service tag for this zone.
72ab5dfd5eSdel_svc_tag "$ZONENAME"
73ab5dfd5eS
74e71ca95cSGerald Jelinekexit $ZONE_SUBPROC_OK
75