From cc6ceaad9bb3ef70f231ad09ab857a0e79eb302f Mon Sep 17 00:00:00 2001 From: cryx Date: Fri, 15 Jan 2010 13:38:23 +0000 Subject: Respect the -x option when creating a ZFS backed jail, do a check if the destinatiuon really is ZFS filesystem! --- ezjail-admin | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'ezjail-admin') diff --git a/ezjail-admin b/ezjail-admin index 585823a..557ae9e 100755 --- a/ezjail-admin +++ b/ezjail-admin @@ -388,6 +388,14 @@ check_for_zpool () { [ "${_zpoolstatus}" = "ONLINE" -o "${_zpoolstatus}" = "DEGRADED" ] || exerr "Error: Your zpool does not exist or is not online." } +check_for_zfs_exist () { + # check if the zfs we want to use already exists or not, return 0 if it does and 1 if not + _exit=1 + _zfs_status=`/sbin/zfs list -H -o name ${ezjail_jailzfs}/${ezjail_hostname} 2> /dev/null` + [ "${_zfs_status}" = "${ezjail_jailzfs}/${ezjail_hostname}" ] && _exit=0 + return ${_exit} +} + ############################# # End of function definitions # @@ -561,13 +569,17 @@ create) simple) ezjail_device=${ezjail_imagedevice} ;; - zfs) - echo "ZFS: create the jail filesystem" - if [ ${ezjail_imagesize} ]; then - ezjail_zfs_jail_properies="-o quota=${ezjail_imagesize} -o compression=lzjb" + zfs) + if [ -z "${ezjail_exists}" ]; then + echo "ZFS: create the jail filesystem" + if [ ${ezjail_imagesize} ]; then + ezjail_zfs_jail_properies="-o quota=${ezjail_imagesize} -o compression=lzjb" + fi + [ -d "${ezjail_jaildir}/${ezjail_hostname}" ] && exerr "Error: Could not create jail root mount point ${ezjail_rootdir}" + /sbin/zfs create -p -o mountpoint=${ezjail_rootdir} ${ezjail_zfs_jail_properies} ${ezjail_jailzfs}/${ezjail_hostname} + else + check_for_zfs_exist || exerr "Error: The existing destination is not a ZFS filesystem." fi - [ -d "${ezjail_jaildir}/${ezjail_hostname}" ] && exerr "Error: Could not create jail root mount point ${ezjail_rootdir}" - /sbin/zfs create -p -o mountpoint=${ezjail_rootdir} ${ezjail_zfs_jail_properies} ${ezjail_jailzfs}/${ezjail_hostname} ;; esac -- cgit v1.2.3