[PC-BSD Commits] r20922 - pcbsd/current/src-sh/warden/scripts/backend

svn at pcbsd.org svn at pcbsd.org
Thu Jan 10 09:07:20 PST 2013


Author: kris
Date: 2013-01-10 17:07:20 +0000 (Thu, 10 Jan 2013)
New Revision: 20922

Modified:
   pcbsd/current/src-sh/warden/scripts/backend/createjail.sh
   pcbsd/current/src-sh/warden/scripts/backend/functions.sh
Log:

Add some new code to handle two situations.

1. If the user has multiple ZPOOLS on the system, and is trying to use
   jails on another one of them

2. If the user is running on a ZPOOL which is NOT mounted to "/"



Modified: pcbsd/current/src-sh/warden/scripts/backend/createjail.sh
===================================================================
--- pcbsd/current/src-sh/warden/scripts/backend/createjail.sh	2013-01-10 16:54:48 UTC (rev 20921)
+++ pcbsd/current/src-sh/warden/scripts/backend/createjail.sh	2013-01-10 17:07:20 UTC (rev 20922)
@@ -126,7 +126,16 @@
    if [ $? -eq 0 ] ; then
      # Create ZFS mount
      tank=`getZFSTank "$JDIR"`
-     zfs create -o mountpoint=${JAILDIR} -p ${tank}${JAILDIR}
+     # Check the mount-point for this tank
+     zMnt=`getZFSMount "$tank"`
+     if [ zMnt = "/" ] ; then
+        zfs create -o mountpoint=${JAILDIR} -p ${tank}${JAILDIR}
+        if [ $? -ne 0 ] ; then exit_err "Failed creating ZFS dataset"; fi
+     else
+        tMnt=`echo $JAILDIR | sed "s|^${zMnt}||g"`
+        zfs create -o mountpoint=${JAILDIR} -p ${tank}${tMnt}
+        if [ $? -ne 0 ] ; then exit_err "Failed creating ZFS dataset"; fi
+     fi
    else
      mkdir -p "${JAILDIR}"
    fi
@@ -140,8 +149,17 @@
 if [ $? -eq 0 ] ; then
    # Create ZFS CLONE
    tank=`getZFSTank "$JDIR"`
-   zfs clone ${tank}${WORLDCHROOT}@clean ${tank}${JAILDIR}
-   if [ $? -ne 0 ] ; then exit_err "Failed creating clean ZFS base clone"; fi
+   # Check the mount-point for this tank
+   zMnt=`getZFSMount "$tank"`
+   if [ zMnt = "/" ] ; then
+      zfs clone ${tank}${WORLDCHROOT}@clean ${tank}${JAILDIR}
+      if [ $? -ne 0 ] ; then exit_err "Failed creating clean ZFS base clone"; fi
+    else
+      tMnt=`echo $JAILDIR | sed "s|^${zMnt}||g"`
+      crDir=`echo $WORLDCHROOT | sed "s|^${zMnt}||g"`
+      zfs clone ${tank}${crDir}@clean ${tank}${tMnt}
+      if [ $? -ne 0 ] ; then exit_err "Failed creating clean ZFS base clone"; fi
+    fi
 else
    # Running on UFS
    mkdir -p "${JAILDIR}"

Modified: pcbsd/current/src-sh/warden/scripts/backend/functions.sh
===================================================================
--- pcbsd/current/src-sh/warden/scripts/backend/functions.sh	2013-01-10 16:54:48 UTC (rev 20921)
+++ pcbsd/current/src-sh/warden/scripts/backend/functions.sh	2013-01-10 17:07:20 UTC (rev 20922)
@@ -82,14 +82,23 @@
     tank=`getZFSTank "$JDIR"`
     isDirZFS "${WORLDCHROOT}" "1"
     if [ $? -ne 0 ] ; then
-       zfs create -o mountpoint=${WORLDCHROOT} -p ${tank}${WORLDCHROOT}
-       if [ $? -ne 0 ] ; then exit_err "Failed creating ZFS base dataset"; fi
+       # Check the mount-point for this tank
+       zMnt=`getZFSMount "$tank"`
+       if [ zMnt = "/" ] ; then
+	 local tMnt="$WORLDCHROOT"
+         zfs create -o mountpoint=${WORLDCHROOT} -p ${tank}${WORLDCHROOT}
+         if [ $? -ne 0 ] ; then exit_err "Failed creating ZFS base dataset"; fi
+       else
+	 local tMnt=`echo $WORLDCHROOT | sed "s|^${zMnt}||g"` 
+         zfs create -o mountpoint=${WORLDCHROOT} -p ${tank}${tMnt}
+         if [ $? -ne 0 ] ; then exit_err "Failed creating ZFS base dataset"; fi
+       fi
     fi
 
     tar xvpf ${FBSD_TARBALL} -C ${WORLDCHROOT} 2>/dev/null
     if [ $? -ne 0 ] ; then exit_err "Failed extracting ZFS chroot environment"; fi
 
-    zfs snapshot ${tank}${WORLDCHROOT}@clean
+    zfs snapshot ${tank}${tMnt}@clean
     if [ $? -ne 0 ] ; then exit_err "Failed creating clean ZFS base snapshot"; fi
     rm ${FBSD_TARBALL}
   else



More information about the Commits mailing list