shared-public-infra/docs/generate-host-info.sh
2023-06-05 17:20:11 +02:00

15 lines
597 B
Bash
Executable file

#!/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