Improved graphics detection.
This commit is contained in:
+41
-44
@@ -99,6 +99,11 @@ hardware_detection() {
|
|||||||
ssh_to_host "nix-shell -p jq pciutils usbutils smartmontools iproute2 --run 'bash -s'" << SSHEND >> "${STDOUT}" 2>> "${STDERR}"
|
ssh_to_host "nix-shell -p jq pciutils usbutils smartmontools iproute2 --run 'bash -s'" << SSHEND >> "${STDOUT}" 2>> "${STDERR}"
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
if [[ ${DEBUG} -eq 1 ]]; then
|
||||||
|
mkdir -${MKDIR_FLAGS} "${STDOUT}"
|
||||||
|
mkdir -${MKDIR_FLAGS} "${STDERR}"
|
||||||
|
fi
|
||||||
|
|
||||||
# --- Initialize Global JSON Output ---
|
# --- Initialize Global JSON Output ---
|
||||||
HW_REPORT=\$(jq -n '{}')
|
HW_REPORT=\$(jq -n '{}')
|
||||||
|
|
||||||
@@ -116,64 +121,54 @@ detect_graphics() {
|
|||||||
local renderer
|
local renderer
|
||||||
local product
|
local product
|
||||||
|
|
||||||
for line in lspci | grep VGA; do
|
OLD_IFS="\$IFS"
|
||||||
local pci_addr
|
IFS=\$'n'
|
||||||
|
|
||||||
|
for line in \$(lspci | grep -e VGA -e 3D >> "${STDOUT}" 2>> "${STDERR}"); do
|
||||||
|
local pci_addr
|
||||||
pci_addr="\$(lspci | grep VGA | head -c 7)"
|
pci_addr="\$(lspci | grep VGA | head -c 7)"
|
||||||
|
|
||||||
# Brand
|
# Brand
|
||||||
for b in Intel AMD NVIDIA; do
|
for b in Intel AMD NVIDIA; do
|
||||||
if [[ echo "\${line}" | grep -i "\${b}" ]]; then
|
if echo "\${line}" | grep -i "\${b}" >> "${STDOUT}" 2>> "${STDERR}"; then
|
||||||
brand="\${b}"
|
brand="\${b}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Renderer info
|
# Renderer info
|
||||||
|
renderer="\$(ls -lh /dev/dri/by-path | grep "\$pci_addr" | grep "render")"
|
||||||
|
if [[ -n "\${renderer}" ]]; then
|
||||||
|
renderer="${renderer##*render}"
|
||||||
|
renderer="render${renderer}"
|
||||||
|
else
|
||||||
|
renderer="none"
|
||||||
|
fi
|
||||||
|
|
||||||
# Product name
|
# Product name
|
||||||
|
product="\${line#*:}"
|
||||||
|
product="\${product#*: }"
|
||||||
|
|
||||||
#
|
# Form factor
|
||||||
|
if [[ "\${brand}" == "NVIDIA" ]]; then
|
||||||
|
integrated="false"
|
||||||
|
fi
|
||||||
|
if [[ "\${brand}" == "Intel" ]]; then
|
||||||
|
if echo "\${line}" | grep -e "HD Graphics" -e "Xe"; then
|
||||||
|
integrated="true"
|
||||||
|
else
|
||||||
|
integrated="false"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [[ "\${brand}" == "AMD" ]]; then
|
||||||
|
if echo "\${line}" | grep "Mobile"; then
|
||||||
|
integrated="true"
|
||||||
|
else
|
||||||
|
integrated="false"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
IFS="\${OLD_IFS}"
|
||||||
|
|
||||||
# Iterate over all VGA and 3D controllers
|
|
||||||
while read -r pci_addr; do
|
|
||||||
local brand="Unknown"
|
|
||||||
local integrated="false"
|
|
||||||
local renderer=""
|
|
||||||
|
|
||||||
# Determine Brand
|
|
||||||
local vendor_info
|
|
||||||
vendor_info=\$(lspci -vms "\$pci_addr" | grep -i "^Vendor:" || true)
|
|
||||||
if echo "\$vendor_info" | grep -iq "intel"; then
|
|
||||||
brand="Intel"
|
|
||||||
integrated="true" # General heuristic for Intel
|
|
||||||
elif echo "\$vendor_info" | grep -iq "amd"; then
|
|
||||||
brand="AMD"
|
|
||||||
# If boot_vga is 1, it's likely the primary/integrated APU
|
|
||||||
if [[ -f "/sys/bus/pci/devices/0000:\$pci_addr/boot_vga" ]] && grep -q "1" "/sys/bus/pci/devices/0000:\$pci_addr/boot_vga"; then
|
|
||||||
integrated="true"
|
|
||||||
fi
|
|
||||||
elif echo "\$vendor_info" | grep -iq "nvidia"; then
|
|
||||||
brand="NVIDIA"
|
|
||||||
integrated="false" # NVIDIA is almost always discrete in these contexts
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Find Renderer (e.g., renderD128)
|
|
||||||
if [[ -d "/sys/bus/pci/devices/0000:\$pci_addr/drm" ]]; then
|
|
||||||
renderer=\$(find "/sys/bus/pci/devices/0000:\$pci_addr/drm" -maxdepth 1 -name "renderD*" -exec basename {} \; | head -n 1)
|
|
||||||
[[ -n "\$renderer" ]] && renderer="/dev/dri/\$renderer"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Append to array
|
|
||||||
local gpu_obj
|
|
||||||
gpu_obj=\$(jq -n --arg b "\$brand" --arg r "\${renderer:-N/A}" --argjson i "\$integrated" \
|
|
||||||
'{brand: \$b, renderer: \$r, integrated: \$i}')
|
|
||||||
gpus=\$(echo "\$gpus" | jq --argjson obj "\$gpu_obj" '. += [\$obj]')
|
|
||||||
|
|
||||||
done < <(lspci -D | grep -iE 'VGA|3D' | awk '{print \$1}')
|
|
||||||
|
|
||||||
append_to_report "graphics" "\$gpus"
|
append_to_report "graphics" "\$gpus"
|
||||||
}
|
}
|
||||||
@@ -183,7 +178,7 @@ detect_corals() {
|
|||||||
local corals="[]"
|
local corals="[]"
|
||||||
|
|
||||||
# Check PCIe Coral (Google ID 1ac1:089a)
|
# Check PCIe Coral (Google ID 1ac1:089a)
|
||||||
if lspci -nn >> "${STDOUT}" 2>> "${STDERR}" | grep -iq "1ac1:089a"; then
|
if lspci -nn | grep -iq "1ac1:089a" >> "${STDOUT}" 2>> "${STDERR}"; then
|
||||||
local pcie_count
|
local pcie_count
|
||||||
pcie_count=\$(lspci -nn | grep -ic "1ac1:089a")
|
pcie_count=\$(lspci -nn | grep -ic "1ac1:089a")
|
||||||
for ((i=1; i<=pcie_count; i++)); do
|
for ((i=1; i<=pcie_count; i++)); do
|
||||||
@@ -348,6 +343,8 @@ echo "\$HW_REPORT" | jq '.' > "$TMPFILE"
|
|||||||
SSHEND
|
SSHEND
|
||||||
|
|
||||||
scp -i "${TMP_EXTRA_PATH}/home/numbus-admin/.ssh/id_ed25519" "${TARGET_USER}@${LIVE_TARGET_IP}":"${TMPFILE}" "${HW_DATA_FILE}" >> "${STDOUT}" 2>> "${STDERR}"
|
scp -i "${TMP_EXTRA_PATH}/home/numbus-admin/.ssh/id_ed25519" "${TARGET_USER}@${LIVE_TARGET_IP}":"${TMPFILE}" "${HW_DATA_FILE}" >> "${STDOUT}" 2>> "${STDERR}"
|
||||||
|
[[ ${DEBUG} -eq 1 ]] && scp -i "${TMP_EXTRA_PATH}/home/numbus-admin/.ssh/id_ed25519" "${TARGET_USER}@${LIVE_TARGET_IP}":"${STDOUT}" "${INSTALL_DIR}/logs/hw_std.log" >> "${STDOUT}" 2>> "${STDERR}"
|
||||||
|
[[ ${DEBUG} -eq 1 ]] && scp -i "${TMP_EXTRA_PATH}/home/numbus-admin/.ssh/id_ed25519" "${TARGET_USER}@${LIVE_TARGET_IP}":"${STDERR}" "${INSTALL_DIR}/logs/hw_err.log" >> "${STDOUT}" 2>> "${STDERR}"
|
||||||
|
|
||||||
if ssh_to_host "sudo nixos-generate-config --no-filesystems --show-hardware-config" > ${TMP_EXTRA_PATH}/etc/nixos/hardware-configuration.nix; then
|
if ssh_to_host "sudo nixos-generate-config --no-filesystems --show-hardware-config" > ${TMP_EXTRA_PATH}/etc/nixos/hardware-configuration.nix; then
|
||||||
echo -e "\n ✅ Hardware configuration generated"
|
echo -e "\n ✅ Hardware configuration generated"
|
||||||
|
|||||||
Reference in New Issue
Block a user