diff options
-rwxr-xr-x | ezjail-admin | 24 |
1 files changed, 18 insertions, 6 deletions
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 () { | |||
388 | [ "${_zpoolstatus}" = "ONLINE" -o "${_zpoolstatus}" = "DEGRADED" ] || exerr "Error: Your zpool does not exist or is not online." | 388 | [ "${_zpoolstatus}" = "ONLINE" -o "${_zpoolstatus}" = "DEGRADED" ] || exerr "Error: Your zpool does not exist or is not online." |
389 | } | 389 | } |
390 | 390 | ||
391 | check_for_zfs_exist () { | ||
392 | # check if the zfs we want to use already exists or not, return 0 if it does and 1 if not | ||
393 | _exit=1 | ||
394 | _zfs_status=`/sbin/zfs list -H -o name ${ezjail_jailzfs}/${ezjail_hostname} 2> /dev/null` | ||
395 | [ "${_zfs_status}" = "${ezjail_jailzfs}/${ezjail_hostname}" ] && _exit=0 | ||
396 | return ${_exit} | ||
397 | } | ||
398 | |||
391 | ############################# | 399 | ############################# |
392 | # End of function definitions | 400 | # End of function definitions |
393 | # | 401 | # |
@@ -561,13 +569,17 @@ create) | |||
561 | simple) | 569 | simple) |
562 | ezjail_device=${ezjail_imagedevice} | 570 | ezjail_device=${ezjail_imagedevice} |
563 | ;; | 571 | ;; |
564 | zfs) | 572 | zfs) |
565 | echo "ZFS: create the jail filesystem" | 573 | if [ -z "${ezjail_exists}" ]; then |
566 | if [ ${ezjail_imagesize} ]; then | 574 | echo "ZFS: create the jail filesystem" |
567 | ezjail_zfs_jail_properies="-o quota=${ezjail_imagesize} -o compression=lzjb" | 575 | if [ ${ezjail_imagesize} ]; then |
576 | ezjail_zfs_jail_properies="-o quota=${ezjail_imagesize} -o compression=lzjb" | ||
577 | fi | ||
578 | [ -d "${ezjail_jaildir}/${ezjail_hostname}" ] && exerr "Error: Could not create jail root mount point ${ezjail_rootdir}" | ||
579 | /sbin/zfs create -p -o mountpoint=${ezjail_rootdir} ${ezjail_zfs_jail_properies} ${ezjail_jailzfs}/${ezjail_hostname} | ||
580 | else | ||
581 | check_for_zfs_exist || exerr "Error: The existing destination is not a ZFS filesystem." | ||
568 | fi | 582 | fi |
569 | [ -d "${ezjail_jaildir}/${ezjail_hostname}" ] && exerr "Error: Could not create jail root mount point ${ezjail_rootdir}" | ||
570 | /sbin/zfs create -p -o mountpoint=${ezjail_rootdir} ${ezjail_zfs_jail_properies} ${ezjail_jailzfs}/${ezjail_hostname} | ||
571 | ;; | 583 | ;; |
572 | 584 | ||
573 | esac | 585 | esac |