Mercurial > hgrepos > FreeBSD > ports > sysutils > local-bsdtools
changeset 235:85aea8ca1ab8
Some work on datasets-tmpl
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Thu, 08 Sep 2022 09:43:31 +0200 |
| parents | 8682cfa74f6a |
| children | 661e35a9d6e5 |
| files | sbin/ftjail |
| diffstat | 1 files changed, 30 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/sbin/ftjail Tue Sep 06 09:40:05 2022 +0200 +++ b/sbin/ftjail Thu Sep 08 09:43:31 2022 +0200 @@ -28,10 +28,10 @@ COMMANDS: - datasets [OPTIONS] PARENT-BASE PARENT-SKELETON NAME + datasets-tmpl [OPTIONS] PARENT-BASE PARENT-SKELETON NAME - Create ZFS datasets for the ro base and the rw skeleton to be used - within for jails + Create the ZFS template datasets, i.e. the ro base and the rw + skeleton to be used within thin jails jails PARENT-BASE and PARENT-SKELETON must exist already and NAME must not exist. @@ -75,16 +75,17 @@ # -# "datasets" -- create the ZFS dataset tree +# "datasets-tmpl" -- create the ZFS dataset tree # # PARENT-BASE PARENT-SKELETON NAME # -command_datasets() { +command_datasets_tmpl() { # parent ZFS dataset -- child ZFS dataset name local _p_base _p_skel _name local _zfsopts + local _ds_base _ds_skel - _zfsopts="-u" + _zfsopts="-u -o canmount=noauto" _p_base="$1" _p_skel="$2" @@ -98,17 +99,33 @@ echo "ERROR: no parent dataset for skeleton given" >&2 return 2 fi - if [ -z "${_pname}" ]; then + if [ -z "${_name}" ]; then echo "ERROR: no name given" >&2 return 2 fi - _ds="${_pds}/${_cds}" - echo "Resulting new root dataset is \`${_ds}' at mountpoint \`${_pmp}/${_cds}'" - if zfs list -H -o mountpoint -t filesystem "${_ds}" >/dev/null 2>/dev/null; then - echo "ERROR: dataset \`${_ds}' does already exist" >&2 + _ds_base="${_p_base}/${_name}" + _ds_skel="${_p_skel}/${_name}" + echo "Resulting new root datasets:" + printf "\\t%s\\n" "${_ds_base}" + printf "\\t%s\\n" "${_ds_skel}" + if ! zfs list -H -o mountpoint -t filesystem "${_p_base}" >/dev/null 2>/dev/null; then + echo "ERROR: parent dataset \`${_p_base}' does not exist" >&2 return 1 fi + if zfs list -H -o mountpoint -t filesystem "${_ds_base}" >/dev/null 2>/dev/null; then + echo "ERROR: dataset \`${_ds_base}' does already exist" >&2 + return 1 + fi + if ! zfs list -H -o mountpoint -t filesystem "${_p_skel}" >/dev/null 2>/dev/null; then + echo "ERROR: parent dataset \`${_p_skel}' does not exist" >&2 + return 1 + fi + if zfs list -H -o mountpoint -t filesystem "${_ds_skel}" >/dev/null 2>/dev/null; then + echo "ERROR: dataset \`${_ds_skel}' does already exist" >&2 + return 1 + fi + return 0 # # NOTE: For BEs these directory will be *excluded* from the BE @@ -406,8 +423,8 @@ shift case "${command}" in - datasets) - command_datasets "$@" + datasets-tmpl) + command_datasets_tmpl "$@" ;; populate) command_populate "$@"
