#!/bin/bash
# Also works with ksh and ash, leave the above statement out 
# if using tcsh or csh.

# SURVEY - Dump all system info
# This file is part of survey - a program to Dump all system file info
# Copyright (C) 1994-99 Everett W. Holland, Jr.
#         <everett@roanoke.infi.net>
#
#    This program is free software; you can redistribute it and/or
#    modify it under the terms of the GNU General Public License as 
#    published by the Free Software Foundation; either version 2 of the
#    License, or (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#

# Uncomment the next line & the last line to pipe the results to 'less'.
#(
if [ "" != "`/bin/domainname`" ]
then
 echo ++++ INFORMATION FOR `hostname`  ON DOMAIN `domainname` AT `date`
else
 echo ++++ INFORMATION FOR `hostname` ON `date`
 echo ++++ The domainname is not set...  ++++
fi
echo 
echo ++++ LIST SYSTEM/VENDOR VERSION INFO:  ++++    
uname -a
if [ -f /etc/redhat-release ]
then
	echo RedHat Linux system release file - /etc/redhat-release
	cat /etc/redhat-release
	echo RedHat Linux release - rpm -q -a \| grep redhat
	rpm -q -a | grep redhat
fi
if [ -d /var/lib/LST ]
then
	echo Caldera OpenLinux release - rpm -q -a \| grep CalderaOpen\|COL
	rpm -q -a | egrep CalderaOpen\|COL
	echo Caldera Base Version - /var/lib/LST/BASEVERSION:
	cat /var/lib/LST/BASEVERSION
fi
if [ -f /etc/debian_version ]
then
	echo Debian Linux system release file - /etc/debian_version
	cat /etc/debian_version
fi
if [ -f /sbin/SuSEconfig ]
then
	echo This is a SuSE Linux system - /sbin/SuSEconfig exists
fi
if [ -d /var/adm/packages ]
then
	echo This is a Slackware Linux system - /var/adm/packages exists
fi
echo -e '\n     ++++  DISK DRIVE Statistics:  +++++\n'
echo '++++     Disk Free Space       +++++'
df
echo 
echo '++++   The filesystem table: /etc/fstab   +++++'
cat /etc/fstab
if [ -f /etc/disktab ]
then
  echo -e '\n++++ The Disk Partition Table: /etc/disktab +++++'
  cat /etc/disktab
fi
if [ -w /etc/passwd ]
then
   echo ++++ Use fdisk to list Partition Tables: fdisk -l +++++
   /sbin/fdisk -l
fi
echo -e '\n++++  CONSOLE STARTUP MESSAGES: /bin/dmesg  +++++'
/bin/dmesg
  echo -e '\n\n\n     ++++  /PROC & OTHER HARDWARE Config:  +++++\n\n'
echo -e '\n++++  DMA usage: cat /proc/dma   +++++'
cat /proc/dma
echo -e '\n++++  Interrupt (IRQ) Usage: cat /proc/interrupts   +++++'
cat /proc/interrupts
echo -e '\n++++  IRQ usage while booting: dmesg\|grep -i irq  +++++'
/bin/dmesg | grep -i irq
echo -e '\n++++  I/O Port Usage: cat /proc/ioports   +++++'
cat /proc/ioports
echo -e '\n++++  Module Usage: cat /proc/modules   +++++'
cat /proc/modules
echo -e '\n++++  Your LINUX Version: cat /proc/version   +++++'
cat /proc/version
echo -e '\n++++  CPU Information: cat /proc/cpuinfo   +++++'
cat /proc/cpuinfo
echo -e '\n++++  MEMORY and SWAP Usage: cat /proc/meminfo   +++++'
cat /proc/meminfo
echo -e '\n++++  Avail. Filesystem TYPES: cat /proc/filesystems   +++++'
cat /proc/filesystems
echo -e '\n++++  /dev MAJOR Number Usage: cat /proc/devices   +++++'
cat /proc/devices
echo -e '\n++++  IDE Device Info: hdparm /dev/hda   +++++'
if [ `hdparm /dev/hda >/dev/null 2>/dev/null` ]
then
  hdparm /dev/hda
