#! /bin/csh -f

#
# what are we going to install/config/upgrade ?
# we use a configuration file (conf/options)
# format: description	%	optname		%	type	%	relevant-defaults-names
# after this part, optname and type are set to the option chosen by the user
#

source scripts/aliases

	if (!($?vprefix)) then
		set vprefix="."
		set pprefix="."
	else
		mkdir -p $pprefix/conf
	endif

	@ nfails = 0
	E -n Checking available options.  Please wait.
	source scripts/options
whichprod:
	E -n "Enter your selection (1-$#nums/a): "
	get opt
	if ("X$opt" == X) then
		@ nfails++			# count failures, although we do nothing about them
		goto whichprod		# here.   maybe we will.
	endif
	if ("X$opt" == Xa) goto abort

	unset optname
	set opt=`echo $opt|awk '{ print $1*1 }'`			# if not num, zero it.
	if (($#nums < $opt) || ($opt < 1)) goto whichprod	# in range ?
	set description=`echo $descriptions[$opt]|sed 's/%/ /g'`
	set optname=`echo $optnames[$opt]|sed 's/%/ /g'`
	set type=`echo $types[$opt]|sed 's/%/ /g'`
	set relevant=` `
	if (! $?optname) goto whichprod
	E ""
	E Installing/Configuring $product $description.
	E ""

if ("X$optname" == "XEnterprise Product") then

	set unlimit=1
	set auth=0
	set firewall = 0
	set management = 0

	E ""
	E "Which Component would you like to install ? "
	E "------------------------------------------- "
	E "(1) FireWall & Management Modules"
	E "(2) FireWall Module only"
	E "(3) Management Module only"
	E ""
	E -n "Enter your selection (1-3/a) [1]: "

	get compans

	if ("X$compans" == Xa) goto abort
	if ("X$compans" == X) set compans = 1
	if ("X$compans" == X1 || "X$compans" == X2) then 
		set firewall = 1
		set auth = 1
	endif

	if ("X$compans" == X1 || "X$compans" == X3) then
		set management = 1
	endif

endif

if (("X$optname" == "XFireWall Module") || ("X$optname" == "XInspection Module")) then

	set management = 0
	set firewall = 1	
	if ("X$optname" == "XFireWall Module") then 
		set auth = 1
	else
		set auth = 0
	endif

	E ""
	E "Which $optname would you like to install ? "
	E "------------------------------------------- "
	E "(1) $optname/25"
	E "(2) $optname/50"
	E "(3) $optname (Unlimited)"
	E ""
	E -n "Enter your selection (1-3/a) [3]: "

	get compans

	if ("X$compans" == Xa) goto abort
	if (("X$compans" == X1) || ("X$compans" == X2)) then
		set unlimit = 0
	endif
	if (("X$compans" == X) || ("X$compans" == X3)) then
		set unlimit = 1
	endif
endif


if ("X$optname" == "XSingle Gateway Product") then
	set unlimit = 0
	set firewall = 1
	set management = 1
	set auth = 1
endif

if ("X$optname" == "XEnterprise Management Console Product") then
	set unlimit = 1
	set firewall = 0
	set management = 1
	set auth = 0
endif


	echo "Unlimit=$unlimit" 		> $pprefix/conf/product.conf 
	echo "Auth=$auth" 			>> $pprefix/conf/product.conf 
	echo "Management=$management" 		>> $pprefix/conf/product.conf 
	echo "FireWall=$firewall" 		>> $pprefix/conf/product.conf 

ok:
	exit 0

abort:
	exit 1

