shared-public-infra/docs/generate-host-info.sh

15 lines
597 B
Bash
Raw Normal View History

2023-06-05 15:20:08 +00:00
#!/usr/bin/env bash
hostname=$(echo "$2")
report="$hostname.md"
lstopo="$hostname.lstopo.svg"
echo -e "# ${hostname}\n" > "$report"
echo "\`\`\`" >> "$report"
ssh "$1" -- nix-shell -p \'inxi.override { withRecommends = true\; }\' --run \"sudo inxi -F -a -i --slots -xxx -c0 -Z -i -m\" >> "$report"
ssh "$1" -- nix-shell -p hwloc -p dmidecode --run \"sudo lstopo /tmp/$hostname.lstopo.svg\"
scp "$1":/tmp/$hostname.lstopo.svg "$lstopo"
ssh "$1" -- sudo rm /tmp/$hostname.lstopo.svg
echo "\`\`\`" >> "$report"
echo "![hardware topology]($hostname.lstopo.svg)" >> "$report"
echo "wrote $report" >&2