Misc changes
This commit is contained in:
+9
-19
@@ -99,28 +99,19 @@ 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} "${REMOTE_STDOUT%std.log}"
|
|
||||||
mkdir -${MKDIR_FLAGS} "${REMOTE_STDERR%err.log}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# --- Initialize Global JSON Output ---
|
|
||||||
HW_REPORT=\$(jq -n '{}')
|
HW_REPORT=\$(jq -n '{}')
|
||||||
|
|
||||||
# --- Helper: Add JSON array to the main report ---
|
|
||||||
append_to_report() {
|
append_to_report() {
|
||||||
local key="\$1"
|
local key="\${1}"
|
||||||
local json_array="\$2"
|
local json_array="\${2}"
|
||||||
HW_REPORT=\$(echo "\$HW_REPORT" | jq --argjson arr "\$json_array" --arg k "\$key" '.[\$k] = \$arr')
|
HW_REPORT=\$(echo "\${HW_REPORT}" | jq --argjson arr "\${json_array}" --arg k "\${key}" '.[\${k}] = \${arr}')
|
||||||
}
|
}
|
||||||
|
|
||||||
# --- 1. Detect Graphics ---
|
|
||||||
detect_graphics() {
|
detect_graphics() {
|
||||||
local gpus="[]"
|
local gpus="[]"
|
||||||
|
|
||||||
# Process each GPU found by lspci
|
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
[[ -z "\$line" ]] && continue
|
[[ -z "\${line}" ]] && continue
|
||||||
local brand="unknown"
|
local brand="unknown"
|
||||||
local renderer="none"
|
local renderer="none"
|
||||||
local product="unknown"
|
local product="unknown"
|
||||||
@@ -128,11 +119,11 @@ detect_graphics() {
|
|||||||
local pci_addr="none"
|
local pci_addr="none"
|
||||||
|
|
||||||
# Extract PCI address
|
# Extract PCI address
|
||||||
pci_addr="\$(echo "\$line" | cut -d' ' -f1)"
|
pci_addr="\$(echo "\${line}" | cut -d' ' -f1)"
|
||||||
|
|
||||||
# Brand
|
# Brand
|
||||||
for b in Intel AMD NVIDIA; do
|
for b in Intel AMD NVIDIA; do
|
||||||
if echo "\$line" | grep -iq "\$b"; then
|
if echo "\${line}" | grep -iq "\${b}"; then
|
||||||
brand="\${b}"
|
brand="\${b}"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
@@ -140,10 +131,9 @@ detect_graphics() {
|
|||||||
|
|
||||||
# Renderer
|
# Renderer
|
||||||
if [[ -d "/dev/dri/by-path" ]]; then
|
if [[ -d "/dev/dri/by-path" ]]; then
|
||||||
local render_node
|
local render_node=\$(ls /dev/dri/by-path | grep "\${pci_addr}" | grep "render" | head -n1 || true)
|
||||||
render_node=\$(ls /dev/dri/by-path | grep "\$pci_addr" | grep "render" | head -n1 || true)
|
if [[ -n "\${render_node}" ]]; then
|
||||||
if [[ -n "\$render_node" ]]; then
|
renderer=\$(basename "\$(readlink -f "/dev/dri/by-path/\${render_node}")")
|
||||||
renderer=\$(basename "\$(readlink -f "/dev/dri/by-path/\$render_node")")
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user