#!/bin/sh -e
#
# Report the detected HW

if [ -x /sbin/discover ] ; then
	/sbin/discover -f "info: $0: discover: %m;%S;%D;%V;%M;%d\n" all || true
else
	echo "error: $0: Unable to find /sbin/discover"
fi

LSPCI=/sbin/lspci
if [ -x /usr/bin/lspci ] ; then
    LSPCI=/usr/bin/lspci # This is the location in Sarge [2005-01-30]
fi

if [ -x $LSPCI ] ; then
	(
		$LSPCI -v -t || true
		$LSPCI -n || true
		$LSPCI -v || true
		echo "For use with 'lspci -F':"
		$LSPCI -x || true
	)| sed "s%^%info: $0: lspci: %"
else
	echo "error: $0: Unable to find $LSPCI"
fi

if [ -x /sbin/lsmod ] ; then
	/sbin/lsmod | sed "s%^%info: $0: lsmod: %"
else
	echo "error: $0: Unable to find /sbin/lsmod"
fi

for file in cpuinfo ioports iomem interrupts meminfo ; do
	if [ -e /proc/$file ] ; then
		cat /proc/$file | sed "s%^%info: $0: $file: %"
	else
		echo "error: $0: Unable to find /proc/$file"
	fi
done

disks=`cat /proc/partitions|egrep 'ide|scsi'|awk '{print $4}'|grep '/disc'|sed 's%^%/dev/%'`
for disk in $disks ; do
	/sbin/hdparm -i $disk 2>&1 |  sed "s%^%info: $0: hdparm: %"
done

if [ -x /usr/sbin/dmidecode ] ; then
    /usr/sbin/dmidecode | sed "s%^%info: $0: dmidecode: %"
else
    echo "error: $0: Unable to find /usr/sbin/dmidecode"
fi
