diff options
-rwxr-xr-x | ezjail-admin | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/ezjail-admin b/ezjail-admin index be95450..11741b5 100755 --- a/ezjail-admin +++ b/ezjail-admin | |||
@@ -179,6 +179,7 @@ writejailinfo () { | |||
179 | echo export jail_${ezjail_safename}_zfs_datasets=\"${ezjail_zfs_datasets}\" | 179 | echo export jail_${ezjail_safename}_zfs_datasets=\"${ezjail_zfs_datasets}\" |
180 | echo export jail_${ezjail_safename}_cpuset=\"${ezjail_cpuset}\" | 180 | echo export jail_${ezjail_safename}_cpuset=\"${ezjail_cpuset}\" |
181 | echo export jail_${ezjail_safename}_fib=\"${ezjail_fib}\" | 181 | echo export jail_${ezjail_safename}_fib=\"${ezjail_fib}\" |
182 | echo export jail_${ezjail_safename}_parentzfs=\"${ezjail_parentzfs}\" | ||
182 | echo export jail_${ezjail_safename}_parameters=\"${ezjail_parameters}\" | 183 | echo export jail_${ezjail_safename}_parameters=\"${ezjail_parameters}\" |
183 | echo export jail_${ezjail_safename}_post_start_script=\"${ezjail_post_start_script}\" | 184 | echo export jail_${ezjail_safename}_post_start_script=\"${ezjail_post_start_script}\" |
184 | 185 | ||
@@ -228,9 +229,13 @@ fetchjailinfo () { | |||
228 | eval ezjail_zfs_datasets=\"\$jail_${ezjail_safename}_zfs_datasets\" | 229 | eval ezjail_zfs_datasets=\"\$jail_${ezjail_safename}_zfs_datasets\" |
229 | eval ezjail_cpuset=\"\$jail_${ezjail_safename}_cpuset\" | 230 | eval ezjail_cpuset=\"\$jail_${ezjail_safename}_cpuset\" |
230 | eval ezjail_fib=\"\$jail_${ezjail_safename}_fib\" | 231 | eval ezjail_fib=\"\$jail_${ezjail_safename}_fib\" |
232 | eval ezjail_parentzfs=\"\$jail_${ezjail_safename}_parentzfs\" | ||
231 | eval ezjail_parameters=\"\$jail_${ezjail_safename}_parameters\" | 233 | eval ezjail_parameters=\"\$jail_${ezjail_safename}_parameters\" |
232 | eval ezjail_post_start_script=\"\$jail_${ezjail_safename}_post_start_script\" | 234 | eval ezjail_post_start_script=\"\$jail_${ezjail_safename}_post_start_script\" |
233 | 235 | ||
236 | # Pre ezjail-3.3-jails do not have this set | ||
237 | : ${ezjail_parentzfs=${ezjail_jailzfs}} | ||
238 | |||
234 | ezjail_softlink=${ezjail_jaildir}/`basename -- "${ezjail_rootdir}"` | 239 | ezjail_softlink=${ezjail_jaildir}/`basename -- "${ezjail_rootdir}"` |
235 | ezjail_devicelink="${ezjail_rootdir}.device" | 240 | ezjail_devicelink="${ezjail_rootdir}.device" |
236 | 241 | ||
@@ -449,7 +454,7 @@ case "$1" in | |||
449 | ######################## ezjail-admin CREATE ######################## | 454 | ######################## ezjail-admin CREATE ######################## |
450 | create) | 455 | create) |
451 | # Clean variables, prevent pollution | 456 | # Clean variables, prevent pollution |
452 | 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 | 457 | unset ezjail_rootdir ezjail_flavours ezjail_softlink ezjail_image ezjail_imagetype ezjail_imageparams ezjail_imagesize ezjail_parentzfs ezjail_device ezjail_devicelink ezjail_config ezjail_attachparams ezjail_exists ezjail_attachblocking ezjail_forceblocking ezjail_sourcedevice ezjail_rootdirempty ezjail_fromarchive ezjail_fromarchive_config |
453 | shift; while getopts :f:r:s:xbic:C:a:A:z: arg; do case ${arg} in | 458 | shift; while getopts :f:r:s:xbic:C:a:A:z: arg; do case ${arg} in |
454 | x) ezjail_exists="YES";; | 459 | x) ezjail_exists="YES";; |
455 | r) ezjail_rootdir=${OPTARG};; | 460 | r) ezjail_rootdir=${OPTARG};; |
@@ -462,7 +467,7 @@ create) | |||
462 | i) : ${ezjail_imagetype="simple"};; | 467 | i) : ${ezjail_imagetype="simple"};; |
463 | s) ezjail_imagesize=${OPTARG};; | 468 | s) ezjail_imagesize=${OPTARG};; |
464 | z) ezjail_imagetype="zfs"; | 469 | z) ezjail_imagetype="zfs"; |
465 | ezjail_parentfs=${OPTARG};; | 470 | ezjail_parentzfs=${OPTARG};; |
466 | ?) exerr ${ezjail_usage_create};; | 471 | ?) exerr ${ezjail_usage_create};; |
467 | esac; done; shift $(( ${OPTIND} - 1 )) | 472 | esac; done; shift $(( ${OPTIND} - 1 )) |
468 | 473 | ||
@@ -620,16 +625,16 @@ create) | |||
620 | ezjail_device=${ezjail_imagedevice} | 625 | ezjail_device=${ezjail_imagedevice} |
621 | ;; | 626 | ;; |
622 | zfs) | 627 | zfs) |
623 | : ${ezjail_parentfs=${ezjail_jailzfs}} | 628 | : ${ezjail_parentzfs=${ezjail_jailzfs}} |
624 | if [ -z "${ezjail_exists}" ]; then | 629 | if [ -z "${ezjail_exists}" ]; then |
625 | [ "${ezjail_imagesize}" ] && ezjail_zfs_jail_properties="${ezjail_zfs_jail_properties} -o quota=${ezjail_imagesize}" | 630 | [ "${ezjail_imagesize}" ] && ezjail_zfs_jail_properties="${ezjail_zfs_jail_properties} -o quota=${ezjail_imagesize}" |
626 | [ -d "${ezjail_jaildir}/${ezjail_hostname}" ] && exerr "Error: Could not create jail root mount point ${ezjail_rootdir}" | 631 | [ -d "${ezjail_jaildir}/${ezjail_hostname}" ] && exerr "Error: Could not create jail root mount point ${ezjail_rootdir}" |
627 | 632 | ||
628 | check_for_zfs_exist "${ezjail_parentfs}" || exerr "Error: The parent zfs dataset does not exist.\n Use 'zfs create -p ${ezjail_parentfs}' to create it." | 633 | check_for_zfs_exist "${ezjail_parentzfs}" || exerr "Error: The parent zfs dataset does not exist.\n Use 'zfs create -p ${ezjail_parentzfs}' to create it." |
629 | 634 | ||
630 | /sbin/zfs create -o mountpoint=${ezjail_rootdir} ${ezjail_zfs_jail_properties} ${ezjail_parentfs}/${ezjail_hostname} | 635 | /sbin/zfs create -o mountpoint=${ezjail_rootdir} ${ezjail_zfs_jail_properties} ${ezjail_parentzfs}/${ezjail_hostname} |
631 | else | 636 | else |
632 | check_for_zfs_exist "${ezjail_parentfs}/${ezjail_hostname}" || exerr "Error: The existing destination is not a ZFS filesystem." | 637 | check_for_zfs_exist "${ezjail_parentzfs}/${ezjail_hostname}" || exerr "Error: The existing destination is not a ZFS filesystem." |
633 | fi | 638 | fi |
634 | ;; | 639 | ;; |
635 | 640 | ||
@@ -661,8 +666,8 @@ create) | |||
661 | if [ "${ezjail_imagetype}" = "zfs" -a "${ezjail_use_zfs}" = "YES" ]; then | 666 | if [ "${ezjail_imagetype}" = "zfs" -a "${ezjail_use_zfs}" = "YES" ]; then |
662 | # create ZFS filesystem first when using ZFS | 667 | # create ZFS filesystem first when using ZFS |
663 | /sbin/zfs snapshot ${ezjail_jailzfs}/newjail@_createnewjailtmp | 668 | /sbin/zfs snapshot ${ezjail_jailzfs}/newjail@_createnewjailtmp |
664 | /sbin/zfs send ${ezjail_jailzfs}/newjail@_createnewjailtmp | zfs receive -F ${ezjail_parentfs}/${ezjail_hostname} | 669 | /sbin/zfs send ${ezjail_jailzfs}/newjail@_createnewjailtmp | zfs receive -F ${ezjail_parentzfs}/${ezjail_hostname} |
665 | /sbin/zfs destroy ${ezjail_parentfs}/${ezjail_hostname}@_createnewjailtmp | 670 | /sbin/zfs destroy ${ezjail_parentzfs}/${ezjail_hostname}@_createnewjailtmp |
666 | /sbin/zfs destroy ${ezjail_jailzfs}/newjail@_createnewjailtmp | 671 | /sbin/zfs destroy ${ezjail_jailzfs}/newjail@_createnewjailtmp |
667 | else | 672 | else |
668 | 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 |
@@ -839,7 +844,7 @@ delete) | |||
839 | [ "${ezjail_image}" ] && rm -f "${ezjail_image}" "${ezjail_image%.img}.device" | 844 | [ "${ezjail_image}" ] && rm -f "${ezjail_image}" "${ezjail_image%.img}.device" |
840 | ;; | 845 | ;; |
841 | zfs) | 846 | zfs) |
842 | /sbin/zfs destroy -r ${ezjail_jailzfs}/${ezjail_hostname} | 847 | /sbin/zfs destroy -r ${ezjail_parentzfs}/${ezjail_hostname} |
843 | ;; | 848 | ;; |
844 | *) | 849 | *) |
845 | chflags -R noschg "${ezjail_rootdir}" | 850 | chflags -R noschg "${ezjail_rootdir}" |
@@ -1429,7 +1434,7 @@ config) | |||
1429 | fi | 1434 | fi |
1430 | 1435 | ||
1431 | # rename the filesystem, remounting is done by ZFS | 1436 | # rename the filesystem, remounting is done by ZFS |
1432 | [ "${ezjail_imagetype}" = "zfs" ] && /sbin/zfs rename ${ezjail_jailzfs}/${ezjail_old_hostname} ${ezjail_jailzfs}/${ezjail_hostname} && /sbin/zfs set mountpoint=${ezjail_rootdir} ${ezjail_jailzfs}/${ezjail_hostname} && rmdir ${ezjail_old_rootdir} | 1437 | [ "${ezjail_imagetype}" = "zfs" ] && /sbin/zfs rename ${ezjail_parentzfs}/${ezjail_old_hostname} ${ezjail_parentzfs}/${ezjail_hostname} && /sbin/zfs set mountpoint=${ezjail_rootdir} ${ezjail_parentzfs}/${ezjail_hostname} && rmdir ${ezjail_old_rootdir} |
1433 | 1438 | ||
1434 | # rename fstab | 1439 | # rename fstab |
1435 | rm -f "/etc/fstab.${ezjail_old_safename}" | 1440 | rm -f "/etc/fstab.${ezjail_old_safename}" |