#!/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'.
#(
echo -e  '++++ ALL SYSTEM INFORMATION - survey-0.95  ++++\n\n'
if [ "" != "`/bin/domainname 2>/dev/null`" ]
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 Open\|COL
	rpm -q -a | egrep Open\|COL
	echo Caldera Base Version - /var/lib/LST/BASEVERSION:
	cat /var/lib/LST/BASEVERSION
	echo Caldera Main Version - /etc/.issue:
	cat /etc/.issue
fi
if [ -f /sbin/SuSEconfig ]
then
	echo This is a SuSE Linux system - /sbin/SuSEconfig exists
	echo SuSE Release Version: /var/adm/inst-log/info
	cat /var/adm/inst-log/info	
fi
if [ -d /usr/lib/setup ]
then
	echo This is a Slackware Linux system - /usr/lib/setup exists
	echo The Slackware Version - /usr/lib/setup\|grep version
	ls /usr/lib/setup | grep version
fi
if [ -d /var/lib/corel_setup ]
then
	echo This is a Corel Linux system - /var/lib/corel_setup exists
	echo Debian Linux system release file - /etc/debian_version
	cat /etc/debian_version
	echo The Corel Linux Version - /etc/issue
	cat /etc/issue
else
	if [ -f /etc/debian_version ]
	then
		echo This is a Debian Linux system
		echo Debian Linux system release file - /etc/debian_version
		cat /etc/debian_version
	fi
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
   if fdisk -l >/dev/null 2>&1
   then
     echo ++++ Use fdisk -l to list Partition Tables:  +++++
     /sbin/fdisk -l 2>&1
   else
     echo ++++ Use fdisk -l /dev/### to list Partition Tables:  +++++
     for i in `cd /dev;/bin/ls hd? sd? ed? rd/c0d? rd/c1d? 2>/dev/null`
     do
     /sbin/fdisk -l /dev/$i 2>/dev/null
     done
   fi
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
if hdparm /dev/hda 2>/dev/null
then
  echo -e '\n++++  IDE Device Info: hdparm /dev/hda   +++++'
  hdparm /dev/hda 2>&1
  hdparm /dev/hdb 2>&1
fi
echo -e '\n++++  SCSI Device Info: cat /proc/scsi/scsi  +++++'
cat /proc/scsi/scsi
if [ -x /sbin/lspci ]
then
echo -e '\n++++  PCI Device Info: lspci -v   +++++'
/sbin/lspci -v
else
echo -e '\n++++  Old PCI Device Info: cat /proc/pci  +++++'
cat /proc/pci
fi
if [ -f /proc/tty/driver/serial ]
then
	echo -e '\n ++++ Serial Ports info: /proc/tty/driver/serial  +++++'
	head /proc/tty/driver/serial
fi
if [ -f /proc/sys/dev/cdrom/info ]
then
	echo -e '\n ++++ CDROM Drive info:/proc/sys/dev/cdrom/info  +++++'
	cat /proc/sys/dev/cdrom/info
fi
if  `hinv >/dev/null 2>&1` 
then
	echo -e '\n ++++ Hardware Inventory: hinv - by Raju Mathur  ++++'
	hinv 2>/dev/null
fi
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/sysconfig/desktop ]
then
   echo -e '\n++++ RedHat Desktop Default /etc/sysconfig/desktop:  ++++'
   cat /etc/sysconfig/desktop
fi
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* ftape fb sg0 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
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 /etc/rc.d/boot.local ]
then
  echo -e '\n++++ The SuSE LOCAL System Configuration File: /etc/rc.d/boot.local ++++'
  cat /etc/rc.d/boot.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
 fi
 if [ -r /etc/conf.modules ]
 then
   echo -e '\n\n\n++++ KERNEL MODULE OPTIONS FILE: /etc/conf.modules ++++\n\n'
   cat /etc/conf.modules
 fi
