#! /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.35 1999/11/08 00:56:14 henry Exp $

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

# message patterns that start relevant parts of logs
fstart='Starting FreeS/WAN'
pstart='Starting Pluto'

# make sure output is in English
LANG=
LC_ALL=
export LANG LC_ALL

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

# try to guess 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
_________________________
ipsec --version | sed 1q
_________________________
hostname --fqdn
_________________________
hostname --ip-address
_________________________
uptime
_________________________
ipsec _include /etc/ipsec.conf | ipsec _keycensor
_________________________
ipsec _include /etc/ipsec.secrets | ipsec _secretcensor
_________________________
cat /proc/net/dev
_________________________
cat /proc/net/route
_________________________
cat /proc/sys/net/ipv4/ip_forward
_________________________
uname -a
_________________________
cat /proc/version
_________________________
if test -r /etc/redhat-release
then
	cat /etc/redhat-release
fi
_________________________
cat /proc/net/ipsec_version
_________________________
ipchains -L
_________________________
ipfwadm -F -l
_________________________
ipfwadm -I -l
_________________________
ipfwadm -O -l
_________________________
ipchains -M -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|NETLINK' $KERNSRC/.config
fi
_________________________
ls -l ${IPSECDIR-/usr/local/lib/ipsec}
_________________________
cat /etc/syslog.conf
_________________________
if test -f $LOGS/kern.debug
then
	tail -100 $LOGS/kern.debug
fi
_________________________
sed -n `(echo 1: ; egrep -n "$fstart" $klog) | sed -n '$s/:.*//p'`,'$'p $klog |
	egrep -i 'ipsec|klips|pluto|xxx' |
	case "$1" in
	--short)	tail -500	;;
	*)		cat		;;
	esac
_________________________
sed -n `(echo 1: ; egrep -n "$pstart" $plog) | sed -n '$s/:.*//p'`,'$'p $plog |
	egrep -i 'pluto' |
	case "$1" in
	--short)	tail -500	;;
	*)		cat		;;
	esac
_________________________
date
