src/brand/detach
changeset 2390 f1c659f5c28e
parent 2235 1f446820dcb0
equal deleted inserted replaced
2235:1f446820dcb0 2390:f1c659f5c28e
    22 
    22 
    23 #
    23 #
    24 # Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
    24 # Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
    25 #
    25 #
    26 
    26 
       
    27 
    27 . /usr/lib/brand/ipkg/common.ksh
    28 . /usr/lib/brand/ipkg/common.ksh
    28 
    29 
    29 m_usage=$(gettext  "detach [-n ].")
    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.")
    30 
    34 
    31 noexecute=0
    35 noexecute=0
    32 
    36 
    33 # Other brand detach options are invalid for this brand.
    37 # Other brand detach options are invalid for this brand.
    34 while getopts "nR:z:" opt; do
    38 while getopts "nR:z:" opt; do
    35 	case $opt in
    39 	case $opt in
    36 		n)	noexecute=1 ;;
    40 		n)	noexecute=1 ;;
    37 		R)	ZONEPATH="$OPTARG" ;;
    41 		R)	zonepath="$OPTARG" ;;
    38 		z)	ZONENAME="$OPTARG" ;;
    42 		z)	zonename="$OPTARG" ;;
    39 		?)	fail_usage "" ;;
    43 		?)	fail_usage "" ;;
    40 		*)	fail_usage "";;
    44 		*)	fail_usage "";;
    41 	esac
    45 	esac
    42 done
    46 done
    43 shift $((OPTIND-1))
    47 shift $((OPTIND-1))
    44 
    48 
    45 init_zone zone "$ZONENAME" "$ZONEPATH"
    49 if [ $noexecute -eq 1 ]; then
    46 eval $(bind_legacy_zone_globals zone)
    50 	# dry-run - output zone's config and exit
    47 
    51 	cat /etc/zones/$zonename.xml
    48 if (( $noexecute == 1 )); then
       
    49 	cat /etc/zones/$ZONENAME.xml
       
    50 	exit $ZONE_SUBPROC_OK
    52 	exit $ZONE_SUBPROC_OK
    51 fi
    53 fi
    52 
    54 
    53 # All of the hard stuff is done in commmon code.
    55 #
    54 detach_zone zone
    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
    55 
    83 
    56 exit $ZONE_SUBPROC_OK
    84 exit $ZONE_SUBPROC_OK