dynamic usb and sata?

This commit is contained in:
2025-03-01 12:28:18 -05:00
parent 351270b886
commit f592783359

View File

@ -106,58 +106,46 @@ medium1='''
'''
generate_medium2_layout() {
local usb_drives=$(ls -l /dev/disk/by-path/pci-0000:0b:00.0* 2>/dev/null | awk -F'/' '{print $NF}')
local sata_drives=$(ls -l /dev/disk/by-path/pci-0000:0c:00.0-ata-[0-9]$ 2>/dev/null | awk -F'/' '{print $NF}')
local nvme_drive=$(ls -l /dev/disk/by-path/pci-0000:0d:00.0* 2>/dev/null | awk -F'/' '{print $NF}')
# USB Section
printf " External USB [0b:00.0]\n"
printf " ┌────┐ ┌────┐\n"
for drive in sdf sde; do
if echo "$usb_drives" | grep -q "$drive"; then
local size=$(get_drive_details "$drive")
printf " │%-4s│ " "$drive"
printf "│%-4s│\n" "$size"
fi
printf " ┌────────┐ ┌────────┐\n"
for usb_drive in $(echo "$usb_drives" | awk -F'/' '{print $NF}'); do
local size=$(get_drive_details "$usb_drive")
printf " │ %-6s │ │ %-6s │\n" "$usb_drive" "$size"
done
printf " └────┘ └────┘\n\n"
printf " └────────┘ └────────┘\n\n"
# Main chassis layout
# Main chassis
printf "┌──────────────────────────────────────────────────────────────┐\n"
printf "│ B650D4U3-2Q/BCM │\n"
printf "│ │\n"
printf "│ NVMe [0d:00.0] │\n"
printf "│ ┌────┐ │\n"
if [ -n "$nvme_drive" ]; then
local nvme_info=$(get_drive_smart_info "$nvme_drive")
printf "│ │%-4s│ │\n" "$nvme_drive"
printf "│ │%-4s│ │\n" "$nvme_info"
fi
printf "│ └────┘ │\n"
printf "│ ┌────────┐ │\n"
printf "│ │ %-6s │ │\n" "nvme0n1"
printf "│ │ PCIe │ │\n"
printf "│ └────────┘ │\n"
printf "│ │\n"
printf "│ Front Hot-swap Bays [0c:00.0] │\n"
printf "│ ┌────────┐┌────────┐┌────────┐┌────────┐┌────────┐┌────────┐┌────────┐┌────────┐┌────────┐┌────────┐ │\n"
# Hot-swap bays
printf "│ ┌────┐┌────┐┌────┐┌────┐┌────┐┌────┐┌────┐┌────┐┌────┐┌────┐ │\n"
for row in {1..7}; do
printf "│ "
for bay in {1..10}; do
local drive=$(echo "$sata_drives" | grep "ata-$bay" | cut -d'/' -f3)
if [ $row -eq 4 ]; then
printf "│ %-3d │" "$bay"
elif [ -n "$drive" ]; then
case $row in
2) local info=$(get_drive_smart_info "$drive"); printf "│%-4s│" "${info%%|*}" ;;
3) local size=$(get_drive_details "$drive"); printf "│%-4s│" "$size" ;;
*) printf "│ │" ;;
esac
else
printf "│ │"
fi
done
printf " │\n"
# Map drives to bays dynamically
for bay in {1..10}; do
# Get drive info from physical path mapping
local drive_path=$(ls -l /dev/disk/by-path/pci-0000:0c:00.0-ata-$bay 2>/dev/null)
if [ -n "$drive_path" ]; then
local drive=$(echo "$drive_path" | awk -F'/' '{print $NF}')
local size=$(get_drive_details "$drive")
local smart_info=$(get_drive_smart_info "$drive")
printf "│ │ %-6s │" "$drive"
printf "│ │ %-6s │" "$size"
printf "│ │ %-6s │" "${smart_info%%|*}"
else
printf "│ │ EMPTY │"
fi
done
printf "│ └────┘└────┘└────┘└────┘└────┘└────┘└────┘└────┘└────┘└────┘ │\n"
printf " │\n"
printf "│ └────────┘└────────┘└────────┘└────────┘└────────┘└────────┘└────────┘└────────┘└────────┘└────────┘ │\n"
printf "└──────────────────────────────────────────────────────────────┘\n"
}