aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xshare/hydractl/hwinfo76
1 files changed, 76 insertions, 0 deletions
diff --git a/share/hydractl/hwinfo b/share/hydractl/hwinfo
new file mode 100755
index 0000000..e15c456
--- /dev/null
+++ b/share/hydractl/hwinfo
@@ -0,0 +1,76 @@
+#!/bin/bash
+#
+# Gather hardware information and dump into a folder.
+#
+
+# Load.
+source $APP_BASE/lib/hydra/functions || exit 1
+hydra_config_load
+
+# Parameters
+BASENAME="`basename $0`"
+
+# This command could be converted to a "hydra <hydra> hwinfo" fact collector, storing results
+# at $HYDRA_FOLDER/config/hardware if we had a way to uniquelly determine hardware UUID, independent
+# from the operating system.
+#
+# Some references that might help:
+#
+# https://stackoverflow.com/questions/35883313/dmidecode-product-uuid-and-product-serial-what-is-the-difference
+# https://wiki.debian.org/HowToIdentifyADevice/System
+# https://unix.stackexchange.com/questions/211327/get-the-same-uuid-on-different-linux-distributions#211398
+# https://stackoverflow.com/questions/10152762/best-way-to-get-machine-id-on-linux#10152797
+# https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.0.0.pdf
+#
+# Some files to look around:
+#
+# /sys/class/dmi/id/board_serial
+# /sys/class/dmi/id/product_uuid
+# /var/lib/dbus/machine-id
+#
+# This would work in some systems, while in others wont:
+#
+# manufacturer="`$SUDO dmidecode -s system-manufacturer`"
+# version="`$SUDO dmidecode -s system-version`"
+#
+# Best way would either get a UUID from BIOS or build our own, manual database with arbitrary generated UUIDs.
+
+# Sudo config
+if [ "`whoami`" != 'root' ]; then
+ SUDO="sudo"
+fi
+
+if which lshw &> /dev/null; then
+ $SUDO lshw #> lshw.txt
+ #$SUDO lshw --json > lshw.json
+ #$SUDO lshw --xml > lshw.xml
+fi
+
+if which lscpu &> /dev/null; then
+ $SUDO lscpu #> lscpu.txt
+fi
+
+if which cpuid &> /dev/null; then
+ $SUDO cpuid #> cpuid.txt
+fi
+
+if which dmidecode &> /dev/null; then
+ $SUDO dmidecode #> dmidecode.txt
+ #$SUDO dmidecode --dump-bin dmidecode.bin
+fi
+
+if which lspci &> /dev/null; then
+ $SUDO lspci #> lspci.txt
+fi
+
+if which lsusb &> /dev/null; then
+ $SUDO lsusb #> lsusb.txt
+fi
+
+if which lsblk &> /dev/null; then
+ $SUDO lsblk #> lsblk.txt
+fi
+
+if which hwinfo &> /dev/null; then
+ $SUDO hwinfo #> hwinfo.txt
+fi