This commit is contained in:
Marc Beninca 2025-03-30 22:25:22 +02:00
parent 930f296dc8
commit 715708dc3d
Signed by: marc.beninca
GPG key ID: 9C7613450C80C24F

View file

@ -52,32 +52,37 @@ rwx_crypt() {
local device local device
case "${action}" in case "${action}" in
"${action_open}") "${action_open}")
# find device
if ! device="$(rwx_crypt_device)"; then if ! device="$(rwx_crypt_device)"; then
rwx_log_error 4 "No device available" rwx_log_error 4 "No device available"
fi fi
# make directory
if ! mkdir --parents "${RWX_CRYPT_VAR}"; then
rwx_log_error 5 "Making failure: ${RWX_CRYPT_VAR}"
fi
# record device # record device
if ! rwx_file_write \ if ! rwx_file_write \
"${RWX_CRYPT_VAR}/${crypt_arg}" "${device}"; then "${RWX_CRYPT_VAR}/${crypt_arg}" "${device}"; then
rwx_log_error 5 "Writing failure: ${device}" rwx_log_error 6 "Writing failure: ${device}"
fi fi
# connect device # connect device
if ! qemu-nbd --connect "${device}" "${crypt_file}"; then if ! qemu-nbd --connect "${device}" "${crypt_file}"; then
rwx_log_error 6 "Connection failure: ${device}" rwx_log_error 7 "Connection failure: ${device}"
fi fi
# open device # open device
if ! echo "${pass_phrase}" | if ! echo "${pass_phrase}" |
cryptsetup luksOpen "${device}" "${crypt_arg}"; then cryptsetup luksOpen "${device}" "${crypt_arg}"; then
rwx_log_error 7 "Opening failure: ${device}" rwx_log_error 8 "Opening failure: ${device}"
fi fi
# make mount directory # make mount directory
if ! mkdir --parents "${crypt_mount}"; then if ! mkdir --parents "${crypt_mount}"; then
rwx_log_error 8 "Making failure: ${crypt_mount}" rwx_log_error 9 "Making failure: ${crypt_mount}"
fi fi
# mount file system # mount file system
if ! mount \ if ! mount \
--options "autodefrag,compress-force=zstd" \ --options "autodefrag,compress-force=zstd" \
"${crypt_map}" "${crypt_mount}"; then "${crypt_map}" "${crypt_mount}"; then
rwx_log_error 9 "Mounting failure: ${crypt_map}" rwx_log_error 10 "Mounting failure: ${crypt_map}"
fi fi
;; ;;
"${action_close}") "${action_close}")