From 297df7bb2efe54426a68e138883a3e73dcd54d57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Numbus?= Date: Mon, 25 May 2026 21:37:16 +0200 Subject: [PATCH] Debugging. --- script/deploy.sh | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/script/deploy.sh b/script/deploy.sh index 52ebdcf..6f429ce 100755 --- a/script/deploy.sh +++ b/script/deploy.sh @@ -117,37 +117,38 @@ append_to_report() { # --- 1. Detect Graphics --- detect_graphics() { local gpus="[]" - local obj - local brand - local renderer - local product - local integrated - local pci_addr - while read -r gpu; do - echo \$gpu >> "${REMOTE_STDERR}" - echo "test" >> "${REMOTE_STDERR}" + # Process each GPU found by lspci + while read -r line; do + [[ -z "\$line" ]] && continue + local brand="unknown" + local renderer="none" + local product="unknown" + local integrated="false" + local pci_addr="none" - pci_addr="\$(lspci | grep VGA | head -c 7)" + # Extract PCI address (e.g. 00:02.0) + pci_addr="\$(echo "\$line" | cut -d' ' -f1)" # Brand for b in Intel AMD NVIDIA; do - if echo "\${gpu}" | grep -i "\${b}" >> "${REMOTE_STDOUT}" 2>> "${REMOTE_STDERR}"; then + if echo "\$line" | grep -iq "\$b"; then brand="\${b}" + break fi done # Renderer - 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" + if [[ -d "/dev/dri/by-path" ]]; then + local render_node + render_node=\$(ls /dev/dri/by-path | grep "\$pci_addr" | grep "render" | head -n1 || true) + if [[ -n "\$render_node" ]]; then + renderer=\$(basename "\$(readlink -f "/dev/dri/by-path/\$render_node")") + fi fi # Product name - product="\${gpu#*:}" + product="\${line#*:}" product="\${product#*: }" # Form factor @@ -162,25 +163,24 @@ detect_graphics() { fi fi if [[ "\${brand}" == "AMD" ]]; then - if echo "\${gpu}" | grep "Mobile"; then + if echo "\$line" | grep -iq "Mobile"; then integrated="true" else integrated="false" fi fi - obj=\$(jq -n \ + local obj=\$(jq -n \ --arg b "\${brand}" \ --arg r "\${renderer}" \ --arg p "\${product}" \ --argjson i "\${integrated}" \ - '{brand: \${b}, renderer: \${r}, product: \${p}, integrated: \${i}}') + '{brand: \$b, renderer: \$r, product: \$p, integrated: \$i}') gpus=\$(echo "\$gpus" | jq --argjson obj "\$obj" '. += [\$obj]') - done < <(lspci | grep -e "VGA" -e "3D" >> "${REMOTE_STDOUT}" 2>> "${REMOTE_STDERR}") + done < <(lspci | grep -E "VGA|3D") - echo "\$gpus" >> "${REMOTE_STDERR}" append_to_report "graphics" "\$gpus" }