diff --git a/driveAtlas.sh b/driveAtlas.sh index 40c44cc..e2502f8 100644 --- a/driveAtlas.sh +++ b/driveAtlas.sh @@ -34,15 +34,15 @@ get_drives_info() { get_bay_number() { local drive=$1 - local path=$(readlink -f "/dev/disk/by-path/"*$(basename "$drive")) + local drive_name=$(basename "$drive") - # Extract bay number from the path based on medium2's mapping - for mapping in ${DRIVE_MAPPINGS[medium2]}; do - if [[ $path =~ $mapping ]]; then - echo "${mapping##*:}" + # Search through mappings for this drive + while IFS=: read -r path bay device; do + if [[ "$drive_name" == "$device" ]]; then + echo "$bay" return fi - done + done <<< "${DRIVE_MAPPINGS[medium2]}" } get_physical_mapping() {