#!/bin/sh -f

cd $INST_DATADIR/$PKG/reloc
module=modules/fwmod.5.5.o

now=`date +%y%m%d-%H:%M.%S`
product="Solstice FireWall-1"
version="v3.0"
hpux=0
aix=0
tmpdir=$FW_PKGSAV
OSREL=`/usr/bin/uname -r | sed 's/\./\ /' | awk '{print $1}'`

#
# default installation directory
#
if [ $OSREL -eq 5 ]; then
	FWDIR=/opt/SUNWfw
	solaris2=1
	sunos4=0	
else
	FWDIR=/usr/local/fw
	solaris2=0
	sunos4=1
fi
#
# tailor no-CR echo
#
if [ "`echo -n`" = "-n" ]; then
    # sysv echo
    DN=""
    BC="\c"
else
    # bsd echo
    DN="-n"
    BC=""
fi

size=`/usr/ucb/du -s| awk '{print $1}'`
ans=i
vprefix='$VARDIR'
pprefix='/tmp/fw-1'

export now module product version solaris2 hpux FWDIR size ans vprefix sunos4
export tmpdir pprefix aix

#
# some needed aliases
#

if [ `/usr/ucb/whoami` != "root" ]; then
	scripts/checkid $1
fi

scripts/whichprod 
scripts/readprod $1
firewall=`grep -i FireWall $1 | awk -F\= '{print $2}'`
scripts/fwexists $1
scripts/guirunning $1

if [ -f $FWDIR/conf/objects.C ]; then
	echo ""
    echo "---------------------------------------"
    echo "Found prior installation of the product"
	echo "Do you want to upgrade the software (use old configuration and log files) (y/n) [y]?"
	read dans
	if [ "X$dans" = "Xy" -o "X$dans" = "X" ]; then
		echo "Upgrading $product"
		ans="u"
		scripts/saveconf	
		echo " "
        echo "The rule bases of Firewall-1 management server are located"
        echo "in a single file called rulebases.fws. You may now merge"
        echo "your existing rule bases into this file."
        echo "At any later time you may do this by running fwm -g file.W."
        echo " "
 
        echo $DN "Do you want to convert your rule bases? (y/n) [y] ? "
        read Yn
		echo "Yn=$Yn" >> $1
	fi
fi
	
if [ -x $FWDIR/bin/fwstop ]; then
	echo "Shutdown=1" >> $1
else
	echo "Shutdown=0" >> $1
fi

scripts/getfwlink $1
scripts/getgroup $1
if [ "$firewall" = 1 ]; then
	scripts/getrc $1
	scripts/getipfwd $1
fi
echo "Ans=$ans" >> $1
echo "FWDIR=$FWDIR" >> $1
exit 0

interrupt:
	exit 1

