[PC-BSD Commits] r20935 - pcbsd/current/src-sh/warden/scripts/backend
svn at pcbsd.org
svn at pcbsd.org
Fri Jan 11 07:22:20 PST 2013
Author: kris
Date: 2013-01-11 15:22:20 +0000 (Fri, 11 Jan 2013)
New Revision: 20935
Modified:
pcbsd/current/src-sh/warden/scripts/backend/functions.sh
Log:
Update the warden functions.sh, now should be able to do all ZFS related
functions on a non '/' mounted zpool
Needs a bit more testing to confirm it doesn't break anything before
we issue online update
Modified: pcbsd/current/src-sh/warden/scripts/backend/functions.sh
===================================================================
--- pcbsd/current/src-sh/warden/scripts/backend/functions.sh 2013-01-11 14:40:08 UTC (rev 20934)
+++ pcbsd/current/src-sh/warden/scripts/backend/functions.sh 2013-01-11 15:22:20 UTC (rev 20935)
@@ -206,14 +206,30 @@
if [ $? -ne 0 ] ; then printerror "Not a ZFS volume: ${1}" ; fi
tank=`getZFSTank "$1"`
zdate=`date +%Y-%m-%d-%H-%M-%S`
- zfs snapshot $tank${1}@$zdate
+ # Check the mount-point for this tank
+ zMnt=`getZFSMount "$tank"`
+ if [ zMnt = "/" ] ; then
+ zfs snapshot $tank${1}@$zdate
+ if [ $? -ne 0 ] ; then exit_err "Failed snapshot of dataset: $1"; fi
+ else
+ local tMnt=`echo ${1} | sed "s|^${zMnt}||g"`
+ zfs snapshot $tank${tMnt}@$zdate
+ if [ $? -ne 0 ] ; then exit_err "Failed snapshot of dataset: $1"; fi
+ fi
}
listZFSSnap() {
isDirZFS "${1}" "1"
if [ $? -ne 0 ] ; then printerror "Not a ZFS volume: ${1}" ; fi
tank=`getZFSTank "$1"`
- zfs list -t snapshot | grep -w "^${tank}${1}" | cut -d '@' -f 2 | awk '{print $1}'
+ # Check the mount-point for this tank
+ zMnt=`getZFSMount "$tank"`
+ if [ zMnt = "/" ] ; then
+ zfs list -t snapshot | grep -w "^${tank}${1}" | cut -d '@' -f 2 | awk '{print $1}'
+ else
+ local tMnt=`echo ${1} | sed "s|^${zMnt}||g"`
+ zfs list -t snapshot | grep -w "^${tank}${tMnt}" | cut -d '@' -f 2 | awk '{print $1}'
+ fi
}
listZFSClone() {
@@ -222,7 +238,14 @@
tank=`getZFSTank "$1"`
echo "Clone Directory: ${CDIR}"
echo "-----------------------------------"
- zfs list | grep -w "^${tank}${CDIR}/${2}" | awk '{print $5}' | sed "s|${CDIR}/${2}-||g"
+ # Check the mount-point for this tank
+ zMnt=`getZFSMount "$tank"`
+ if [ zMnt = "/" ] ; then
+ zfs list | grep -w "^${tank}${CDIR}/${2}" | awk '{print $5}' | sed "s|${CDIR}/${2}-||g"
+ else
+ local tMnt=`echo ${CDIR} | sed "s|^${zMnt}||g"`
+ zfs list | grep -w "^${tank}${tMnt}/${2}" | awk '{print $5}' | sed "s|${CDIR}/${2}-||g"
+ fi
}
rmZFSClone() {
@@ -230,23 +253,48 @@
isDirZFS "${CLONEDIR}" "1"
if [ $? -ne 0 ] ; then printerror "Not a ZFS volume: ${CLONEDIR}" ; fi
tank=`getZFSTank "$2"`
- zfs destroy ${tank}${CLONEDIR}
+ # Check the mount-point for this tank
+ zMnt=`getZFSMount "$tank"`
+ if [ zMnt = "/" ] ; then
+ zfs destroy ${tank}${CLONEDIR}
+ if [ $? -ne 0 ] ; then exit_err "Failed removing: $CLONEDIR"; fi
+ else
+ local tMnt=`echo ${CLONEDIR} | sed "s|^${zMnt}||g"`
+ zfs destroy ${tank}${tMnt}
+ if [ $? -ne 0 ] ; then exit_err "Failed removing: $CLONEDIR"; fi
+ fi
}
rmZFSSnap() {
isDirZFS "${1}" "1"
if [ $? -ne 0 ] ; then printerror "Not a ZFS volume: ${1}" ; fi
tank=`getZFSTank "$1"`
- zfs destroy $tank${1}@$2
+ # Check the mount-point for this tank
+ zMnt=`getZFSMount "$tank"`
+ if [ zMnt = "/" ] ; then
+ zfs destroy $tank${1}@$2
+ if [ $? -ne 0 ] ; then exit_err "Failed removing: ${1}@${2}"; fi
+ else
+ local tMnt=`echo ${1} | sed "s|^${zMnt}||g"`
+ zfs destroy $tank${tMnt}@$2
+ if [ $? -ne 0 ] ; then exit_err "Failed removing: ${tMnt}@${2}"; fi
+ fi
}
revertZFSSnap() {
isDirZFS "${1}" "1"
if [ $? -ne 0 ] ; then printerror "Not a ZFS volume: ${1}" ; fi
tank=`getZFSTank "$1"`
+ # Check the mount-point for this tank
+ zMnt=`getZFSMount "$tank"`
+ if [ zMnt = "/" ] ; then
+ local tMnt="${1}"
+ else
+ local tMnt=`echo ${1} | sed "s|^${zMnt}||g"`
+ fi
# Make sure this is a valid snapshot
- zfs list -t snapshot | grep -w "^${tank}${1}" | cut -d '@' -f 2 | awk '{print $1}' | grep -q ${2}
+ zfs list -t snapshot | grep -w "^${tank}${tMnt}" | cut -d '@' -f 2 | awk '{print $1}' | grep -q ${2}
if [ $? -ne 0 ] ; then printerror "Invalid ZFS snapshot!" ; fi
# Check if the jail is running first
@@ -262,7 +310,8 @@
fi
# Rollback the snapshot
- zfs rollback -R -f ${tank}${1}@$2
+ zfs rollback -R -f ${tank}${tMnt}@$2
+ if [ $? -ne 0 ] ; then exit_err "Failed rollback: ${tMnt}@${2}"; fi
# If it was started, restart the jail now
if [ "$restartJail" = "YES" ]; then
@@ -275,9 +324,18 @@
isDirZFS "${1}" "1"
if [ $? -ne 0 ] ; then printerror "Not a ZFS volume: ${1}" ; fi
tank=`getZFSTank "$1"`
+ # Check the mount-point for this tank
+ zMnt=`getZFSMount "$tank"`
+ if [ zMnt = "/" ] ; then
+ local tMnt="${1}"
+ local cMnt="${CDIR}"
+ else
+ local tMnt=`echo ${1} | sed "s|^${zMnt}||g"`
+ local cMnt=`echo ${CDIR} | sed "s|^${zMnt}||g"`
+ fi
# Make sure this is a valid snapshot
- zfs list -t snapshot | grep -w "^${tank}${1}" | cut -d '@' -f 2 | awk '{print $1}' | grep -q ${2}
+ zfs list -t snapshot | grep -w "^${tank}${tMnt}" | cut -d '@' -f 2 | awk '{print $1}' | grep -q ${2}
if [ $? -ne 0 ] ; then printerror "Invalid ZFS snapshot!" ; fi
if [ -d "${CDIR}/${3}-${2}" ] ; then
@@ -285,7 +343,7 @@
fi
# Clone the snapshot
- zfs clone -p ${tank}${1}@$2 ${tank}${CDIR}/${3}-${2}
+ zfs clone -p ${tank}${tMnt}@$2 ${tank}${cMnt}/${3}-${2}
echo "Snapshot cloned and mounted to: ${CDIR}/${3}-${2}"
}
More information about the Commits
mailing list