comparison sbin/ftjail @ 248:0b5dbf394aa2

FIX: echo 2>&1 is not intended: use 1>&2 instead
author Franz Glasner <fzglas.hg@dom66.de>
date Sun, 11 Sep 2022 10:57:00 +0200
parents 5dd38cb3fecf
children a91e1c5173cc
comparison
equal deleted inserted replaced
247:5dd38cb3fecf 248:0b5dbf394aa2
79 _ensure_no_options() { 79 _ensure_no_options() {
80 local _opt 80 local _opt
81 81
82 while getopts ":" _opt ; do 82 while getopts ":" _opt ; do
83 [ "${_opt}" = '?' ] && { echo "ERROR: no option allowed" 1>&2; exit 2; } 83 [ "${_opt}" = '?' ] && { echo "ERROR: no option allowed" 1>&2; exit 2; }
84 done 84 done
85 } 85 }
86 86
87 87
88 _get_dataset_for_mountpoint() { 88 _get_dataset_for_mountpoint() {
89 : 'Use `mount -t zfs -p` to determine the ZFS dataset for a given mountpoint. 89 : 'Use `mount -t zfs -p` to determine the ZFS dataset for a given mountpoint.
90 90
91 ' 91 '
92 local _mountpoint 92 local _mountpoint
93 93
94 local _ds _mount _rest 94 local _ds _mount _rest
95 95
96 _mountpoint="$1" 96 _mountpoint="$1"
97 97
98 mount -t zfs -p \ 98 mount -t zfs -p \
128 return 2; 128 return 2;
129 ;; 129 ;;
130 esac 130 esac
131 done 131 done
132 shift $((OPTIND-1)) 132 shift $((OPTIND-1))
133 OPTIND=1 133 OPTIND=1
134 134
135 _p_base="${1-}" 135 _p_base="${1-}"
136 _name="${2-}" 136 _name="${2-}"
137 137
138 if [ -z "${_p_base}" ]; then 138 if [ -z "${_p_base}" ]; then
185 return 2; 185 return 2;
186 ;; 186 ;;
187 esac 187 esac
188 done 188 done
189 shift $((OPTIND-1)) 189 shift $((OPTIND-1))
190 OPTIND=1 190 OPTIND=1
191 191
192 _p_skel="${1-}" 192 _p_skel="${1-}"
193 _name="${2-}" 193 _name="${2-}"
194 194
195 if [ -z "${_p_skel}" ]; then 195 if [ -z "${_p_skel}" ]; then
401 # be equal to the configured mountpoint when no custom mountpoint 401 # be equal to the configured mountpoint when no custom mountpoint
402 # is given. 402 # is given.
403 # 403 #
404 if [ "${_mount_natural}" = "yes" ]; then 404 if [ "${_mount_natural}" = "yes" ]; then
405 if [ "${_real_mp}" != "${_mp}" ]; then 405 if [ "${_real_mp}" != "${_mp}" ]; then
406 echo "ERROR: mountpoint mismatch" >&2 406 echo "ERROR: mountpoint mismatch" 1>&2
407 return 1 407 return 1
408 fi 408 fi
409 fi 409 fi
410 410
411 if [ "${_dry_run}" = "yes" ]; then 411 if [ "${_dry_run}" = "yes" ]; then
416 echo "Mounting ${_name} on ${_real_mp}" 416 echo "Mounting ${_name} on ${_real_mp}"
417 mount -t zfs "${_name}" "${_real_mp}" || return 1 417 mount -t zfs "${_name}" "${_real_mp}" || return 1
418 fi 418 fi
419 ;; 419 ;;
420 *) 420 *)
421 echo "Skipping ${_name} because its configured ZFS mountpoint is not relative to given root dataset" 2>&1 421 echo "Skipping ${_name} because its configured ZFS mountpoint is not relative to given root dataset" 1>&2
422 ;; 422 ;;
423 esac 423 esac
424 done 424 done
425 425
426 return 0 426 return 0
534 534
535 _ensure_no_options "$@" 535 _ensure_no_options "$@"
536 536
537 _mountpoint="${1-}" 537 _mountpoint="${1-}"
538 538
539 [ -z "${_mountpoint}" ] && { echo "ERROR: no mountpoint given" 2>&1; return 2; } 539 [ -z "${_mountpoint}" ] && { echo "ERROR: no mountpoint given" 1>&2; return 2; }
540 [ -d "${_mountpoint}" ] || { echo "ERROR: mountpoint \`${_mountpoint}' does not exist" 2>&1; return 1; } 540 [ -d "${_mountpoint}" ] || { echo "ERROR: mountpoint \`${_mountpoint}' does not exist" 1>&2; return 1; }
541 [ -d "${_mountpoint}/skeleton" ] || { echo "WARNING: skeleton is not mounted at \`${_mountpoint}/skeleton'" 2>&1; } 541 [ -d "${_mountpoint}/skeleton" ] || { echo "WARNING: skeleton is not mounted at \`${_mountpoint}/skeleton'" 1>&2; }
542 542
543 for _dir in etc home root tmp usr/local var ; do 543 for _dir in etc home root tmp usr/local var ; do
544 case "${_dir}" in 544 case "${_dir}" in
545 "usr/local") 545 "usr/local")
546 _dirpart="$(dirname "${_dir}")" 546 _dirpart="$(dirname "${_dir}")"