diff options
author | erdgeist <erdgeist@erdgeist.org> | 2013-04-10 21:42:56 +0000 |
---|---|---|
committer | erdgeist <erdgeist@erdgeist.org> | 2013-04-10 21:42:56 +0000 |
commit | 31feb69b9c64a66433d1fd0e28283ceef05b8978 (patch) | |
tree | dc86308799901cb489cd2cd29fc3e7f3f913a37c /ezjail-admin | |
parent | 8313cd36ec7db8dcdb44c0dcca295a20d66c149b (diff) |
Allow user to specify another parent zfs or zpool for a new jail. This also implies -c zfs. Thanks to Cryx.
Diffstat (limited to 'ezjail-admin')
-rwxr-xr-x | ezjail-admin | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/ezjail-admin b/ezjail-admin index 82eac3d..a5f719a 100755 --- a/ezjail-admin +++ b/ezjail-admin | |||
@@ -418,8 +418,8 @@ check_for_zpool () { | |||
418 | check_for_zfs_exist () { | 418 | check_for_zfs_exist () { |
419 | # check if the zfs we want to use already exists or not, return 0 if it does and 1 if not | 419 | # check if the zfs we want to use already exists or not, return 0 if it does and 1 if not |
420 | _exit=1 | 420 | _exit=1 |
421 | _zfs_status=`/sbin/zfs list -H -o name ${ezjail_jailzfs}/${ezjail_hostname} 2> /dev/null` | 421 | _zfs_status=`/sbin/zfs list -H -o name ${ezjail_parentfs}/${ezjail_hostname} 2> /dev/null` |
422 | [ "${_zfs_status}" = "${ezjail_jailzfs}/${ezjail_hostname}" ] && _exit=0 | 422 | [ "${_zfs_status}" = "${ezjail_parentfs}/${ezjail_hostname}" ] && _exit=0 |
423 | return ${_exit} | 423 | return ${_exit} |
424 | } | 424 | } |
425 | 425 | ||
@@ -456,7 +456,7 @@ case "$1" in | |||
456 | ######################## ezjail-admin CREATE ######################## | 456 | ######################## ezjail-admin CREATE ######################## |
457 | create) | 457 | create) |
458 | # Clean variables, prevent pollution | 458 | # Clean variables, prevent pollution |
459 | unset ezjail_rootdir ezjail_flavours ezjail_softlink ezjail_image ezjail_imagetype ezjail_imageparams ezjail_imagesize ezjail_device ezjail_devicelink ezjail_config ezjail_attachparams ezjail_exists ezjail_attachblocking ezjail_forceblocking ezjail_sourcedevice ezjail_rootdirempty ezjail_fromarchive ezjail_fromarchive_config | 459 | unset ezjail_rootdir ezjail_flavours ezjail_softlink ezjail_image ezjail_imagetype ezjail_imageparams ezjail_imagesize ezjail_parentfs ezjail_device ezjail_devicelink ezjail_config ezjail_attachparams ezjail_exists ezjail_attachblocking ezjail_forceblocking ezjail_sourcedevice ezjail_rootdirempty ezjail_fromarchive ezjail_fromarchive_config |
460 | shift; while getopts :f:r:s:xbic:C:a:A: arg; do case ${arg} in | 460 | shift; while getopts :f:r:s:xbic:C:a:A: arg; do case ${arg} in |
461 | x) ezjail_exists="YES";; | 461 | x) ezjail_exists="YES";; |
462 | r) ezjail_rootdir=${OPTARG};; | 462 | r) ezjail_rootdir=${OPTARG};; |
@@ -468,6 +468,8 @@ create) | |||
468 | b) ezjail_forceblocking="YES";; | 468 | b) ezjail_forceblocking="YES";; |
469 | i) : ${ezjail_imagetype="simple"};; | 469 | i) : ${ezjail_imagetype="simple"};; |
470 | s) ezjail_imagesize=${OPTARG};; | 470 | s) ezjail_imagesize=${OPTARG};; |
471 | z) ezjail_imagetype="zfs"; | ||
472 | ezjail_parentfs=${OPTARG};; | ||
471 | ?) exerr ${ezjail_usage_create};; | 473 | ?) exerr ${ezjail_usage_create};; |
472 | esac; done; shift $(( ${OPTIND} - 1 )) | 474 | esac; done; shift $(( ${OPTIND} - 1 )) |
473 | 475 | ||
@@ -625,11 +627,12 @@ create) | |||
625 | ezjail_device=${ezjail_imagedevice} | 627 | ezjail_device=${ezjail_imagedevice} |
626 | ;; | 628 | ;; |
627 | zfs) | 629 | zfs) |
630 | ${ezjail_parentfs=${ezjail_jailzfs}} | ||
628 | if [ -z "${ezjail_exists}" ]; then | 631 | if [ -z "${ezjail_exists}" ]; then |
629 | [ "${ezjail_imagesize}" ] && ezjail_zfs_jail_properties="${ezjail_zfs_jail_properties} -o quota=${ezjail_imagesize}" | 632 | [ "${ezjail_imagesize}" ] && ezjail_zfs_jail_properties="${ezjail_zfs_jail_properties} -o quota=${ezjail_imagesize}" |
630 | [ -d "${ezjail_jaildir}/${ezjail_hostname}" ] && exerr "Error: Could not create jail root mount point ${ezjail_rootdir}" | 633 | [ -d "${ezjail_jaildir}/${ezjail_hostname}" ] && exerr "Error: Could not create jail root mount point ${ezjail_rootdir}" |
631 | 634 | ||
632 | /sbin/zfs create -o mountpoint=${ezjail_rootdir} ${ezjail_zfs_jail_properties} ${ezjail_jailzfs}/${ezjail_hostname} | 635 | /sbin/zfs create -o mountpoint=${ezjail_rootdir} ${ezjail_zfs_jail_properties} ${ezjail_parentfs}/${ezjail_hostname} |
633 | else | 636 | else |
634 | check_for_zfs_exist || exerr "Error: The existing destination is not a ZFS filesystem." | 637 | check_for_zfs_exist || exerr "Error: The existing destination is not a ZFS filesystem." |
635 | fi | 638 | fi |
@@ -663,8 +666,8 @@ create) | |||
663 | if [ "${ezjail_imagetype}" = "zfs" -a "${ezjail_use_zfs}" = "YES" ]; then | 666 | if [ "${ezjail_imagetype}" = "zfs" -a "${ezjail_use_zfs}" = "YES" ]; then |
664 | # create ZFS filesystem first when using ZFS | 667 | # create ZFS filesystem first when using ZFS |
665 | /sbin/zfs snapshot ${ezjail_jailzfs}/newjail@_createnewjailtmp | 668 | /sbin/zfs snapshot ${ezjail_jailzfs}/newjail@_createnewjailtmp |
666 | /sbin/zfs send ${ezjail_jailzfs}/newjail@_createnewjailtmp | zfs receive -F ${ezjail_jailzfs}/${ezjail_hostname} | 669 | /sbin/zfs send ${ezjail_jailzfs}/newjail@_createnewjailtmp | zfs receive -F ${ezjail_parentfs}/${ezjail_hostname} |
667 | /sbin/zfs destroy ${ezjail_jailzfs}/${ezjail_hostname}@_createnewjailtmp | 670 | /sbin/zfs destroy ${ezjail_parentfs}/${ezjail_hostname}@_createnewjailtmp |
668 | /sbin/zfs destroy ${ezjail_jailzfs}/newjail@_createnewjailtmp | 671 | /sbin/zfs destroy ${ezjail_jailzfs}/newjail@_createnewjailtmp |
669 | else | 672 | else |
670 | mkdir -p "${ezjail_rootdir}" && cd "${ezjail_jailtemplate}" && find . | cpio -p -v "${ezjail_rootdir}" > /dev/null | 673 | mkdir -p "${ezjail_rootdir}" && cd "${ezjail_jailtemplate}" && find . | cpio -p -v "${ezjail_rootdir}" > /dev/null |