if [ -f /etc/sysconfig/mouse ]
then
echo ++++ Mouse Config. File: /etc/sysconfig/mouse
cat /etc/sysconfig/mouse
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: pcmcia-info +++++'
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 +++++'
fi
if [ -f /etc/hosts.allow ]
then
   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
else
   echo -e '\n++++ The /etc/hosts.allow file does not exist +++++'
fi
if [ -d /etc/sysconfig ]
then
  echo -e '\n++++ The Redhat Network Configuration Files:  +++++'
  echo -e '++ /etc/sysconfig/network: ++'
  cat /etc/sysconfig/network
  if [ -r /etc/sysconfig/static-routes ]
  then
    echo -e '++ /etc/sysconfig/static-routes: ++'
    cat /etc/sysconfig/static-routes
  fi
  if [ -f /etc/sysconfig/network-scripts/ifcfg-eth0 ]
  then
    echo -e '++ /etc/sysconfig/network-scripts/ifcfg-eth*: ++'
    cat /etc/sysconfig/network-scripts/ifcfg-eth*
  fi
fi
if [ -f /etc/rc.d/rc.inet1 ]
then
echo -e '\n++++ From Slackware Network Configuration File:  +++++'
echo -e '++ /etc/rc.d/rc.inet1: ++'
grep IPADDR= /etc/rc.d/rc.inet1
grep NETWORK= /etc/rc.d/rc.inet1
grep GATEWAY= /etc/rc.d/rc.inet1
grep NETMASK= /etc/rc.d/rc.inet1
fi
if [ -f /etc/rc.config ]
then
echo -e '\n++++ From SuSE Network Configuration File:  +++++'
echo -e '++ /etc/rc.config: ++'
grep "for one" /etc/rc.config
grep NETCONFIG= /etc/rc.config
grep DEVTYPE_0= /etc/rc.config
grep DEVTYPE_1= /etc/rc.config
grep IPADDR_0= /etc/rc.config
grep IPADDR_1= /etc/rc.config
grep IFCONFIG_0= /etc/rc.config
grep IFCONFIG_1= /etc/rc.config
grep SETUPDUMMYDEV= /etc/rc.config
grep FQHOSTNAME= /etc/rc.config
grep SEARCHLIST= /etc/rc.config
grep NAMESERVER= /etc/rc.config
fi
if [ -f /etc/init.d/network ]
then
echo -e '\n++++ The Debian/Corel Network Configuration File:  +++++'
cat  /etc/init.d/network 
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 Services Offered: /bin/netstat -uta +++++'
/bin/netstat -uta
echo ++++ This is decided by the file /etc/inetd.conf, which follows:
echo -e '\n++++ The Internet Configuration File: /etc/inetd.conf'
cat /etc/inetd.conf
/bin/netstat -uta
echo -e '\n++++ Internet Configuration: /sbin/ifconfig -a +++++'
/sbin/ifconfig -a
echo -e '\n++++ Routing Configuration: /sbin/route -n +++++' 
/sbin/route -n
if route -e >/dev/null 2>/dev/null
then
echo -e '\n++++ Another Routing Display: /sbin/route -e +++++' 
/sbin/route -e
fi
if [ -f /etc/ppp/if-up.local ]
then
  echo -e '\n++++ The Local ppp options file: /etc/ppp/if-up.local +++++ '
  cat /etc/ppp/if-up.local
fi
#echo "Print Install/Update log file??"
#read yn
#if [ $yn = "y" ]
#then
   echo -e '\n\n\n        ++++  Install/Upgrade Information:  +++++\n\n'
   if [ -r /tmp/upgrade.log ]
   then
   echo -e '\n++++ The RedHat Upgrade File: /tmp/upgrade.log +++++'
   cat /tmp/upgrade.log
   else
   echo Cannot read any /tmp/upgrade.log file
   fi
   if [ -r /tmp/install.log ]
   then
   echo -e '\n++++ The RedHat Upgrade File: /tmp/install.log +++++'
   cat /tmp/install.log
   else
   echo Cannot read any /tmp/install.log file
   fi
#fi
#) | less 
