#! /bin/sh
# dump assorted information of use in debugging
# Copyright (C) 1998, 1999  Henry Spencer.
# 
# 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.  See <http://www.fsf.org/copyleft/gpl.txt>.
# 
# 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.
#
# RCSID $Id: barf,v 1.26 1999/04/10 22:51:26 henry Exp $

PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin
export PATH

KERNSRC=${KERNSRC-/usr/src/linux}
LOGS=${LOGS-/var/log}

exec 2>&1		# stderr on stdout, so errors go into main output

# try to figure out where logs are
if test -r $LOGS/messages
then
	klog=$LOGS/messages
else
	klog=$LOGS/syslog
fi
if test -r $LOGS/secure
then
	plog=$LOGS/secure
else
	plog=$LOGS/debug
fi

# advanced shell deviousness to get dividers into output
_________________________() {
	$1	# something to do nothing and not echo anything
}

hostname ; date
set -x
_________________________
cat /proc/net/ipsec_eroute
_________________________
cat /proc/net/ipsec_spi
_________________________
cat /proc/net/ipsec_spigrp
_________________________
netstat -nr
_________________________
cat /proc/net/ipsec_tncfg
_________________________
ipsec auto --status
_________________________
ifconfig -a
_________________________
hostname --fqdn
_________________________
hostname --ip-address
_________________________
ipsec _keycensor /etc/ipsec.conf
_________________________
ipsec _secretcensor /etc/ipsec.secrets
_________________________
cat /proc/net/dev
_________________________
cat /proc/net/route
_________________________
uname -a
_________________________
cat /proc/version
_________________________
if test -r /etc/redhat-release
then
	cat /etc/redhat-release
fi
_________________________
cat /proc/net/ipsec_version
_________________________
ipfwadm -F -l
_________________________
ipfwadm -I -l
_________________________
ipfwadm -O -l
_________________________
ipfwadm -M -l
_________________________
cat /proc/modules
_________________________
cat /proc/meminfo
_________________________
ls -l /dev/ipsec*
_________________________
ls -l /proc/net/ipsec_*
_________________________
if test -f $KERNSRC/.config
then
	egrep IP $KERNSRC/.config
fi
_________________________
cat /etc/syslog.conf
_________________________
if test -f $LOGS/kern.debug
then
	tail -100 $LOGS/kern.debug
fi
_________________________
sed -n `egrep -n 'Starting FreeS/WAN' $klog | sed -n '$s/:.*//p'`,'$'p $klog |
	egrep -i 'ipsec|klips|pluto|xxx' |
	case "$1" in
	--short)	tail -500	;;
	*)		cat		;;
	esac
_________________________
sed -n `egrep -n 'Starting Pluto' $plog | sed -n '$s/:.*//p'`,'$'p $plog |
	egrep -i 'pluto' |
	case "$1" in
	--short)	tail -500	;;
	*)		cat		;;
	esac
_________________________
date
