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 # 22 23 # 24 # Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. 25 # 26 27 28 . /usr/lib/brand/ipkg/common.ksh 29 30 m_usage=$(gettext "detach [-n ].") 31 32 f_mount=$(gettext "Error: error mounting zone root dataset.") 33 f_ds_config=$(gettext "Failed to configure dataset %s: could not set %s.") 34 35 noexecute=0 36 37 # Other brand detach options are invalid for this brand. 38 while getopts "nR:z:" opt; do 39 case $opt in 40 n) noexecute=1 ;; 41 R) zonepath="$OPTARG" ;; 42 z) zonename="$OPTARG" ;; 43 ?) fail_usage "" ;; 44 *) fail_usage "";; 45 esac 46 done 47 shift $((OPTIND-1)) 48 49 if [ $noexecute -eq 1 ]; then 50 # dry-run - output zone's config and exit 51 cat /etc/zones/$zonename.xml 52 exit $ZONE_SUBPROC_OK 53 fi 54 55 # 56 # Detaching 57 # 58 # Leave the active dataset mounted on the zone's rootpath for ease of 59 # migration. 60 # 61 get_current_gzbe 62 get_zonepath_ds $zonepath 63 get_active_ds $CURRENT_GZBE $ZONEPATH_DS 64 65 /usr/sbin/zfs set zoned=off $ACTIVE_DS || \ 66 fail_incomplete "$f_ds_config" "$ACTIVE_DS" "zoned=off" 67 68 /usr/sbin/zfs set canmount=on $ACTIVE_DS || \ 69 fail_incomplete "$f_ds_config" "$ACTIVE_DS" "canmount=on" 70 71 # 72 # This mounts the dataset. 73 # XXX do we have to worry about subsidiary datasets? 74 # 75 /usr/sbin/zfs set mountpoint=$zonepath/root $ACTIVE_DS || \ 76 fail_incomplete "$f_ds_config" "$ACTIVE_DS" "mountpoint=$zonepath/root" 77 78 # 79 # There is no sw inventory in an ipkg branded zone, so just use the original 80 # xml file. 81 # 82 cp /etc/zones/$zonename.xml $zonepath/SUNWdetached.xml 83 84 exit $ZONE_SUBPROC_OK