Fixed encrypted partition support

This commit is contained in:
Logan G 2024-09-24 23:51:49 -06:00
parent 9e2a71d6bd
commit d9e58a5c3b
Signed by: logan
GPG key ID: E328528C921E7A7A

View file

@ -115,14 +115,15 @@ get_mapped () {
if ! cryptsetup open "${TARGET}" "${MAPPED_NAME}"; then
echo -e "\e[1;31mCould not unlock target \"${TARGET}\"!""\e[0m" 1>&2
exit 1
else
fi
TARGET="/dev/mapper/${MAPPED_NAME}"
NEW_LABEL=$(blkid -o value -s LABEL "${TARGET}")
[[ -z $NEW_LABEL ]] && LABEL=$NEW_LABEL
trap "cryptsetup close ${TARGET}" EXIT
TYPE=$(blkid -o value -s TYPE "${TARGET}")
fi
[[ ! -z $(blkid -o value -s LABEL "${TARGET}") ]] && LABEL=$(blkid -o value -s LABEL "${TARGET}")
TYPE=$(blkid -o value -s TYPE "${TARGET}" || true) # Fuck you bash
}
if [[ "$#" -eq 0 ]]; then
@ -157,6 +158,8 @@ if [[ -z $TARGET ]]; then
exit 1
fi
MAPPED_NAME=""
LABEL=$(blkid -o value -s LABEL "${TARGET}")
[[ -z $LABEL ]] && LABEL=$(basename "${TARGET}")
@ -167,6 +170,8 @@ if [[ -z $TYPE ]]; then
exit 1
fi
trap - EXIT
if [[ -z "${DEFAULT_MOUNT_OPTS["$TYPE"]}" ]]; then
MOUNT_OPTS="${DEFAULT_MOUNT_OPTS["OTHER"]}""${MOUNT_OPTS}"
else
@ -192,7 +197,9 @@ fi
done
rmdir "${1}"
' -- "${MOUNT_FOLDER}/${LABEL}" >/dev/null 2>&1 &
[ -b /dev/mapper/"${2}" ] && cryptsetup close /dev/mapper/"${2}"
' -- "${MOUNT_FOLDER}/${LABEL}" "${MAPPED_NAME}" >/dev/null 2>&1 &
) &
echo -e "\e[1;32mDevice \"${TARGET}\" successfully mounted at \"${MOUNT_FOLDER}/${LABEL}\"""\e[0m"