6b0f80d89d6495c843f6a5fe369bc3b18433aa01
4 # this script is idempotent
6 # warning: changes here may affect the open version of this script
8 if ! test "$BASH_VERSION"; then echo "error: shell is not bash" >&2; exit 1; fi
9 shopt -s inherit_errexit
2>/dev
/null ||
: # ignore fail in bash < 4.4
11 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" exit status: $?, PIPESTATUS: ${PIPESTATUS[*]}" >&2' ERR
13 m
() { printf "%s\n" "$*"; "$@"; }
16 fs_file
=/root
/crypt-luks-keys-loopback
17 mapper_name
=crypt-luks-keys-loopback
19 if mountpoint
/mnt2
&>/dev
/null
; then
22 if cryptsetup status
/dev
/mapper
/$mapper_name &>/dev
/null
; then
23 m cryptsetup luksClose
/dev
/mapper
/$mapper_name; then
25 l
=$
(losetup
-l --noheadings |
awk '$6 ~ /\/'$mapper_name'$/ {print $1}')
29 echo "$0: warning: no loopback device found" >&2