fi
echo -e '\n++++  SCSI Device Info: cat /proc/scsi/scsi  +++++'
cat /proc/scsi/scsi
echo -e '\n++++  PCI Device Info: cat /proc/pci  +++++'
cat /proc/pci
if [ -f /etc/isapnp.conf ]
then
	echo -e '\n ++++ ISA PNP Device Info: cat /etc/isapnp.conf  ++++'
	cat /etc/isapnp.conf
fi
echo -e '\n++++  X-Windows Servers:   ++++'
if [ -f /usr/X11R6/bin/X ]
then
ls -lG /usr/X11R6/bin/X*
fi
if [ -f /var/X11R6/bin/X ]
then
   ls -lG /var/X11R6/bin/X*
else
   if [ -f /etc/X11/X ]
   then
      ls  -lG /etc/X11/X*
   fi
fi
echo -e '\n\n    ++++  X-Windows Configuration file(s):   ++++'
if [ -f /etc/X11/Xconfig ]
then
   echo -e '\n++++   /etc/X11/Xconfig:     ++++'
   cat /etc/X11/Xconfig
fi
if [ -f /etc/Xaccel.ini ]
then
   echo -e '\n++++   /etc/Xaccel.ini:     ++++'
   cat /etc/Xaccel.ini
fi
if [ -f /etc/X11/XF86Config ]
then
   echo -e '\n++++   /etc/X11/XF86Config:     ++++'
   cat /etc/X11/XF86Config
fi
echo -e '\n\n\n++++  Modem, Mouse, CDROM, sound, & Tape devices:   ++++'
( cd /dev;ls -l modem mouse cdr* rmt* st0 aud* dsp* mix* 2>/dev/null; cd - )
  echo -e '\n\n\n        ++++  SOUND Information:  +++++\n\n'
if [ -r /etc/soundconf ]
then
  echo -e '\n++++  Sound Kernel Configuration: cat /etc/soundconf +++++'
  cat /etc/soundconf
else
  echo -e '\n\n ++++ Could not read /etc/soundconf file ... \n\n'
fi
if [ -r /etc/conf.modules ]
then
  echo -e '\n++++  SOUND Module Config.: grep sound /etc/conf.modules   +++++'
  grep sound /etc/conf.modules
else
  echo -e '\n\n ++++ Could not read /etc/conf.modules file ... \n\n'
fi
if [ -r /etc/sysconfig/sound ]
then
  echo -e '\n++++  RedHat SOUND Config.: cat /etc/sysconfig/sound  +++++'
  cat /etc/sysconfig/sound
else
  echo -e '\n\n ++++ Could not read /etc/sysconfig/sound file ... \n\n'
fi
if [ -f /usr/src/linux/drivers/sound/.defines ]
then	
  echo -e '\n++++  Sound Kernel Driver Configuration:  +++++'
  echo ++++  /usr/src/linux/drivers/sound/.defines:   ++++++
  cat /usr/src/linux/drivers/sound/.defines
fi
if [ -r /dev/sndstat ]
then
   echo -e '\n++++  Sound Devices: cat /dev/sndstat   +++++'
   cat /dev/sndstat 2>&1
else
   echo -e '\n+++++ /dev/sndstat is not readable +++++'
   echo 'SOUND may not be available ...    +++++'
fi
if [ -f /etc/.aumixrc ]
then
   echo -e '\n++++  Sound Mixer Config.: cat /etc/.aumixrc  +++++'
   cat /etc/.aumixrc
else
   echo -e '\n+++++ /etc/.aumixrc not found +++++'
fi
  echo -e '\n\n\n        ++++  SYSTEM Files:  +++++\n\n'
