1*ab5dfd5eS#!/bin/ksh -p
2*ab5dfd5eS#
3*ab5dfd5eS# CDDL HEADER START
4*ab5dfd5eS#
5*ab5dfd5eS# The contents of this file are subject to the terms of the
6*ab5dfd5eS# Common Development and Distribution License (the "License").
7*ab5dfd5eS# You may not use this file except in compliance with the License.
8*ab5dfd5eS#
9*ab5dfd5eS# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*ab5dfd5eS# or http://www.opensolaris.org/os/licensing.
11*ab5dfd5eS# See the License for the specific language governing permissions
12*ab5dfd5eS# and limitations under the License.
13*ab5dfd5eS#
14*ab5dfd5eS# When distributing Covered Code, include this CDDL HEADER in each
15*ab5dfd5eS# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*ab5dfd5eS# If applicable, add the following below this CDDL HEADER, with the
17*ab5dfd5eS# fields enclosed by brackets "[]" replaced with your own identifying
18*ab5dfd5eS# information: Portions Copyright [yyyy] [name of copyright owner]
19*ab5dfd5eS#
20*ab5dfd5eS# CDDL HEADER END
21*ab5dfd5eS#
22*ab5dfd5eS#
23*ab5dfd5eS# Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
24*ab5dfd5eS# Use is subject to license terms.
25*ab5dfd5eS#
26*ab5dfd5eS
27*ab5dfd5eS#
28*ab5dfd5eS# This postattach hook adds the service tag for the zone.
29*ab5dfd5eS# We need this in a postattach hook since the zone doesn't have
30*ab5dfd5eS# a UUID when the attach hook is run.
31*ab5dfd5eS#
32*ab5dfd5eS
33*ab5dfd5eS. /usr/lib/brand/solaris10/common.ksh
34*ab5dfd5eS
35*ab5dfd5eSinstall_media="-"
36*ab5dfd5eS
37*ab5dfd5eS# If we weren't passed at least two arguments, exit now.
38*ab5dfd5eS(( $# < 2 )) && exit $ZONE_SUBPROC_OK
39*ab5dfd5eS
40*ab5dfd5eSZONENAME="$1"
41*ab5dfd5eSZONEPATH="$2"
42*ab5dfd5eS
43*ab5dfd5eSshift 2
44*ab5dfd5eS
45*ab5dfd5eSnoexecute=0
46*ab5dfd5eSunset inst_type
47*ab5dfd5eS
48*ab5dfd5eS#
49*ab5dfd5eS# This hook will see the same options as the attach hook, so make sure
50*ab5dfd5eS# we accept all of these.
51*ab5dfd5eS#
52*ab5dfd5eSwhile getopts "a:d:nr:" opt; do
53*ab5dfd5eS	case $opt in
54*ab5dfd5eS		a)
55*ab5dfd5eS		 	inst_type="archive"
56*ab5dfd5eS			install_media="$OPTARG"
57*ab5dfd5eS			;;
58*ab5dfd5eS		d)
59*ab5dfd5eS		 	inst_type="directory"
60*ab5dfd5eS			install_media="$OPTARG"
61*ab5dfd5eS			;;
62*ab5dfd5eS		n)	noexecute=1 ;;
63*ab5dfd5eS		r)
64*ab5dfd5eS		 	inst_type="stdin"
65*ab5dfd5eS			install_media="$OPTARG"
66*ab5dfd5eS			;;
67*ab5dfd5eS		?)	exit $ZONE_SUBPROC_OK;;
68*ab5dfd5eS		*)	exit $ZONE_SUBPROC_OK;;
69*ab5dfd5eS	esac
70*ab5dfd5eSdone
71*ab5dfd5eSshift $((OPTIND-1))
72*ab5dfd5eS
73*ab5dfd5eS[ $noexecute -eq 1 ] && exit $ZONE_SUBPROC_OK
74*ab5dfd5eS[[ -z "$inst_type" ]] && inst_type="directory"
75*ab5dfd5eS
76*ab5dfd5eS# Add a service tag for this zone.
77*ab5dfd5eSadd_svc_tag "$ZONENAME" "attach $inst_type `basename $install_media`"
78*ab5dfd5eS
79*ab5dfd5eSexit $ZONE_SUBPROC_OK
80