comparison sbin/ftjail @ 270:dde5967d1e43

Implement the "-M" (custom mountpoint) option for "copy-skel"
author Franz Glasner <fzglas.hg@dom66.de>
date Wed, 14 Sep 2022 09:24:27 +0200
parents 68f091c9524a
children 570363928b13
comparison
equal deleted inserted replaced
269:f1278babb7a5 270:dde5967d1e43
74 copy-skel [ OPTIONS ] SOURCE-DS SNAPSHOT-NAME TARGET-DS 74 copy-skel [ OPTIONS ] SOURCE-DS SNAPSHOT-NAME TARGET-DS
75 75
76 -A Set "canmount=noauto" for all datasets in the target dataset 76 -A Set "canmount=noauto" for all datasets in the target dataset
77 -L Copy dataset properties optimized for employing a 77 -L Copy dataset properties optimized for employing a
78 "skeleton" subdirectory 78 "skeleton" subdirectory
79 -M MOUNTPOINT Set the "mountpoint" property for the TARGET-DS to
80 MOUNTPOINT (children will inherit it)
79 -P Copy dataset properties optimized for direct mounts 81 -P Copy dataset properties optimized for direct mounts
80 of skeleton children over an already mounted base 82 of skeleton children over an already mounted base
81 -u Do not mount the target dataset automatically 83 -u Do not mount the target dataset automatically
82 84
83 ENVIRONMENT: 85 ENVIRONMENT:
705 #: 707 #:
706 #: Implementation of "copy-skel" 708 #: Implementation of "copy-skel"
707 #: 709 #:
708 command_copy_skel() { 710 command_copy_skel() {
709 local _ds_source _snapshot_name _ds_target 711 local _ds_source _snapshot_name _ds_target
710 local _opt_symlink _opt_nomount 712 local _opt_symlink _opt_nomount _opt_canmount _opt_mountpoint
711 713
712 local _opt _name _relative_name _opt_canmount 714 local _opt _name _relative_name _root_canmount
713 715
714 _opt_symlink="" 716 _opt_symlink=""
715 _opt_nomount="" 717 _opt_nomount=""
716 _opt_canmount="-o canmount=on" 718 _opt_canmount="-o canmount=on"
717 719 _opt_mountpoint=""
718 720
719 while getopts "ALPu" _opt ; do 721 while getopts "ALM:Pu" _opt ; do
720 case ${_opt} in 722 case ${_opt} in
721 A) 723 A)
722 _opt_canmount="-o canmount=noauto" 724 _opt_canmount="-o canmount=noauto"
723 ;; 725 ;;
724 L) 726 L)
725 _opt_symlink="yes" 727 _opt_symlink="yes"
728 ;;
729 M)
730 _opt_mountpoint="${OPTARG}"
726 ;; 731 ;;
727 P) 732 P)
728 _opt_symlink="no" 733 _opt_symlink="no"
729 ;; 734 ;;
730 u) 735 u)
758 _relative_name="${_relative_name%@*}" 763 _relative_name="${_relative_name%@*}"
759 echo " -> $_relative_name" 764 echo " -> $_relative_name"
760 if [ -z "${_relative_name}" ]; then 765 if [ -z "${_relative_name}" ]; then
761 # root 766 # root
762 if [ "${_opt_symlink}" = "yes" ]; then 767 if [ "${_opt_symlink}" = "yes" ]; then
763 zfs send -Lec -p -v "${_name}" | zfs receive ${_opt_nomount} -v ${_opt_canmount} -x mountpoint "${_ds_target}${_relative_name}" 768 _root_canmount="${_opt_canmount}"
764 else 769 else
765 zfs send -Lec -p -v "${_name}" | zfs receive ${_opt_nomount} -v -o canmount=off -x mountpoint "${_ds_target}${_relative_name}" 770 _root_canmount="-o canmount=off"
771 fi
772 if [ -n "${_opt_mountpoint}" ]; then
773 zfs send -Lec -p -v "${_name}" | zfs receive ${_opt_nomount} -v ${_root_canmount} -o "mountpoint=${_opt_mountpoint}" "${_ds_target}${_relative_name}"
774 else
775 zfs send -Lec -p -v "${_name}" | zfs receive ${_opt_nomount} -v ${_root_canmount} -x mountpoint "${_ds_target}${_relative_name}"
766 fi 776 fi
767 else 777 else
768 # child 778 # child
769 if [ "${_relative_name}" = "/usr" ]; then 779 if [ "${_relative_name}" = "/usr" ]; then
770 zfs send -Lec -p -v "${_name}" | zfs receive ${_opt_nomount} -v -o canmount=off -x mountpoint "${_ds_target}${_relative_name}" 780 zfs send -Lec -p -v "${_name}" | zfs receive ${_opt_nomount} -v -o canmount=off -x mountpoint "${_ds_target}${_relative_name}"