[PC-BSD Commits] r21874 - in pcbsd/current/src-sh: libsh warden/scripts/backend

svn at pcbsd.org svn at pcbsd.org
Fri Mar 15 01:49:11 PDT 2013


Author: kris
Date: 2013-03-15 08:49:10 +0000 (Fri, 15 Mar 2013)
New Revision: 21874

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

Extend some ZFS functionality in our functions, and while here fix a bug
in warden. Don't try to make a ZFS dataset if JAILDIR: isn't set to a
ZFS dataset, will fallback to the old style of creating the jails. 



Modified: pcbsd/current/src-sh/libsh/functions.sh
===================================================================
--- pcbsd/current/src-sh/libsh/functions.sh	2013-03-15 06:37:00 UTC (rev 21873)
+++ pcbsd/current/src-sh/libsh/functions.sh	2013-03-15 08:49:10 UTC (rev 21874)
@@ -305,6 +305,11 @@
   do
      # Is this dir a ZFS mount
      mount | grep -w "on $_chkDir " | grep -qw "(zfs," && return 0
+
+     # If this directory is mounted, but NOT ZFS
+     if [ "$2" != "1" ] ; then
+       mount | grep -qw "on $_chkDir " && return 1
+     fi
       
      # Quit if not walking down
      if [ "$2" = "1" ] ; then return 1 ; fi
@@ -330,12 +335,18 @@
 
 # Get the ZFS dataset of a particular directory
 getZFSDataset() {
-  local mount="$1"
-  local zData=`mount | grep " on $mount " | grep "(zfs," | awk '{print $1}'`
-  if [ -n "$zData" ] ; then
-     echo "$zData"
-     return 0
-  fi
+  local _chkDir="$1"
+  while :
+  do
+    local zData=`mount | grep " on ${_chkDir} " | grep "(zfs," | awk '{print $1}'`
+    if [ -n "$zData" ] ; then
+       echo "$zData"
+       return 0
+    fi
+    if [ "$2" != "rec" ] ; then return 1 ; fi
+    if [ "$_chkDir" = "/" ] ; then return 1 ; fi
+    _chkDir=`dirname $_chkDir`
+  done
   return 1
 }
 

Modified: pcbsd/current/src-sh/warden/scripts/backend/createjail.sh
===================================================================
--- pcbsd/current/src-sh/warden/scripts/backend/createjail.sh	2013-03-15 06:37:00 UTC (rev 21873)
+++ pcbsd/current/src-sh/warden/scripts/backend/createjail.sh	2013-03-15 08:49:10 UTC (rev 21874)
@@ -117,7 +117,7 @@
 
 # If we are setting up a linux jail, lets do it now
 if [ "$LINUXJAIL" = "YES" ] ; then
-   isDirZFS "${JDIR}"
+   isDirZFS "${JDIR}" "1"
    if [ $? -eq 0 ] ; then
      # Create ZFS mount
      zData=`getZFSDataset "$JDIR"`
@@ -135,7 +135,7 @@
 
 echo "Building new Jail... Please wait..."
 
-isDirZFS "${JDIR}"
+isDirZFS "${JDIR}" "1"
 if [ $? -eq 0 ] ; then
    # Create ZFS CLONE
    zData=`getZFSDataset "$JDIR"`

Modified: pcbsd/current/src-sh/warden/scripts/backend/functions.sh
===================================================================
--- pcbsd/current/src-sh/warden/scripts/backend/functions.sh	2013-03-15 06:37:00 UTC (rev 21873)
+++ pcbsd/current/src-sh/warden/scripts/backend/functions.sh	2013-03-15 08:49:10 UTC (rev 21874)
@@ -56,19 +56,13 @@
      dFiles="$dFiles lib32.txz"
   fi
 
-  # Set the mirror URL, may be overridden by setting MIRRORURL environment variable
-  if [ -z "${MIRRORURL}" ]; then
-    get_mirror
-    MIRRORURL="$VAL"
-  fi
-
   if [ ! -d "${JDIR}" ] ; then mkdir -p "${JDIR}" ; fi
   cd ${JDIR}
 
   echo "Fetching jail environment. This may take a while..."
   for i in $dFiles
   do
-    echo "Downloading ${MIRRORURL}/${SYSVER}/${ARCH}/dist/${i} ..."
+    echo "Downloading ${SYSVER}/${ARCH}/dist/${i} ..."
 
     get_file_from_mirrors "/${SYSVER}/${ARCH}/dist/${i}" "$i"
     [ $? -ne 0 ] && printerror "Error while downloading the freebsd world."
@@ -80,10 +74,9 @@
   if [ $? -eq 0 ] ; then
     # Use ZFS base for cloning
     echo "Creating ZFS ${WORLDCHROOT} dataset..."
-    tank=`getZFSTank "$JDIR"`
     isDirZFS "${WORLDCHROOT}" "1"
     if [ $? -ne 0 ] ; then
-       # Check the mount-point for this tank
+       # Check the mount-point for this zfs dataset
        zData=`getZFSDataset "$JDIR"`
        if [ -z "$zData" ] ; then 
           exit_err "Failed getting ZFS dataset for $JDIR.."; 
@@ -104,7 +97,7 @@
   done
 
   # Create ZFS clean snapshot
-  isDirZFS "${JDIR}"
+  isDirZFS "${JDIR}" "1"
   if [ $? -eq 0 ] ; then
     zfs snapshot ${zData}/`basename $WORLDCHROOT`@clean
     if [ $? -ne 0 ] ; then exit_err "Failed creating clean ZFS base snapshot"; fi



More information about the Commits mailing list