Compare commits
2 Commits
d3bdf02a6a
...
55c51c7205
| Author | SHA1 | Date | |
|---|---|---|---|
| 55c51c7205 | |||
| 297df7bb2e |
+53
-60
@@ -117,37 +117,38 @@ append_to_report() {
|
|||||||
# --- 1. Detect Graphics ---
|
# --- 1. Detect Graphics ---
|
||||||
detect_graphics() {
|
detect_graphics() {
|
||||||
local gpus="[]"
|
local gpus="[]"
|
||||||
local obj
|
|
||||||
local brand
|
|
||||||
local renderer
|
|
||||||
local product
|
|
||||||
local integrated
|
|
||||||
local pci_addr
|
|
||||||
|
|
||||||
while read -r gpu; do
|
# Process each GPU found by lspci
|
||||||
echo \$gpu >> "${REMOTE_STDERR}"
|
while read -r line; do
|
||||||
echo "test" >> "${REMOTE_STDERR}"
|
[[ -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
|
||||||
|
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 "\${gpu}" | grep -i "\${b}" >> "${REMOTE_STDOUT}" 2>> "${REMOTE_STDERR}"; then
|
if echo "\$line" | grep -iq "\$b"; then
|
||||||
brand="\${b}"
|
brand="\${b}"
|
||||||
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Renderer
|
# Renderer
|
||||||
renderer="\$(ls -lh /dev/dri/by-path | grep "\$pci_addr" | grep "render")"
|
if [[ -d "/dev/dri/by-path" ]]; then
|
||||||
if [[ -n "\${renderer}" ]]; then
|
local render_node
|
||||||
renderer="\${renderer##*render}"
|
render_node=\$(ls /dev/dri/by-path | grep "\$pci_addr" | grep "render" | head -n1 || true)
|
||||||
renderer="render\${renderer}"
|
if [[ -n "\$render_node" ]]; then
|
||||||
else
|
renderer=\$(basename "\$(readlink -f "/dev/dri/by-path/\$render_node")")
|
||||||
renderer="none"
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Product name
|
# Product name
|
||||||
product="\${gpu#*:}"
|
product="\${line#*:}"
|
||||||
product="\${product#*: }"
|
product="\${product#*: }"
|
||||||
|
|
||||||
# Form factor
|
# Form factor
|
||||||
@@ -155,32 +156,31 @@ detect_graphics() {
|
|||||||
integrated="false"
|
integrated="false"
|
||||||
fi
|
fi
|
||||||
if [[ "\${brand}" == "Intel" ]]; then
|
if [[ "\${brand}" == "Intel" ]]; then
|
||||||
if echo "\${gpu}" | grep -e "HD Graphics" -e "Xe"; then
|
if echo "\${gpu}" | grep -Ei "HD Graphics|Xe"; then
|
||||||
integrated="true"
|
integrated="true"
|
||||||
else
|
else
|
||||||
integrated="false"
|
integrated="false"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [[ "\${brand}" == "AMD" ]]; then
|
if [[ "\${brand}" == "AMD" ]]; then
|
||||||
if echo "\${gpu}" | grep "Mobile"; then
|
if echo "\$line" | grep -i "Mobile"; then
|
||||||
integrated="true"
|
integrated="true"
|
||||||
else
|
else
|
||||||
integrated="false"
|
integrated="false"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
obj=\$(jq -n \
|
local obj=\$(jq -n \
|
||||||
--arg b "\${brand}" \
|
--arg b "\${brand}" \
|
||||||
--arg r "\${renderer}" \
|
--arg r "\${renderer}" \
|
||||||
--arg p "\${product}" \
|
--arg p "\${product}" \
|
||||||
--argjson i "\${integrated}" \
|
--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]')
|
gpus=\$(echo "\$gpus" | jq --argjson obj "\$obj" '. += [\$obj]')
|
||||||
|
|
||||||
done < <(lspci | grep -e "VGA" -e "3D" >> "${REMOTE_STDOUT}" 2>> "${REMOTE_STDERR}")
|
done < <(lspci | grep -Ei "VGA|3D")
|
||||||
|
|
||||||
echo "\$gpus" >> "${REMOTE_STDERR}"
|
|
||||||
append_to_report "graphics" "\$gpus"
|
append_to_report "graphics" "\$gpus"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,58 +284,51 @@ detect_tpm() {
|
|||||||
# --- 6. Detect Disks ---
|
# --- 6. Detect Disks ---
|
||||||
detect_disks() {
|
detect_disks() {
|
||||||
local disks="[]"
|
local disks="[]"
|
||||||
|
|
||||||
# lsblk to loop through block devices (ignoring loops, rams, and cdroms)
|
|
||||||
while read -r disk; do
|
|
||||||
local dev_path="/dev/\$disk"
|
|
||||||
|
|
||||||
# Disk Type Mapping
|
|
||||||
local disk_type="Other"
|
|
||||||
local transport
|
|
||||||
transport=\$(lsblk -d -n -o TRAN "\$dev_path" >> "${REMOTE_STDOUT}" 2>> "${REMOTE_STDERR}" || echo "")
|
|
||||||
local rotational
|
|
||||||
rotational=\$(lsblk -d -n -o ROTA "\$dev_path" >> "${REMOTE_STDOUT}" 2>> "${REMOTE_STDERR}" || echo "1")
|
|
||||||
|
|
||||||
if [[ "\$disk" == nvme* ]]; then
|
while read -r disk; do
|
||||||
disk_type="NVMe"
|
# Disk Type Mapping
|
||||||
elif [[ "\$transport" == "usb" ]]; then
|
local disk_type="unknown"
|
||||||
disk_type="USB"
|
local disk_transport=\$(lsblk -d -n -o TRAN "\$dev_path" || echo "unknown")
|
||||||
|
local rotational=\$(lsblk -d -n -o ROTA "\$dev_path" || echo "1")
|
||||||
|
|
||||||
|
if [[ "\$disk_name" == nvme* ]]; then
|
||||||
|
disk_type="NVMe"
|
||||||
elif [[ "\$rotational" == "1" ]]; then
|
elif [[ "\$rotational" == "1" ]]; then
|
||||||
disk_type="HDD"
|
disk_type="HDD"
|
||||||
elif [[ "\$rotational" == "0" ]]; then
|
elif [[ "\$rotational" == "0" ]]; then
|
||||||
disk_type="SSD"
|
disk_type="SSD"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Size in GB
|
# Size in GB
|
||||||
local size_bytes
|
local disk_size=\$(lsblk -d -n -o SIZE "\$dev_path" || echo "unknown")
|
||||||
size_bytes=\$(lsblk -d -n -b -o SIZE "\$dev_path" >> "${REMOTE_STDOUT}" 2>> "${REMOTE_STDERR}" || echo "0")
|
|
||||||
local size_gb=\$(awk -v size_bytes="\$size_bytes" 'BEGIN {printf "%.2f", size_bytes/1073741824}')
|
|
||||||
|
|
||||||
# ID via by-id
|
# ID via by-id
|
||||||
local disk_id="N/A"
|
local disk_id="unknown"
|
||||||
if [[ -d "/dev/disk/by-id" ]]; then
|
if [[ -d "/dev/disk/by-id" ]]; then
|
||||||
local id_match
|
local id_match=\$(find /dev/disk/by-id/ -type l -not -name "wwn-*" -not -name "nvme-eui*" -printf "%p %l\n" | grep -m1 "/\$disk_name\$" | awk '{print \$1}')
|
||||||
id_match=\$(find /dev/disk/by-id/ -type l -not -name "wwn-*" -not -name "nvme-eui*" -printf "%p %l\n" | grep -m1 "/\$disk\$" | awk '{print \$1}')
|
[[ -n "\$id_match" ]] && disk_id="\$id_match"
|
||||||
[[ -n "\$id_match" ]] && disk_id="\$id_match"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Health Assessment (Requires smartctl)
|
# Health
|
||||||
local health="N/A"
|
local health="unknown"
|
||||||
if echo "${LIVE_TARGET_PASSWORD}" | sudo -S smartctl -H "\$dev_path" >> "${REMOTE_STDOUT}" 2>> "${REMOTE_STDERR}"; then
|
if echo "${LIVE_TARGET_PASSWORD}" | sudo -S smartctl -H /dev/\$disk_name 2>/dev/null | grep -i "PASSED"; then
|
||||||
if smartctl -H "\$dev_path" | grep -iq -e "PASSED" -e "OK" >> "${REMOTE_STDOUT}" 2>> "${REMOTE_STDERR}"; then
|
disk_health="Passed"
|
||||||
health="PASSED"
|
elif echo "${LIVE_TARGET_PASSWORD}" | sudo -S smartctl -H /dev/\$disk_name 2>/dev/null | grep -i "FAILED"; then
|
||||||
else
|
disk_health="Failed"
|
||||||
health="FAILED"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local obj=\$(jq -n --arg n "\$disk" --arg dp "\$dev_path" --arg t "\$disk_type" \
|
local obj=\$(jq -n \
|
||||||
--arg h "\$health" --arg id "\$disk_id" --arg s "\$size_gb" \
|
--arg n "\${disk_name}" \
|
||||||
'{name: \$n, device_path: \$dp, type: \$t, health: \$h, id: \$id, size_gb: \$s}')
|
--arg t "\${disk_type}" \
|
||||||
|
--arg tr "\${disk_transport}" \
|
||||||
|
--arg h "\${disk_health}" \
|
||||||
|
--arg s "\${disk_size}" \
|
||||||
|
--arg i "\${disk_id}" \
|
||||||
|
'{name: \$n, type: \$t, transport: \$tr, health: \$h, size: \$s, id: \$i}')
|
||||||
|
|
||||||
disks=\$(echo "\$disks" | jq --argjson obj "\$obj" '. += [\$obj]')
|
disks=\$(echo "\$disks" | jq --argjson obj "\$obj" '. += [\$obj]')
|
||||||
|
|
||||||
done < <(lsblk -d -n -o NAME -e 7,11,252) # Exclude loop(7), sr(11), zram(252)
|
done < <(lsblk -d -n -o NAME -e 7,11,252)
|
||||||
|
|
||||||
append_to_report "disks" "\$disks"
|
append_to_report "disks" "\$disks"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user