qmnt - Added checks to see if partition is already mounted, or mountpoint occupied

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

View file

@ -189,7 +189,10 @@ fi
if [[ -z $DRY_RUN ]]; then
if ! mount -o "${MOUNT_OPTS}" --source "${TARGET}" --target "${MOUNT_FOLDER}/${LABEL}"; then
if \
mountpoint "${MOUNT_FOLDER}/${LABEL}" 2>&1 &>/dev/null || \
findmnt -n -o SOURCE "${TARGET}" 2>&1 &>/dev/null || \
! mount -o "${MOUNT_OPTS}" --source "${TARGET}" --target "${MOUNT_FOLDER}/${LABEL}"; then
echo -e "\e[1;31mFailed to mount \"${TARGET}\"!""\e[0m" 1>&2
exit 1
fi