qmnt - Added UUID mount labeling option

This commit is contained in:
Logan G 2024-09-25 12:52:57 -06:00
parent 44cad425a4
commit dbecee4919
Signed by: logan
GPG key ID: E328528C921E7A7A

View file

@ -19,6 +19,7 @@ MOUNT_FOLDER="/run/media/${CURRENT_USER}"
ALLOW_UUID="0"
ALLOW_LABEL="0"
LABEL_BY="LABEL"
print_help () {
cat /dev/stdin << EOF
@ -32,6 +33,7 @@ Options:
-u --uuid Allow UUIDs as the target
-l --label Allow labels as the target
-d --dry-run Does nothing
-U --label-uuid Use UUID instead of drive label for mountpoint name
-ro --read-only Mounts target as read only
EOF
@ -123,7 +125,7 @@ get_mapped () {
trap "cryptsetup close ${TARGET}" EXIT
[[ ! -z $(blkid -o value -s LABEL "${TARGET}") ]] && LABEL=$(blkid -o value -s LABEL "${TARGET}")
[[ ! -z $(blkid -o value -s "${LABEL_BY}" "${TARGET}") ]] && LABEL=$(blkid -o value -s "${LABEL_BY}" "${TARGET}")
TYPE=$(blkid -o value -s TYPE "${TARGET}" || true) # Fuck you bash
fi
@ -150,6 +152,9 @@ for arg in "$@"; do
"-d" | "--dry-run")
DRY_RUN="1"
;;
"-U" | "--label-uuid")
LABEL_BY="UUID"
;;
"-ro" | "--read-only")
MOUNT_OPTS+=",ro"
;;
@ -166,7 +171,7 @@ fi
MAPPED_NAME=""
LABEL=$(blkid -o value -s LABEL "${TARGET}")
LABEL=$(blkid -o value -s "${LABEL_BY}" "${TARGET}")
[[ -z $LABEL ]] && LABEL=$(basename "${TARGET}")
TYPE=$(blkid -o value -s TYPE "${TARGET}")