echo -e '\n++++ The LILO Configuration Table: lilo.conf +++++'
cat /etc/lilo.conf
if [ -f /etc/lilo.conf.bak ]
then
  echo ++++ The backup LILO Config. Table: /etc/lilo.conf.bak +++++
  cat /etc/lilo.conf.bak
fi
echo -e '\n++++ The Common User Login File: /etc/profile +++++'
cat /etc/profile
echo -e '\n++++    The INIT File: /etc/inittab   +++++'
cat /etc/inittab
if [ -r /etc/syslog.conf ]
then
  echo -e '\n++++ The syslogd Configuration File: /etc/syslog.conf'
  cat /etc/syslog.conf
fi
  echo -e '\n\n\n        ++++  DOSEMU Information:  +++++\n\n'
if [ -r /etc/dosemu.conf ]
then
  echo -e '\n++++ The DOSEMU Configuration File: /etc/dosemu.conf'
  cat /etc/dosemu.conf
  if [ -r /etc/dosemu.users ]
  then
    echo -e '\n++++ The DOSEMU Users File: /etc/dosemu.users'
    cat /etc/dosemu.users
  else
    echo This system has no /etc/dosemu.users file ...
  fi
fi
  echo -e '\n\n\n        ++++  MTOOLS Information:  +++++\n\n'
if [ -r /etc/mtools.conf ]
then
  echo -e '\n++++ The MTOOLS Configuration File: /etc/mtools.conf'
  cat /etc/mtools.conf
fi
  echo -e '\n\n\n        ++++  SECURITY Information:  +++++\n\n'
echo -e '\n++++ The Password File: /etc/passwd +++++'
cat /etc/passwd
echo -e '\n++++ The Group File: /etc/group' +++++
cat /etc/group
if [ -r /etc/shadow ]
then
 echo -e '\n++++ The Shadow Password File: /etc/shadow'
 cat /etc/shadow
else
 if [ -f /etc/shadow ]
 then
   echo -e '\n\n++++ Cannot Read the /etc/shadow file.  ++++\n'
 else
   echo -e '\n\n++++ This system has no /etc/shadow file.  ++++\n'
 fi
fi
echo -e '\n++++ The Internet Configuration File: /etc/inetd.conf'
cat /etc/inetd.conf
if [ -f /etc/printcap ]
then
	echo -e '\n\n\n        ++++  PRINTER Information:  +++++\n\n'
	echo -e '\n++++ The Printer Configuration File: /etc/printcap ++++'
	cat /etc/printcap
	if [ -f /etc/hosts.lpd ]
	then
	echo -e '\n++++ Remote systems that can print here: /etc/hosts.lpd ++++'
	echo -e '\n++++ Also works if you use /etc/hosts.equiv ++++'
	cat /etc/hosts.lpd
	fi
	echo -e '\n++++ The Printer Status: /usr/sbin/lpc status ++++'
	/usr/sbin/lpc status
else
	echo -e '\n\n\n  ++++  NO /etc/printcap FILE FOUND ... ++++\n\n'
fi
  echo -e '\n\n\n        ++++  KERNEL & LOCAL Info:  +++++\n\n'
if [ -f /etc/rc.d/rc.local ]
then
  echo -e '\n++++ The LOCAL System Configuration File: /etc/rc.d/rc.local ++++'
  cat /etc/rc.d/rc.local
fi
if [ -f /root/linux/config.in ]
then
  echo -e '\n++++ Kernel Configuration Options: /root/linux/config.in'
  cat /root/linux/config.in
elif [ -f /usr/src/linux/.config ]
 then
  echo -e '\n++++ Kernel Configuration Options: /usr/src/linux/.config'
  cat /usr/src/linux/.config
 else
  if [ -r /etc/conf.modules ]
  then
   echo -e '\n++++ Kernel Module Options: /etc/conf.modules'
   cat /etc/conf.modules
  fi
 fi
