#!/bin/sh

files=''
ldd='no'
gcc='no'
hardware='no'
startup='no'
drivers='no'
symbols='no'
tracer=''

if [ -f /usr/bin/strace ] ; then
	tracer='strace'
fi

if [ -f /bin/strace ] ; then
	tracer='strace'
fi

if [ -f /sbin/strace ] ; then
	tracer='strace'
fi

if [ -f /bin/ldd ] ; then
	ldd='yes'
fi

if [ -f /usr/bin/ldd ] ; then
	ldd='yes'
fi

if [ -f /usr/bin/gcc ] ; then
	gcc='yes'
fi

if [ -f /usr/local/bin/gcc ] ; then
	gcc='yes'
fi

if [ -f config.diag ] ; then
	. ./config.diag
fi

if [ ! -z "$title" ] ; then
	echo $title
fi

if [ ! -z "$strace" ] ; then
	for trace in $strace ; do
		echo
		ls -l $trace
		if [ $ldd = 'yes' ] ; then
			echo
			echo "Library map for " $trace
			ldd $trace
		fi
		if [ $symbols = 'yes' ] ; then
			echo
			nm $trace
		fi
		if [ ! -z "$tracer" ] ; then
			echo
			$tracer $opts $trace 2>&1
		fi
	done
fi

echo
echo -n "System Type: "
uname -s 

echo -n "Achitecture: " 
uname -m 

echo -n "Release:     " 
uname -r

if [ $gcc = 'yes' ] ; then
	echo 
	echo "GCC Information:" 
	gcc -v 2>&1
fi

if [ -f /proc/meminfo ] ; then
	echo 
	echo "Memory:" 
	cat /proc/meminfo 
fi

echo "" 
echo "Disks:" 
df 

if [ $startup = 'yes' ] ; then

	if [ -d /etc/rc.d ] ; then
		echo 
		echo "Services:" 
		ls -l /etc/rc.d 
		if [ -d /etc/rc.d/rc3.d ] ; then
			echo 
			echo "Startup:"
			ls /etc/rc.d/rc3.d 
		fi
	fi
fi

if [ -f config.cache ] ; then
	echo 
	echo "Configuration:" 
	cat config.cache
fi

if [ -f config.cc ] ; then
	echo 
	echo "Compiler:" 
	cat config.cc
fi

if [ ! -z "$files" ] ; then
	for file in $files ; do
		if [ -f $file ] ; then
			echo
			echo "Found: " $file
			echo
			cat $file
		fi
	done
fi

if [ $drivers = 'yes' ] ; then

	if [ -f /proc/modules ] ; then
		echo 
		echo "Modules:" 
		cat /proc/modules
	fi
fi

if [ $hardware = 'yes' ] ; then

	if [ -f /proc/devices ] ; then
		echo 
		echo "Devices:" 
		cat /proc/devices 
	fi

	if [ -f /proc/ioports ] ; then
		echo 
		echo "Ports:" 
		cat /proc/ioports 
	fi

	if [ -f /proc/interrupts ] ; then
		echo 
		echo "Interrupts:" 
		cat /proc/interrupts 
	fi

	if [ -f /proc/dma ] ; then
		echo
		echo "DMA:"
		cat /proc/dma
	fi

	if [ -f /proc/cpuinfo ] ; then
		echo 
		cat /proc/cpuinfo 
	fi
fi

