diff options
author | Josh Wilsdon <jwilsdon@joyent.com> | 2013-05-03 04:36:38 +0000 |
---|---|---|
committer | Josh Wilsdon <jwilsdon@joyent.com> | 2013-05-03 09:15:18 +0000 |
commit | 7bfcac593b37bd0b081e7190a4429e7cae0bfc22 (patch) | |
tree | 47f244c10c890b79d3fecfed41e2b0c385f1fafc /usr/src | |
parent | 21a6b03bbd82147f869197594e8b3ea8a7600eb1 (diff) | |
download | illumos-joyent-7bfcac593b37bd0b081e7190a4429e7cae0bfc22.tar.gz |
OS-2154 sngl brand should clone from @final when it exists.
Diffstat (limited to 'usr/src')
-rw-r--r-- | usr/src/lib/brand/sngl/zone/sinstall.sh | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/usr/src/lib/brand/sngl/zone/sinstall.sh b/usr/src/lib/brand/sngl/zone/sinstall.sh index 70b02a06c5..d0633a7525 100644 --- a/usr/src/lib/brand/sngl/zone/sinstall.sh +++ b/usr/src/lib/brand/sngl/zone/sinstall.sh @@ -53,9 +53,9 @@ shift OPTIND-1 if [[ -n $(zonecfg -z "${ZONENAME}" info attr name=transition \ | grep "value: receiving:") ]]; then - # Here we're doing an install for a received zone, the dataset should have - # already been created. - exit $ZONE_SUBPROC_OK + # Here we're doing an install for a received zone, the dataset should have + # already been created. + exit $ZONE_SUBPROC_OK fi if [[ -z $ZONEPATH || -z $ZONENAME ]]; then @@ -89,16 +89,28 @@ PDS_NAME=`mount | nawk -v p=$dname '{if ($1 == p) print $3}'` QUOTA_ARG= if [[ ${ZQUOTA} != "0" ]]; then - QUOTA_ARG="-o quota=${ZQUOTA}g" + QUOTA_ARG="-o quota=${ZQUOTA}g" fi -zfs snapshot $PDS_NAME/${TMPLZONE}@${bname} -zfs clone -F ${QUOTA_ARG} $PDS_NAME/${TMPLZONE}@${bname} \ - $PDS_NAME/$bname || fatal "failed to clone zone dataset" +# New imgadm renames the dataset's snapshot at import to @final for us +# and when it exists, we use that. However, when it does not exist we +# still use the old method of creating a zones/<uuid>@<uuid> snapshot +# so we can support old datasets. +exists=$(zfs list -Ho name ${PDS_NAME}/${TMPLZONE}@final 2>&1) +if [[ $? == 0 && ${exists} == "${PDS_NAME}/${TMPLZONE}@final" ]]; then + zfs clone -F ${QUOTA_ARG} ${PDS_NAME}/${TMPLZONE}@final \ + ${PDS_NAME}/${bname} || fatal "failed to clone zone dataset" +elif [[ ${exists} =~ "dataset does not exist" ]]; then + zfs snapshot ${PDS_NAME}/${TMPLZONE}@${bname} + zfs clone -F ${QUOTA_ARG} ${PDS_NAME}/${TMPLZONE}@${bname} \ + ${PDS_NAME}/${bname} || fatal "failed to clone zone dataset" +else + fatal "Unable to determine snapshot for ${PDS_NAME}/${TMPLZONE}" +fi if [ ! -d ${ZONEPATH}/config ]; then - mkdir -p ${ZONEPATH}/config - chmod 755 ${ZONEPATH}/config + mkdir -p ${ZONEPATH}/config + chmod 755 ${ZONEPATH}/config fi final_setup |