if [ -f /usr/src/linux/include/linux/busmouse.h ]
then
echo ++++ Logitech Busmouse Config. File: /usr/src/linux/include/linux/busmouse.h
grep IRQ /usr/src/linux/include/linux/busmouse.h
fi
  echo -e '\n\n\n        ++++  PACKAGE Information:  +++++\n\n'
if [ -d /var/log/packages ]
then
  echo -e '\n    ++++ SLACKWARE PACKAGES in /var/log/packages:  +++++'
  ls -x /var/log/packages
  echo -e '\n    ++++ SLACKWARE DISK SETS IN /var/log/disk_contents:  +++++'
  ls -x /var/log/disk_contents
elif [ -x /bin/rpm ]
then
  echo  -e '\n  ++++ List of RPM PACKAGES installed  +++++'
  echo "rpm -q --queryformat %-20{NAME}\\b%-10{SIZE}\\b%{SUMMARY}\\n -a |sort"
  rpm -q --queryformat %-20{NAME}\\b%-10{SIZE}\\b%{SUMMARY}\\n -a |sort
elif [ -d /var/lib/dpkg ]
then
  echo  -e '\n  ++++ List of Debian Dpkg PACKAGES installed  +++++'
  dpkg -l
fi
  echo -e '\n\n\n        ++++  PCMCIA INFORMATION:  +++++\n\n'
  echo -e '\n++++ PCMCIA Configuration Options: /home/everett/bin/pcmcia-info +++++'
  /home/everett/bin/pcmcia-info
  echo -e '\n\n\n        ++++  NETWORK INFORMATION:  +++++\n\n'
echo -e '\n++++ The Networking Config. File: /etc/hosts +++++'
cat /etc/hosts
echo -e '\n++++ The netconfig Configuration File: /etc/host.conf +++++'
cat /etc/host.conf
if [ -f /etc/hosts.equiv ]
then
   echo -e '\n++++ The netconfig Security File: /etc/hosts.equiv +++++'
   cat /etc/hosts.equiv
else
   echo -e '\n++++ The /etc/hosts.equiv file does not exist +++++'
   echo -e '\n++++ The Security File: /etc/hosts.allow +++++'
   cat /etc/hosts.allow
   echo -e '\n++++ The Security File: /etc/hosts.deny +++++'
   cat /etc/hosts.deny
fi
if [ -f /etc/resolv.conf ]
then
   echo -e '\n++++ The Internet DNS Table: /etc/resolv.conf +++++'
   cat /etc/resolv.conf
else
   echo -e '\n++++ This system has no /etc/resolv.conf file +++++'
fi
if [ -f /etc/exports ]
then
echo -e '\n++++ The exported Filesystems: /etc/exports +++++'
cat /etc/exports
fi
if [ -f /etc/networks ]
then
  echo -e '\n++++ The Networks: /etc/networks +++++ '
  cat /etc/networks
fi
echo -e '\n++++ Internet Configuration: /sbin/ifconfig -a +++++'
/sbin/ifconfig -a
echo -e '\n++++ Routing Configuration: /sbin/route +++++' 
/sbin/route -n
#echo "Print Install/Update log file??"
#read yn
#if [ $yn = "y" ]
#then
   echo -e '\n\n\n        ++++  Install/Upgrade Information:  +++++\n\n'
   if [ -f /tmp/upgrade.log ]
   then
   echo -e '\n++++ The RedHat Upgrade File: /tmp/upgrade.log +++++'
   cat /tmp/upgrade.log
   else
   echo This system has no /tmp/upgrade.log file
   fi
   if [ -f /tmp/install.log ]
   then
   echo -e '\n++++ The RedHat Upgrade File: /tmp/install.log +++++'
   cat /tmp/install.log
   else
   echo This system has no /tmp/install.log file
   fi
#fi
#) | less 
