Release new version 0.17.1
[grml-hwinfo.git] / grml-hwinfo
index 0281e39..97ad572 100755 (executable)
@@ -160,6 +160,33 @@ disk_info() {
   disklist=$(lsblk -nd -o NAME -e 7,11)
 }
 
+# return list of all network devices in array "${niclist[@]}"
+get_network_devices() {
+  local interface
+  niclist=()
+  for interface in /sys/class/net/* ; do
+      [ -e "${interface}" ] || continue
+      interface=$(basename "${interface}")
+      # [ "${interface}" = "lo" ] && continue
+      niclist+=("${interface}")
+  done
+}
+
+# Check if X server is running
+#
+# If xset is missing, we rely on the existence of the $DISPLAY variable.
+NO_DISPLAY=0
+if exectest xset ; then
+  if ! timeout 1s xset q &>/dev/null ; then
+    NO_DISPLAY=1
+  fi
+elif [ -z "${DISPLAY}" ] ; then
+    NO_DISPLAY=1
+fi
+
+if [ "${NO_DISPLAY}" -eq 1 ] ; then
+  $_opt_quiet || echo "W: Running without X server. Not all data will be collected."
+fi
 
 cd "${OUTDIR}" || exit 1
 (
@@ -180,6 +207,10 @@ cd "${OUTDIR}" || exit 1
   fi
   uname -a > ./uname
 
+  # inxi
+  exectest inxi  && inxi -F -xx > ./inxi 2>./inxi.error
+  exectest inxi  && inxi -FJ --admin > ./inxi_admin 2>./inxi_admin.error
+
   # disks / devices
   [ -f /proc/scsi/scsi ] && cat /proc/scsi/scsi > scsi
   exectest lspci && lspci -nn > ./lspci
@@ -236,6 +267,23 @@ cd "${OUTDIR}" || exit 1
   exectest ifconfig && ifconfig -v -a > ./ifconfig
   exectest route    && route -n       > ./route
 
+  # net stuff, ethtool
+  if exectest ethtool ; then
+    get_network_devices
+    for dev in "${niclist[@]}" ; do
+      ethtool          "${dev}" > ethtool_"${dev}"
+      case "${dev}" in
+        "lo")
+          # skip the loopback device, `ethtool --driver lo` fails with:
+          # "Cannot get driver information: Operation not supported"
+          ;;
+        *)
+          ethtool --driver "${dev}" > ethtool_"${dev}_driver"
+          ;;
+      esac
+    done
+  fi
+
   # net stuff, iproute:
   exectest ip && ip addrlabel list > ip_addrlabel
   exectest ip && ip addr show      > ip_addr
@@ -292,7 +340,7 @@ cd "${OUTDIR}" || exit 1
   dpkg -S "/boot/vmlinuz-$(uname -r)" >> running_kernel 2>>running_kernel.error
 
   # X stuff
-  if [ -n "${DISPLAY}" ] ; then
+  if [ "${NO_DISPLAY}" -eq 0 ] ; then
     exectest xviddetect  && xviddetect         > ./xviddetect
     exectest xvidtune    && xvidtune -show     > ./xdivtune
     exectest xrandr      && xrandr             > ./xrandr