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