#! /bin/csh -f
#
# Copyright (c) 1993-1996 CheckPoint Software Technologies Ltd.
# All Rights Reserved
#
# THIS IS AN UNPUBLISHED PROPRIETARY SOURCE CODE OF CHECKPOINT SOFTWARE
# TECHNOLOGIES LTD. The copyright notice above does not evidence any actual
# or intended publication of such source code.
#
# $Header: /fw/cvs/fw-1/fwutil/fwinfo.csh,v 1.8.2.1 1996/04/11 09:59:14 yoav Exp $
#
set solaris2 = 0
set sunos4 = 0
set hpux = 0
if ( -f /kernel/genunix || -f /kernel/unix ) then
	set solaris2 = 1
	set path = ( /usr/bin /usr/ucb /usr/sbin )
	set module = modules/fwmod.5.3.o
	alias dodf df -k
	alias dops /usr/ucb/ps auxww
else if (-f /hp-ux) then
	set hpux = 9
	set path = (/bin /usr/bin /etc)
	set module = modules/fwmod.hpux9.o
	alias dodf bdf
	alias dops ps -ef
else if (-f /stand/vmunix) then
	set hpux = 10
	set path = (/bin /usr/bin /usr/sbin /etc)
	set module = modules/fwmod.hpux10.o
	alias dodf bdf
	alias dops ps -ef
else
	set sunos4 = 1
	set path = ( /usr/bin /usr/ucb /bin /usr/etc )
	set module = modules/fwmod.4.1.3.o
	alias dodf df
	alias dops ps auxww
endif

alias header "echo '' ; echo ============================================== ; echo \!* ; echo ============================================== ; echo ''"
alias invoke "echo Issuing \'\!*\' : ; echo '' ; \!* |& cat"
alias docrash "echo Issuing crash \'\!*\' : ; echo '' ; echo \!* | crash |& cat; echo ''"

if (! $?FWDIR) set FWDIR = /etc/fw

echo '************************************************************************'
echo '                    FireWall-1 Support Information.                     '
echo '                                                                        '
echo '  When needed, you will be asked to send the output of this program to  '
echo '                        support@CheckPoint.COM                          '
echo '                                                                        '
echo '  In order to do it, you might want to invoke the following commands:   '
echo '                                                                        '
echo '  1) $FWDIR/bin/fwinfo | compress | uuencode fwinfo.Z > /tmp/fwinfo.uue '
echo '                                                                        '
echo '  2) Attach /tmp/fwinfo.uue to a mail for support@CheckPoint.COM        '
echo '                                                                        '
echo '************************************************************************'

header System Information
invoke date
echo ""
invoke hostname
echo ""
invoke uname -a
echo ""
invoke w -u
echo ""
invoke dops
echo ""
if ($solaris2) then
	invoke swap -s
	echo ""
	invoke swap -l
	echo ""
	crash < /dev/null > /dev/null
	if ($status == 0) then
		docrash kmastat
		echo ""
	endif
	invoke modinfo
	echo ""
else if ($sunos4) then
	invoke pstat -s
	echo ""
	invoke modstat
	echo ""
else if ($hpux) then
	invoke swapinfo -mta
	echo ""
	if ($hpux == 10) then
		invoke swapinfo -Mta
		echo ""
	endif
endif
invoke env
echo ""
invoke set
echo ""
invoke dodf
echo ""
invoke dodf $FWDIR
echo ""
if ($hpux) then
	invoke model
	echo ""
	if ($hpux == 9) then
		invoke nodename
		echo ""
		invoke ioscan -f
		echo ""
	else
		invoke ioscan -fn
		echo ""
		invoke ioscan -fnk
		echo ""
	endif
endif

header IP Interfaces
if ($hpux) then
	invoke lanscan
	set iflist = (lo0 `lanscan | tail +3 | awk '{print $5}'`)
	foreach if ($iflist)
		echo ""
		invoke ifconfig $if
	end
else
	invoke ifconfig -a
endif
echo ""
invoke $FWDIR/bin/fw ctl iflist

header Netstat Information
invoke netstat -rn
echo ""
invoke netstat -i
echo ""
invoke netstat -m
echo ""
invoke netstat -s
echo ""
invoke netstat -a
echo ""

if ($solaris2) then
	header Check Forwarding Flag
	invoke ndd /dev/ip ip_forwarding
endif

header FireWall-1 Version Information
invoke $FWDIR/bin/fw ver
alias getrcs strings -
foreach prog (bin/fw bin/fwui $module)
	invoke getrcs $FWDIR/$prog | grep 'Header: \/fw' | sed -e 's/^.*Header: //' | sed -e 's/[a-z]* Exp.*$//'
	echo ""
	if ($solaris2) then
		invoke /usr/ucb/sum $FWDIR/$prog
	else
		invoke sum $FWDIR/$prog
	endif
	echo ""
end

header FireWall-1 Status
invoke $FWDIR/bin/fw stat -i -l
echo ""

header FireWall-1 Tables
invoke $FWDIR/bin/fw tab -u
echo ""

header FireWall-1 License
invoke $FWDIR/bin/fw printlic
echo ""
invoke $FWDIR/bin/fw printlic -k
echo ""

header FireWall-1 Statistics
invoke $FWDIR/bin/fw ctl pstat
echo ""

header FireWall-1 Configuration, Database and State
invoke ls -lsigRL $FWDIR
echo ""
ln -s $FWDIR/bin/gunzip /tmp/gzip.$$
echo ""
set files = `(cd $FWDIR ; echo conf/{*.{C,W,pf,cl,exp},external.if*,masters*,xlate.conf*,fw.license*,fwauth.*} state/* database/* lib/{*.{def,C,h},control.map*})`
(cd $FWDIR ; invoke tar cf - $files | /tmp/gzip.$$ | uuencode fw.tar.gz ) |& cat
/bin/rm -rf /tmp/gzip.$$
echo ""

header Hosts
invoke head -200 /etc/hosts
echo ""
invoke ypcat hosts | head -200
echo ""

header Services
invoke cat /etc/services
echo ""
invoke ypcat services
echo ""

