#!/bin/sh
# $Id: setup_dialog.sh,v 1.40.6.1 2006/03/23 16:55:08 billwe Exp $
#  Copyright 2006 Sun Microsystems, Inc. All rights reserved.
#
# Prompt user for setup information.
##########################################

machinearch ()
{
#!/bin/sh
#  $Id: ixiarch.sh,v 10.38 2005/06/20 19:21:26 peterc Exp $
#  Copyright (C) 1996-2005 Tarantella, Inc.
#  This software code contains proprietary information
#  and should be treated as confidential.
#
#  Print canonical syscode for platform

# There are three valid types of command line:
#
# 1.     visionarch
# 2.     visionarch <available codes>...
# 3.	 visionarch [-c|-o]
#
# 1. The architecture is echoed
# 2. The best architecture from the list is returned
# 3. The -c and -o options return just the system Code or the OS type.

# 0) INITIALIZE VARIABLES

# Some of these are historical, but dont cause any harm
PATH=/bin:/usr/bin:/sbin:/usr/sbin:$XDTHOME/bin:$PMWMHOME/bin:$IXIHOME/bin:$PATH


# 1) Arguments
numcodes=0
for i
do
  case $i in
    -c )
      codeonly=1
    ;;
  
    -o )
      osonly=1
    ;;

    -n )
      if [ -z "$codeonly" -a -z "$osonly" ]
      then
	  displayname=1	
      fi
    ;;
 
    * )
      checkcodes="$checkcodes $i"
      numcodes=`expr $numcodes + 1`
    ;;

   esac
done

# fast exit
if [ $numcodes = 1 ]
then
  echo $checkcodes
  exit 0
fi


# 2) MESSAGES
myname=`basename $0`

#  First define some messages.
#  They get overwritten by sourcing from a file, scripts.ll_TT,
#  so there's no need to translate them here.  

#  Messages for the visionarch script.
#  These follow text like "visionarch: !4! ", and may extend to several lines.
msg_xdtarch_no_uname=\
'No uname command found.'
msg_xdtarch_os_cpu=\
'Cannot recognize the Operating System or processor type.'
msg_xdtarch_ver_rel=\
'Cannot calculate version or release.'
msg_xdtarch_no_match=\
'Cannot find matching installed system.'

#  End of messages
# Try to find a language script
posslangfiles=""
for lang in C $IXILANG $PANLANG $LANG
do
  for pathname in $XDTHOME/bin/scripts. $PMWMHOME/bin/scripts. $IXIHOME/bin/scripts. ./scripts.
  do
    posslangfiles="$posslangfiles $pathname.$lang"
  done
done

# see if we can find one of those language files
for f in $posslangfiles
do
  if [ -f $f ]
  then
    . $scriptslangfile			# source it
    break
  fi						
done
  
# 3) TRY UNAME AND SET UP VARIABLES

unamev=`uname -v 2>/dev/null`
if [ $? -ne 0 ]
then
  # This isn't really a UNIX system is it?
  echo >&2  "$myname: !2! $msg_xdtarch_no_uname"
  exit 2
fi

U_SYSTEM=`uname -s 2>/dev/null`  || U_SYSTEM=UNKNOWN
U_RELEASE=`uname -r 2>/dev/null` || U_RELEASE=UNKNOWN
U_VERSION=`uname -v 2>/dev/null` || U_VERSION=UNKNOWN

# Some machines use -m arg to return 'model' rather
# than architecture.  For example, NCR SVR4 returns
# 3433,3434.  On such machines need to use -p which
# returns processor.

for MACHARG in m p
do
    U_MACHINE=`uname -"$MACHARG" 2>/dev/null` || U_MACHINE=UNKNOWN

    # 4)  FIND THE MACHINE
    # Note that we only look for cpu/os combinations our products currently
    # support - if you want better matching, most GNU software comes with
    # a script called 'config.guess' which does a more thorough job (and
    # has totally different output!)

    CPU= 			# Characters 1-2 of syscode
    OS= 			# Characters 3-4 of syscode
    VER=			# Digits 5-6 of syscode
    REL= 			# Digits 7-8 of syscode


    case ${U_MACHINE}::${U_SYSTEM}::${U_RELEASE}::${U_VERSION} in
      # Intel FreeBSD
      i*::FreeBSD::*:* )
        CPU=i3
        OS=fb
        NAME="FreeBSD (Intel)"
        VER=`expr $U_RELEASE : '[^0-9]*\([0-9][0-9]*\)[^0-9]'`
        REL=`expr $U_RELEASE : '[^0-9]*[0-9][0-9]*[^0-9]\([0-9][0-9]*\)'`
       ;;
      # MacOS X
      powerpc::Darwin::*::*)
        CPU=pp
        OS=dw
        NAME="Darwin (PowerPC)"
        VER=`expr $U_RELEASE : '[^0-9]*\([0-9][0-9]*\)[^0-9]'`
        REL=`expr $U_RELEASE : '[^0-9]*[0-9][0-9]*[^0-9]\([0-9][0-9]*\)'`
       ;;
      # PowerPC Linux
      ppc*::Linux::*::*)
        CPU=pp
        OS=li
        NAME="Linux (PowerPC)"
        VER=`expr $U_RELEASE : '[^0-9]*\([0-9][0-9]*\)[^0-9]'`
        REL=`expr $U_RELEASE : '[^0-9]*[0-9][0-9]*[^0-9]\([0-9][0-9]*\)'`
       ;;
      # Intel Linux
      i*::Linux::*::* )
	CPU=i3
	OS=li
	NAME="Linux (Intel)"
	VER=`expr $U_RELEASE : '[^0-9]*\([0-9][0-9]*\)[^0-9]'`
	REL=`expr $U_RELEASE : '[^0-9]*[0-9][0-9]*[^0-9]\([0-9][0-9]*\)'`
      ;;
      # Athlon 64 Linux
      x86_64::Linux::*::* )
	CPU=i3
	OS=li
	NAME="Linux (AMD 64)"
	VER=`expr $U_RELEASE : '[^0-9]*\([0-9][0-9]*\)[^0-9]'`
	REL=`expr $U_RELEASE : '[^0-9]*[0-9][0-9]*[^0-9]\([0-9][0-9]*\)'`
      ;;
      # PowerPC Linux
      ppc*::Linux::*::* )
        CPU=pp
        OS=li
        NAME="Linux (PowerPC)"
        VER=`expr $U_RELEASE : '[^0-9]*\([0-9][0-9]*\)[^0-9]'`
        REL=`expr $U_RELEASE : '[^0-9]*[0-9][0-9]*[^0-9]\([0-9][0-9]*\)'`
       ;;
      # Sequent (Intel)
      i*::DYNIX*::*::* )
	CPU=i3
	OS=dy
	NAME="Sequent DYNIX/ptx (Intel)"
	VER=`expr $U_VERSION : 'V\([0-9]\).*'`
	REL=`expr $U_VERSION : 'V[0-9].\([0-9].[0-9]\)' | sed 's/\.//g'`
      ;;

      # The Sun family
      *::SunOS::4.*::* )
	CPU=sp
	OS=su
	VER=4
	NAME="Sun SunOS (Sparc)"
	REL=`expr $U_RELEASE : '4.\([^_]*\)' | sed 's/[^0-9]//g'`
      ;;
      sun*::SunOS::5.*::* )
	CPU=sp
	OS=so
	VER=5
	NAME="Sun Solaris (Sparc)"
	REL=`expr $U_RELEASE : '5.\([0-9][0-9]*\).*' | sed 's/[^0-9]//g'`
      ;;
      *86*::SunOS::5.*::* )
	CPU=i3
	OS=so
	VER=5
	NAME="Sun Solaris (Intel)"
	REL=`expr $U_RELEASE : '5.\(.*\)' | sed 's/[^0-9]//g'`
      ;;
      *::SunOS::5.*::* )
	CPU=sp
	OS=so
	VER=5
	NAME="Sun Solaris (Sparc)"
	REL=`expr $U_RELEASE : '5.\([0-9][0-9]*\).*' | sed 's/[^0-9]//g'`
      ;;

      # HP
      *::HP-UX::*::* )
	CPU=pa
	OS=hp
	NAME="Hewlett-Packard HP-UX (PA-RISC)"
	VER=`expr $U_RELEASE : '[^.]*.\([0-9]*\).*'`
	REL=`expr $U_RELEASE : '[^.]*.[^.]*.\([0-9]*\)'`
      ;;

      # Data General
      *::dgux::5.4*::* )
	CPU=m8
	OS=dg
	VER=54
	NAME="Data General DG/UX (Motorola)"
	REL=`expr $U_RELEASE : '5.4\(.*\)' | sed 's/[^0-9]//g' | sed 's/\(.\).*\(.\)$/\1\2/'`
      ;;

      # Data General on Intel
      *::dgux::R4*::* )
	case `uname -p`  in
	  m* )
	    CPU=m8 ;;
	  * )
	    CPU=i3 ;;
	esac
	OS=dg
	VER=04
	NAME="Data General DG/UX (Intel)"
	REL=`expr $U_RELEASE : 'R4.\(.*\)' | sed 's/[^0-9]//g'`
        REL=`echo $REL | sed 's/\(..\).*/\1/'`
      ;;

      # OSF/1
      alpha::OSF1::*::* )
	CPU=ax
	OS=o1
	NAME="DEC OSF/1 (Alpha)"
	VER=`echo $U_RELEASE | sed 's/\([^.]*\).*/\1/' | sed 's/[^0-9]//g'`
	REL=`echo $U_RELEASE | sed 's/[^.]*.\(.*\)/\1/' | sed 's/[^0-9]//g'`
      ;;

      # ULTRIX
      *::ULTRIX::*::* )
	CPU=mp
	OS=ul
	NAME="DEC Ultrix (MIPS)"
	VER=`echo $U_RELEASE | sed 's/\([^.]*\).*/\1/' | sed 's/[^0-9]//g'`
	REL=`echo $U_RELEASE | sed 's/[^.]*.\(.*\)/\1/' | sed 's/[^0-9]//g'`
      ;;

      # IRIX
      *::IRIX::4.*::* )
	CPU=mp
	OS=ir
	VER=`echo $U_RELEASE | sed 's/\([^.]*\).*/\1/' | sed 's/[^0-9]//g'`
	REL=`echo $U_RELEASE | sed 's/[^.]*.\(.*\)/\1/' | sed 's/[^0-9]//g'`
      ;;
      
      *::IRIX::5.1::* )
	CPU=mp
	OS=ir
	VER=`echo $U_RELEASE | sed 's/\([^.]*.[^.]*\).*/\1/' | sed 's/[^0-9]//g'`
	REL=`echo $U_RELEASE | sed 's/[^.]*.[^.]*.\(.*\)/\1/' | sed 's/[^0-9]//g'`
      ;;

      # Note
      # If we ever get minor release numbers of 5.2 we'll have to do
      # something different
      *::IRIX::5.2::* )
	CPU=mp
	OS=ir
	VER=`echo $U_RELEASE | sed 's/\([^.]*\).*/\1/' | sed 's/[^0-9]//g'`
	REL=20
      ;;
      # Note
      # This system does not exist yet
      *::IRIX::5.2.*::* )
	CPU=mp
	OS=ir
	VER=`echo $U_RELEASE | sed 's/\([^.]*\).*/\1/' | sed 's/[^0-9]//g'`
	REL=`echo $U_RELEASE | sed 's/[^.]*.\(.*\)/\1/' | sed 's/[^0-9]//g'`
      ;;

      # catchall for other irix versions
      # 6.4 and later change from IRIX to IRIX64
      *::IRIX*::*::* )
	CPU=mp
	OS=ir
	VER=`echo $U_RELEASE | sed 's/\([^.]*\).*/\1/' | sed 's/[^0-9]//g'`
	REL=`echo $U_RELEASE | sed 's/[^.]*.\(.*\)/\1/' | sed 's/[^0-9]//g'`
      ;;

      # AIX
      # note that we can't figure out the patch level of a 3.2.x (x<4)
      # system (even IBM can't tell you immediately!)
      *::AIX::*::* )
	CPU=rs
	OS=ai
	NAME="IBM AIX (Risc)"
	VER=$U_VERSION
	REL=$U_RELEASE
      ;;

      # RISC OS (the mips variety, not acorn)
      # version 5 like output
      mips::*::*::RISCos )
	CPU=mp
	OS=ro
	VER=`echo $U_RELEASE | sed 's/\([^.]*\).*/\1/' | sed 's/[^0-9]//g'`
	REL=`echo $U_RELEASE | sed 's/[^.]*.\(.*\)/\1/' | sed 's/[^0-9]//g'`
      ;;
      # version 4 like output
      mips::*::*::UMIPS )
	CPU=mp
	OS=ro
	VER=`echo $U_RELEASE | sed 's/\([0-9]*\).*/\1/'`
	REL=`echo $U_RELEASE | sed 's/[0-9]*\(.*\)/\1/' | sed 's/[^0-9]//g'`
      ;;

      # Siemens Nixdorf mips R4000 (at least)
      R4000::*::*::* )
	CPU=mp
	OS=sx
	NAME="Siemens Nixdorf SINIX (MIPS)"
	VER=`echo $U_RELEASE | sed 's/\([0-9]*\).*/\1/'`
	REL=`echo $U_RELEASE | sed 's/[0-9]*\(.*\)/\1/' | sed 's/[^0-9]//g'`
      ;;

      # Motorola SVR4
      *88*::*::4*::* )
	CPU=m8
	OS=mo
	VER=`expr $U_VERSION : '[^V]*.\([^.]*\).*' | sed 's/[^0-9]//g'`
	REL=`expr $U_VERSION : '[^V]*.[^.]*.\(.*\)' | sed 's/[^0-9]//g'`
      ;;

      # windows nt with nutcracker
      *::Windows_NT::*::* )
	CPU=i3
	OS=wi
	VER="$U_RELEASE"
	REL="$U_VERSION"
      ;;

      DRS*::*::*::* )
	  PROC=`uname -p 2>/dev/null` || PROC=UNKNOWN
	  case "$PROC" in
	    sparc | SPARC )
	      CPU=sp
	      OS=nx
	      NAME="ICL DRS/NX (Sparc)"
	      ;;
	    i386 )
	      CPU=i386
	      OS=nx
	      NAME="ICL DRS/NX (Intel)"
	      ;;
	  esac

	  VER=`expr $U_VERSION : '\([0-9]\).*'`
	  REL=`expr $U_VERSION : '[0-9]..*\([0-9].[0-9]\)' | sed 's/\.//g'`
      ;;

      
      *::UnixWare::*::* )
	CPU=i3
	OS=un
	NAME="SCO UnixWare (Intel)"
	VER=`expr $U_VERSION : '\([0-9]\)'`
	REL=`expr $U_VERSION : '[0-9].\(.*\)' | sed -e 's/\.//'`
	if [ -z "$REL" ]; then
		REL=00
        elif [ "x`expr $REL : '[0-9]\([0-9]\)'`" = "x" ] ; then
		REL="$REL"0
	fi
	;;

      *::OpenUNIX::*::* )
        CPU=i3
        OS=un
        NAME="SCO UnixWare (Intel)"
        VER=`expr $U_VERSION : '\([0-9]\)'`
        REL=`expr $U_VERSION : '[0-9].\(.*\)' | sed -e 's/\.//'`
        if [ -z "$REL" ]; then
                REL=00
        elif [ "x`expr $REL : '[0-9]\([0-9]\)'`" = "x" ] ; then
                REL="$REL"0
        fi
        ;;

      # Various Intel based Unixen.  These seem particularly reluctant
      # to divulge their OS name, so we have to grep through
      # various system files to find the OS string

      *86*::*::*::* )
	if grep -s -i UnixWare /stand/boot 2>/dev/null 1>&2 || strings /stand/1/unix_mp 2>/dev/null | grep -s -i Unixware 2>/dev/null 1>&2
	then
          # It's some version of Unixware obviously
	  CPU=i3
	  OS=un
	  NAME="SCO UnixWare (Intel)"
          if expr $U_VERSION : 'D\([0-9]*.*\)' 2>/dev/null 1>&2
	  then
            # It's a date stamped version ; we dont yet know how to figure out
            # which so just pretend that it is unixware 212
            VER=02
            REL=12
          else
	    VER=`expr $U_VERSION : '\([0-9]\)'`
	    REL=`expr $U_VERSION : '[0-9].\(.*\)' | sed -e 's/\.//'`
	    if [ "x`expr $REL : '[0-9]\([0-9]\)'`" = "x" ] 
	    then
		REL="$REL"0
	    fi
          fi
	else
	  if [ "$U_SYSTEM" = "SCO_SV" ]
	  then
	    CPU=i3
	    OS=sc
	    VER=`expr $U_RELEASE : '^\([0-9]*\)'`
	    NAME="SCO OpenServer (Intel)"
	    # just the release string ie: 3.2v5.0.0
	    relstr=`uname -X | grep Release | awk '{ print $3 }'`
	    # just the major SCO version after the SVR? (3.2v) bit
	    U_VERSION=`expr ${relstr} : '[0-9.]*v\([0-9]\)[0-9.]*'`
	    REL=`expr ${U_RELEASE}::${U_VERSION} : '[0-9]*\(.*\)' | sed 's/[^0-9]//g'`
	  else
	    if grep -s 'The Santa Cruz Operation' /etc/gettydefs 2>/dev/null 1>&2
	    then
	      CPU=i3
	      OS=sc
	      NAME="SCO Unix (Intel)"
	      VER=`expr $U_RELEASE : '^\([0-9]*\)'`
	      REL=`expr ${U_RELEASE}::${U_VERSION} : '[0-9]*\(.*\)' | sed 's/[^0-9]//g'`
	    else
	      # DYNIX/ptx V2 doesn't return 'DYNIX' or 'ptx' in uname.
	      # This kludge may work, may not, it's either this
	      # or flip a coin!   
	      if grep -s 'ptx' /etc/versionlog 2>/dev/null 1>&2
	      then
		CPU=i3
		OS=dy
		NAME="Sequent DYNIX/ptx (Intel)"
		VER=`expr $U_VERSION : 'V\([0-9]\).*'`
		REL=`expr $U_VERSION : 'V[0-9].\([0-9].[0-9]\)' | sed 's/\.//g'`
	      else
	        # Assume OS must be System V Release 4.
	        CPU=i3
	        OS=sv
		NAME="System V Release 4 (Intel)"
	        VER=`expr $U_RELEASE : '^\([0-9]*\)'`
	        REL=`expr ${U_RELEASE}::${U_VERSION} : '[0-9]*\(.*\)' | sed 's/[^0-9]//g'`
	      fi
	    fi
	  fi
	fi
	;;	
    esac

    if [ -n "$CPU" -a -n "$OS" -a -n "$VER" -a -n "$REL" ]
    then
	break
    fi
done

# 5) Do sanity checking and cleanup
VER=`echo $VER | sed 's/[^0-9]//g'`
REL=`echo $REL | sed 's/[^0-9]//g'`

if [ -z "$CPU" -o -z "$OS" ]
then
  echo "$myname: !10! $msg_xdtarch_os_cpu"
  exit 10
fi

if [ -z "$VER" -o -z "$REL" ]
then
  echo "$myname: !11! $msg_xdtarch_ver_rel"
  exit 11
fi

# Add leading zeroes
REL=`echo 0$REL | sed 's/.*\(..\)/\1/'`
VER=`echo 0$VER | sed 's/.*\(..\)/\1/'`

# 6) So we now know it all

syscode=$CPU$OS$VER$REL

if  test -n "$codeonly"
then
    echo $CPU$OS
    exit 0
fi

if  test -n "$osonly"
then
    echo $VER$REL
    exit 0
fi

# 7) Check for codes given on the command line

if [ ! -z "$checkcodes" ]
then
    for i in $checkcodes
    do
	# Filter the input $checkcodes by matching CPU and OS, and strip
	# them off leaving just the VER and REL.  The tr command replaces
	# spaces by line-feeds, so that the following sort can do its stuff.
	posscodes=`echo $checkcodes | tr ' ' '\012' \
				| sed -ne "s/$CPU$OS//p" | sort -n`
	if [ -z "$posscodes" ]
	then				# None supplied for correct CPU+OS
	    echo >&2 "$myname: !5! $msg_xdtarch_no_match"
	    exit 5
	fi 

	# Some of them are the right platform.
	# The following algorithm returns the greatest possible code which
	# is older than this syscode, or, failing that, the least possible
	# code which is more recent than this one.

	for ver_rel in $posscodes
	do
	    if [ $VER$REL -eq $ver_rel ]
	    then 			# bingo we have this exact release
		echo $syscode
		exit 0
	    elif [ $VER$REL -gt $ver_rel ]
	    then 			# store this previous version
		priorcode=$CPU$OS$ver_rel
	    else 			# $VER$REL is < $ver_rel
		if [ -n "$priorcode" ]
		then
		    echo $priorcode
		    exit 0
		else
		    # Oh dear, we have no previous version so we should use
		    # the oldest newer version which is this current one ...
		    echo $CPU$OS$ver_rel
		    exit 0
		fi
	    fi
	done
    done
    if [ -n "$priorcode" ]
    then
        echo $priorcode
        exit 0
    fi
else
    if [ -n "$displayname" ]
    then
	echo "$NAME"
    else
	echo $syscode
    fi
fi

}
MACHINEARCH=`machinearch`
MACHINEFLAVOR=""
LSBFLAVOR=""
if [  `expr $MACHINEARCH : ..li....` -ne 0 ] ; then
	distrib=`ls /etc/*-release 2>/dev/null`
	n_distrib=`echo $distrib | LANG=C LC_ALL=C tr '[A-Z]' '[a-z]'`
        
        for f_distrib in $n_distrib ; do 
	  case "$f_distrib" in
	    *turbolinux* )
	        MACHINEFLAVOR="turbolinux"
		;;
	    *suse* )
	        MACHINEFLAVOR="suse"
	        ;;
	    *caldera* )
                MACHINEFLAVOR="caldera"
                ;;
	    *redhat*|*fedora* )
	        MACHINEFLAVOR="redhat"
	        ;;
            *lsb* )
                eval `grep ^DISTRIB_ID /etc/lsb-release`
                case "$DISTRIB_ID" in
                 *SuSE* )
                        LSBFLAVOR="suse"
                        ;;
                 "SCO Linux"* ) 
                        LSBFLAVOR="scolinux"
                        ;;
                 *UnitedLinux* ) 
                        LSBFLAVOR="unitedlinux"
                        ;;
                esac
                ;;
	    * )
		# Caldera and Debian don't have a -release.
		# But Debian has a debian_version
		if [ -f /etc/debian_version ] ; then
			MACHINEFLAVOR="debian"
		else
			distrib=`rpm -q -a 2>/dev/null | grep OpenLinux 2>/dev/null`
			r_distrib=`echo $distrib | LANG=C LC_ALL=C tr '[A-Z]' '[a-z]'`
			case "$r_distrib" in
				*openlinux* )
					MACHINEFLAVOR="caldera"
					;;
			esac
		fi
     		;;
	  esac
        done
        # use the LSB flavor iff we haven't determined a flavor from files
        # and packages.
        if [ -z "$MACHINEFLAVOR" -a  ! -z "$LSBFLAVOR" ] ; then
                MACHINEFLAVOR=$LSBFLAVOR
        fi
fi




preInstalledKeys=`cat $TTA_TMPDIR/LICENSE.tta 2>/dev/null`
apachePort=80
if [ -s "$TTA_TMPDIR/apachePort" ]; then
    [ `wc -l <"$TTA_TMPDIR/apachePort"` -eq 1 ] && apachePort=`cat "$TTA_TMPDIR/apachePort"`
fi

GetLicInfo()
{
    # Work out the current license mode and message to display.  Note that
    # all relevant shell variables (including messages) have to be passed in
    # as arguments to this function.  This is horrible, but it's better than
    # having the content of this function replicated in three places as used
    # to be the case.

    l_mode_eval="$1"; 	[ -n "$1" ] && shift
    l_mode_eval2="$1"; 	[ -n "$1" ] && shift
    l_mode_full="$1"; 	[ -n "$1" ] && shift
    l_mode_full2="$1"; 	[ -n "$1" ] && shift
    l_unlimited="$1"; 	[ -n "$1" ] && shift
    LICINFO="$1"; 	[ -n "$1" ] && shift
    PRODUCT_LICENSE_PRODUCT_CODE="$1"; [ -n "$1" ] && shift
    a_LicenseKeys="$1"

    licmode=$l_mode_eval
    NUSERS=0
    unlimitedUserCount=f
    for key in $preInstalledKeys $a_LicenseKeys; do
	output=`$LICINFO $key`
	if [ -n "$output" ]; then
	    unset TTALIC_USERS
	    eval $output
            NEWUSERS=0
            thiskeyunlimited=f
	    for component in $TTALIC_COMPONENT_NAMES ; do
		if [ "$component" = "base" ]; then
		    if [ -n "${TTALIC_USERS}" ]; then
			[ "${TTALIC_USERS}0" -eq 0 ] && thiskeyunlimited=t
                        NEWUSERS=$TTALIC_USERS
		    fi
		fi
                if [ "$component" = "maintenance" ]; then
                    # we assume base comes before maintenace.
                    # maintenance licenses do not license base..
                    NEWUSERS=0
                    thiskeyunlimited=f
                fi
	    done
            if [ "${thiskeyunlimited}" = "t" ] ; then 
                NEWUSERS=0 NUSERS=0
                unlimitedUserCount=t
            fi
            if [ "${NEWUSERS}" != "0" -a -z "$TTALIC_EXPIRE_TIME" ]; then
		licmode=$l_mode_full
	    fi
            NUSERS=`expr $NUSERS + $NEWUSERS` 
	    unset TTALIC_USERS
	fi
    done
    [ "$unlimitedUserCount" = "t" ] && NUSERS="${l_unlimited}"
    case $licmode in
    $l_mode_eval) echo "${NUSERS}%${licmode}%${l_mode_eval2}" ;;
    *) 		  echo "${NUSERS}%${licmode}% (${NUSERS}${l_mode_full2}"
    esac
    return 0
}

setup_dialog()
{
    case "$trace" in
    x) set -x
    esac

    OK=0
    FAIL=1
    CANT_DOWNGRADE=2
    CANT_UPGRADE=3
    QUIT=4

# Version numbers
PRODUCT_VERSION="4.2"
PRODUCT_VERSION_FULL="4.20.983"
PRODUCT_VERSION_MAJOR=4
PRODUCT_VERSION_FEATURE=2
PRODUCT_VERSION_BUG=0
PRODUCT_VERSION_BUILD=983
PRODUCT_VERSION_CAB=4,2,0,983

# Product names
PRODUCT_FULL_NAME="Sun Secure Global Desktop Software"
PRODUCT_SHORT_NAME="Secure Global Desktop"
PRODUCT_SHORT_FILENAME="Tarantella"
TSP_FULL_NAME="Sun Secure Global Desktop Security Pack"
TSP_SHORT_NAME="Security Pack"
WCP_FULL_NAME="Sun Secure Global Desktop Windows Connectivity Pack"
WCP_SHORT_NAME="Windows Connectivity Pack"
TN3270_FULL_NAME="Sun Secure Global Desktop Mainframe Connectivity Pack"
TN3270_SHORT_NAME="Mainframe Connectivity Pack"
AS400_FULL_NAME="Sun Secure Global Desktop AS/400 Connectivity Pack"
AS400_SHORT_NAME="AS/400 Connectivity Pack"
S1PSTK_FULL_NAME="Sun Secure Global Desktop Channel for Sun ONE Portal Server"
S1PSIP_FULL_NAME="Sun Secure Global Desktop Integration Pack for Sun ONE Portal Server"
S1PSTK_SHORT_NAME="Secure Global Desktop Channel for Sun ONE Portal Server"
S1PSIP_SHORT_NAME="Secure Global Desktop Integration Pack for Sun ONE Portal Server"

OBJECT_MGR_NAME="Object Manager"
ARRAY_MGR_NAME="Array Manager"
NATIVE_WIN16_FULL_NAME="Sun Secure Global Desktop Native Client for Windows 3.1"
NATIVE_WIN16_SHORT_NAME="Native Client for Windows 3.1"
NATIVE_WIN32_FULL_NAME="Sun Secure Global Desktop Native Client for Windows 95, 98 and NT"
NATIVE_WIN32_SHORT_NAME="Native Client for Windows 95, 98 and NT"
NATIVE_WYSE_FULL_NAME="Sun Secure Global Desktop Native Client for Wyse"
NATIVE_WYSE_SHORT_NAME="Native Client for Wyse"
NATIVE_FULL_NAME="Sun Secure Global Desktop Native Client"
NATIVE_SHORT_NAME="Native Client"
NATIVE_REGISTRY_NAME="Tarantella Native Client"
TCC_FULL_NAME="Sun Secure Global Desktop Client"
TCC_HELPER_NAME="Sun Secure Global Desktop Client Helper"
TCC_ACTIVEX_NAME="Sun Secure Global Desktop ActiveX Control"
TCC_PLUGIN_NAME="Sun Secure Global Desktop Netscape Plug-in"
T3COMPONENT_WIN_NAME="Sun Secure Global Desktop Enhancement Module for Windows"
T3COMPONENT_UNIX_NAME="Sun Secure Global Desktop Enhancement Module for UNIX/Linux"
T3COMPONENT_SHORT_UNIX_NAME="tem"
T3COMPONENT_NAME="Sun Secure Global Desktop Enhancement Module"

# Watch the length of these names: IE refuses to remove packages if
# the name is too long.
ARCHIVE_NAME_ttalw="TCC Helper, version"
ARCHIVE_NAME_asad="3.x Framework Java Archive"
#ARCHIVE_NAME_tta="3.x Java Archive"
#ARCHIVE_NAME_tta="3.x Combined Java Archive"
ARCHIVE_NAME_tta="Client, "
ARCHIVE_NAME_tsp="3.x Security Java Archive"
ARCHIVE_NAME_proxy="3.x Proxy Java Archive"

ARCHIVE_SUFFIX="F"

NS_REGKEY="java/download/com/tarantella/tta"

PRODUCT_VENDOR="Sun Microsystems, Inc."
PRODUCT_SHORT_VENDOR="Sun"

# Capabilities:
# The format for the capabilities required by the client end of a
# connection is: CAPABILITIES_protocol_type_REQUIRED="expression"

# The format for the capabilities provided by the server end of a
# connection is: CAPABILITIES_protocol_type_PROVIDED="c1 c2 ... c3"

# Asad between a webtop client and server:
CAPABILITIES_ASAD_WEBTOPCLIENT_REQUIRED="(1.1 || 1.2)"
CAPABILITIES_ASAD_WEBTOPCLIENT_PROVIDED="1.1 1.2"

# Asad between two peer servers, or an admin tool and a server:
# 1.1 is core E3 array functionality.
# 1.2 is 3.01 array interoperability functionality.
# 2.1 is core Pisa client device mapping functionality (not a requirement)
CAPABILITIES_ASAD_PEER_REQUIRED="(1.1 || 1.2)"
CAPABILITIES_ASAD_PEER_PROVIDED="1.1 1.2 2.1"

# Client versions of server strings; same format, name prefixed by CLIENT
# Asad between a webtop client and server:
CLIENTCAPABILITIES_ASAD_WEBTOPCLIENT_REQUIRED="(1.1 || 1.2)"
CLIENTCAPABILITIES_ASAD_WEBTOPCLIENT_PROVIDED="1.1 1.2"
# Reboot and cron names
INST_RCFILE="S90$PRODUCT_SHORT_FILENAME"
INST_RCSTRING="##$PRODUCT_SHORT_FILENAME##"

# Tarantella Web Server
TWS_INST_RCFILE="S89${PRODUCT_SHORT_FILENAME}WebServer"
TWS_INST_RCSTRING="##${PRODUCT_SHORT_FILENAME}WebServer##"

# Modify this list whenever the list of supported upgrades changes.
# Version numbers may contain wildcards.
PRIOR_UPGRADES="3.3*.* 3.40.* 3.42.* 4.00.* 4.10.* 4.20.*"
SUPPORTED_UPGRADES="$PRODUCT_VERSION_FULL $PRIOR_UPGRADES"
# the License Product Code
PRODUCT_LICENSE_PRODUCT_CODE="8388608"
TSP_US_LICENSE_PRODUCT_CODE="4194304"
TSP_INTL_LICENSE_PRODUCT_CODE="2097152"
USER_RESTRICTION="1"


# Version numbers
PRODUCT_VERSION="4.2"
PRODUCT_VERSION_FULL="4.20.983"
PRODUCT_VERSION_MAJOR=4
PRODUCT_VERSION_FEATURE=2
PRODUCT_VERSION_BUG=0
PRODUCT_VERSION_BUILD=983
PRODUCT_VERSION_CAB=4,2,0,983

# Product names
PRODUCT_FULL_NAME="Sun Secure Global Desktop Software"
PRODUCT_SHORT_NAME="Secure Global Desktop"
PRODUCT_SHORT_FILENAME="Tarantella"
TSP_FULL_NAME="Sun Secure Global Desktop Security Pack"
TSP_SHORT_NAME="Security Pack"
WCP_FULL_NAME="Sun Secure Global Desktop Windows Connectivity Pack"
WCP_SHORT_NAME="Windows Connectivity Pack"
TN3270_FULL_NAME="Sun Secure Global Desktop Mainframe Connectivity Pack"
TN3270_SHORT_NAME="Mainframe Connectivity Pack"
AS400_FULL_NAME="Sun Secure Global Desktop AS/400 Connectivity Pack"
AS400_SHORT_NAME="AS/400 Connectivity Pack"
S1PSTK_FULL_NAME="Sun Secure Global Desktop Channel for Sun ONE Portal Server"
S1PSIP_FULL_NAME="Sun Secure Global Desktop Integration Pack for Sun ONE Portal Server"
S1PSTK_SHORT_NAME="Secure Global Desktop Channel for Sun ONE Portal Server"
S1PSIP_SHORT_NAME="Secure Global Desktop Integration Pack for Sun ONE Portal Server"

OBJECT_MGR_NAME="Object Manager"
ARRAY_MGR_NAME="Array Manager"
NATIVE_WIN16_FULL_NAME="Sun Secure Global Desktop Native Client for Windows 3.1"
NATIVE_WIN16_SHORT_NAME="Native Client for Windows 3.1"
NATIVE_WIN32_FULL_NAME="Sun Secure Global Desktop Native Client for Windows 95, 98 and NT"
NATIVE_WIN32_SHORT_NAME="Native Client for Windows 95, 98 and NT"
NATIVE_WYSE_FULL_NAME="Sun Secure Global Desktop Native Client for Wyse"
NATIVE_WYSE_SHORT_NAME="Native Client for Wyse"
NATIVE_FULL_NAME="Sun Secure Global Desktop Native Client"
NATIVE_SHORT_NAME="Native Client"
NATIVE_REGISTRY_NAME="Tarantella Native Client"
TCC_FULL_NAME="Sun Secure Global Desktop Client"
TCC_HELPER_NAME="Sun Secure Global Desktop Client Helper"
TCC_ACTIVEX_NAME="Sun Secure Global Desktop ActiveX Control"
TCC_PLUGIN_NAME="Sun Secure Global Desktop Netscape Plug-in"
T3COMPONENT_WIN_NAME="Sun Secure Global Desktop Enhancement Module for Windows"
T3COMPONENT_UNIX_NAME="Sun Secure Global Desktop Enhancement Module for UNIX/Linux"
T3COMPONENT_SHORT_UNIX_NAME="tem"
T3COMPONENT_NAME="Sun Secure Global Desktop Enhancement Module"

# Watch the length of these names: IE refuses to remove packages if
# the name is too long.
ARCHIVE_NAME_ttalw="TCC Helper, version"
ARCHIVE_NAME_asad="3.x Framework Java Archive"
#ARCHIVE_NAME_tta="3.x Java Archive"
#ARCHIVE_NAME_tta="3.x Combined Java Archive"
ARCHIVE_NAME_tta="Client, "
ARCHIVE_NAME_tsp="3.x Security Java Archive"
ARCHIVE_NAME_proxy="3.x Proxy Java Archive"

ARCHIVE_SUFFIX="F"

NS_REGKEY="java/download/com/tarantella/tta"

PRODUCT_VENDOR="Sun Microsystems, Inc."
PRODUCT_SHORT_VENDOR="Sun"

# Capabilities:
# The format for the capabilities required by the client end of a
# connection is: CAPABILITIES_protocol_type_REQUIRED="expression"

# The format for the capabilities provided by the server end of a
# connection is: CAPABILITIES_protocol_type_PROVIDED="c1 c2 ... c3"

# Asad between a webtop client and server:
CAPABILITIES_ASAD_WEBTOPCLIENT_REQUIRED="(1.1 || 1.2)"
CAPABILITIES_ASAD_WEBTOPCLIENT_PROVIDED="1.1 1.2"

# Asad between two peer servers, or an admin tool and a server:
# 1.1 is core E3 array functionality.
# 1.2 is 3.01 array interoperability functionality.
# 2.1 is core Pisa client device mapping functionality (not a requirement)
CAPABILITIES_ASAD_PEER_REQUIRED="(1.1 || 1.2)"
CAPABILITIES_ASAD_PEER_PROVIDED="1.1 1.2 2.1"

# Client versions of server strings; same format, name prefixed by CLIENT
# Asad between a webtop client and server:
CLIENTCAPABILITIES_ASAD_WEBTOPCLIENT_REQUIRED="(1.1 || 1.2)"
CLIENTCAPABILITIES_ASAD_WEBTOPCLIENT_PROVIDED="1.1 1.2"
# The special name values are limited to 53 characters (including "Tarantella")
# well only 53 characters of the complete name is displayed in the --info
# option of the shx file

PRODUCT_PACKAGE_TYPES="pkg rpm"

PRODUCT_TTA_PKGNAME="tta"
PRODUCT_TSP_PKGNAME="ttasecure"
PRODUCT_WCP_PKGNAME="ttawcp"
PRODUCT_PIP_PKGNAME="ttapip"
PRODUCT_3270_PKGNAME="tta3270"
PRODUCT_5250_PKGNAME="tta5250"
PRODUCT_TEM_PKGNAME="tem"
PRODUCT_TIER3TEM_PKGNAME="tem"

PRODUCT_S1PSTK_PKGNAME="tcs1"
PRODUCT_S1PSIP_PKGNAME="tis1"

PRODUCT_PACKAGELIST_S1PSTK="tcs1"
PRODUCT_PACKAGELIST_S1PSIP="tis1"
PRODUCT_PACKAGE_SPECIAL_PRENAME_tcs1pt=""
PRODUCT_PACKAGE_SPECIAL_NAME_tcs1pt=" $S1PSTK_SHORT_NAME patch $PRODUCT_VERSION_FULL"
PRODUCT_PACKAGE_CATEGORY_tcs1pt="application"

PRODUCT_PACKAGE_SPECIAL_NAME_tis1pt=" $S1PSIP_SHORT_NAME patch $PRODUCT_VERSION_FULL"
PRODUCT_PACKAGE_CATEGORY_tis1pt="application"

PRODUCT_PACKAGE_SPECIAL_PRENAME_tcs1=""
PRODUCT_PACKAGE_SPECIAL_NAME_tcs1=" $S1PSTK_SHORT_NAME"
PRODUCT_PACKAGE_CATEGORY_tcs1="application"

PRODUCT_PACKAGE_SPECIAL_PRENAME_tis1=""
PRODUCT_PACKAGE_SPECIAL_NAME_tis1=" $S1PSIP_SHORT_NAME"
PRODUCT_PACKAGE_CATEGORY_tis1="application"

PRODUCT_PACKAGELIST_BASE="tta ttapip ttawcp"
PRODUCT_PACKAGELIST_TSP="ttasecure"
PRODUCT_PACKAGELIST_WCP="ttawcp"
PRODUCT_PACKAGELIST_3270="tta3270"
PRODUCT_PACKAGELIST_5250="tta5250"
PRODUCT_PACKAGELIST_TEM="tem"
PRODUCT_PACKAGELIST_TIER3TEM="tem"
PRODUCT_PACKAGELIST_ARCHIVE=""
PRODUCT_PACKAGELIST_NULL="ttafandr ttafhang ttaficl ttaforie ttafscot"
PRODUCT_PACKAGELIST_FONTS="ttafandr ttafhang ttaficl ttaforie ttafscot"

PRODUCT_PACKAGE_SPECIAL_PRENAME_tta=""
PRODUCT_PACKAGE_SPECIAL_NAME_tta=""
PRODUCT_PACKAGE_CATEGORY_tta="application"

PRODUCT_PACKAGE_SPECIAL_PRENAME_ttasecure=""
PRODUCT_PACKAGE_SPECIAL_NAME_ttasecure=" Security Pack"
PRODUCT_PACKAGE_CATEGORY_ttasecure="application"

PRODUCT_PACKAGE_SPECIAL_PRENAME_ttawcp=""
PRODUCT_PACKAGE_SPECIAL_NAME_ttawcp=" Windows Connectivity Pack"
PRODUCT_PACKAGE_CATEGORY_ttawcp="application"

PRODUCT_PACKAGE_SPECIAL_PRENAME_ttafandr=""
PRODUCT_PACKAGE_SPECIAL_NAME_ttafandr=" Andrew Fonts"
PRODUCT_PACKAGE_CATEGORY_ttafandr="graphics"
PRODUCT_PACKAGE_DIR_ttafandr="fonts/andrew"

PRODUCT_PACKAGE_SPECIAL_PRENAME_ttafhang=""
PRODUCT_PACKAGE_SPECIAL_NAME_ttafhang=" Hangul Fonts"
PRODUCT_PACKAGE_CATEGORY_ttafhang="graphics"
PRODUCT_PACKAGE_DIR_ttafhang="fonts/hangul"

PRODUCT_PACKAGE_SPECIAL_PRENAME_ttaficl=""
PRODUCT_PACKAGE_SPECIAL_NAME_ttaficl=" ICL Fonts"
PRODUCT_PACKAGE_CATEGORY_ttaficl="graphics"
PRODUCT_PACKAGE_DIR_ttaficl="fonts/icl"

PRODUCT_PACKAGE_SPECIAL_PRENAME_ttaforie=""
PRODUCT_PACKAGE_SPECIAL_NAME_ttaforie=" Oriental Fonts"
PRODUCT_PACKAGE_CATEGORY_ttaforie="graphics"
PRODUCT_PACKAGE_DIR_ttaforie="fonts/oriental"

PRODUCT_PACKAGE_SPECIAL_PRENAME_ttafscot=""
PRODUCT_PACKAGE_SPECIAL_NAME_ttafscot=" SCO Term Fonts"
PRODUCT_PACKAGE_CATEGORY_ttafscot="graphics"
PRODUCT_PACKAGE_DIR_ttafscot="fonts/scoterm"

PRODUCT_PACKAGE_SPECIAL_PRENAME_ttapatch=""
PRODUCT_PACKAGE_SPECIAL_NAME_ttapatch=" Patch $PRODUCT_VERSION_FULL"
PRODUCT_PACKAGE_CATEGORY_ttapatch="application"

PRODUCT_PACKAGE_SPECIAL_PRENAME_tta3270pt=""
PRODUCT_PACKAGE_SPECIAL_NAME_tta3270pt=" $TN3270_SHORT_NAME patch $PRODUCT_VERSION_FULL"
PRODUCT_PACKAGE_CATEGORY_tta3270pt="application"

PRODUCT_PACKAGE_SPECIAL_PRENAME_tta5250pt=""
PRODUCT_PACKAGE_SPECIAL_NAME_tta5250pt=" $AS400_SHORT_NAME patch $PRODUCT_VERSION_FULL"
PRODUCT_PACKAGE_CATEGORY_tta5250pt="application"

PRODUCT_PACKAGE_SPECIAL_PRENAME_tsppatch=""
PRODUCT_PACKAGE_SPECIAL_NAME_tsppatch=" Security Pack Patch $PRODUCT_VERSION_FULL"
PRODUCT_PACKAGE_CATEGORY_tsppatch="application"

PRODUCT_PACKAGE_SPECIAL_PRENAME_pkgprog=""
PRODUCT_PACKAGE_SPECIAL_NAME_pkgprog=" Application Packaging Tools"
PRODUCT_PACKAGE_CATEGORY_pkgprog="application"

PRODUCT_PACKAGE_SPECIAL_PRENAME_gunzip="GNU gunzip for "
PRODUCT_PACKAGE_SPECIAL_NAME_gunzip=""
PRODUCT_PACKAGE_CATEGORY_gunzip="application"

PRODUCT_PACKAGE_SPECIAL_PRENAME_tta3270=""
PRODUCT_PACKAGE_SPECIAL_NAME_tta3270=" $TN3270_SHORT_NAME"
PRODUCT_PACKAGE_CATEGORY_tta3270="application"

PRODUCT_PACKAGE_SPECIAL_PRENAME_tta5250=""
PRODUCT_PACKAGE_SPECIAL_NAME_tta5250=" $AS400_SHORT_NAME"
PRODUCT_PACKAGE_CATEGORY_tta5250="application"

PRODUCT_PACKAGE_SPECIAL_PRENAME_ttapip=""
PRODUCT_PACKAGE_SPECIAL_NAME_ttapip=" Platform Identity Pack"
PRODUCT_PACKAGE_CATEGORY_ttapip="application"

PRODUCT_PACKAGE_SPECIAL_PRENAME_tem=""
PRODUCT_PACKAGE_SPECIAL_NAME_tem=" Enhancement Module"
PRODUCT_PACKAGE_CATEGORY_tem="application"

# be paranoid about the current path
if [ -d /bin ]; then
  PATH=/bin:$PATH
fi
if [ -d /sbin ]; then
  PATH=/sbin:$PATH
fi
if [ -d /usr/bin ]; then
  PATH=/usr/bin:$PATH
fi
if [ -d /usr/sbin ]; then
  PATH=/usr/sbin:$PATH
fi
if [ -d /etc ]; then
  PATH=/etc:$PATH
fi
export PATH

N=""
C=""
if echo -n | grep n > /dev/null
then
  C="\c"
else
  N="-n"
fi
case "$MACHINEARCH" in
i3li*|ppli*) N="$N -e" ;;
esac
_ss_headlines="--------------------------------------------------------------------------"

# get our ported package tools on the head of the path
if [ -d /usr/package/sadm/install/bin ]
then
    PATH=/var/sadm/install/bin:$PATH
fi

if [ -z "$0" ]; then
  who_i_am=""
else
  who_i_am=`expr "//$0" : '.*/\(.*\)' `
fi


    NUSERS="0"
    THISKEY=""
    NEWUSERS="0"
    LICINFO=":"
    RESPONSE="/dev/null"
    NEEDKB="0"
    INSTTYPE=""
    INSTMSG=""
    GOTSTRINGS=""
    INST_RCFILE="S90$PRODUCT_SHORT_FILENAME"
    INST_RCSTRING="##$PRODUCT_SHORT_FILENAME##"

    ASK_INSTDIR=""
    ASK_PEERDNS=""
    ASK_LICMODE=""
    ASK_CRONTAB=""
    ASK_RC=""
    ASK_WEBTOP=""
    ASK_PRINTER=""
    ASK_HTTPPORT=""

    a_LicenseKeys=""

    ######################################################################
    # command-line args
    #
    while [ -n "$1" ]; do
	case "$1" in
	--licinfo) 	LICINFO="$2"; shift; shift;;
	--response) 	RESPONSE="$2"; shift; shift;;
	--needkb) 	NEEDKB="$2"; shift; shift;;
	--gotstrings) 	GOTSTRINGS="t"; shift;;
	--ask_instdir) 	ASK_INSTDIR="t"; shift;;
	--ask_peerdns)  ASK_PEERDNS="$2"; shift; shift;;
	--ask_licmode) 	ASK_LICMODE="t"; shift;;
	--ask_crontab) 	ASK_CRONTAB="t"; shift;;
	--ask_rc) 	ASK_RC="t"; shift;;
	--ask_webtop) 	ASK_WEBTOP="t"; shift;;
	--ask_printer) 	ASK_PRINTER="t"; shift;;
	--ask_httpport)	ASK_HTTPPORT="t"; shift;;
	*)  echo "$0: unknown arg '$1'" >&2
	    return $FAIL
	esac
    done

    if [ -z "$GOTSTRINGS" ]; then
lf_nomessages="No message files installed for LANG="
l_langdefault="Attempting to use default English (en-us) messages"
l_langunknown="Unrecognized \$LANG: "
l_langunset="\$LANG is not set."
lf_langright="Please check the \$LANG variable is correct."
l_langsetto="\$LANG is currently set to: "
l_gottheselangs="Message files are installed for the following languages:"
l_usinglang="Using messages in"
[ -z "$LANG" ] && LANG="C"

TTALANG=$LANG
case "$TTALANG" in
C)  TTALANG="en-us"
    ;;
[a-z][a-z]_[A-Z][A-Z])
    # convert LANG format from ab_CD to ab-cd
    TTALANG=`echo "$TTALANG" | LANG=C LC_ALL=C tr '[A-Z]_' '[a-z]-'`
esac

if [ ! -d $TTALANG -o -z "$TTALANG" ]; then
  [ ! -z "$TTALANG" ] && posslangs=`find . -type d -name "$TTALANG*" -print 2>/dev/null | sed 's;.*\/.*\/.*;;'`

  [ -z "$posslangs" ] && posslangs=`find . -type d -name '[a-z][a-z]-[a-z][a-z]*' -print 2>/dev/null | sed 's;.*\/.*\/.*;;'`

  nposslangs=`echo $posslangs | wc -w`
  if [ "$nposslangs" -gt 1 ]; then
    case "$TTALANG" in
      ??* )
            echo "${lf_nomessages}${LANG}" #!!!
	    echo "$lf_langright"
            ;;
      "" )
           echo "$l_langunset"
           ;;
      * )
          TTALANG=en-us
          echo "$l_langunknown $LANG"
          echo "$l_langdefault"
          ;;
    esac
    echo "$l_gottheselangs"
    tmpTTALANG=$TTALANG
    for a_lang in $posslangs; do
      output=`echo $a_lang | sed -e 's/.*\///'`
      echo "  $output"
      if [ -f $output/common -o -f ../$output/common ]; then
	[ "$tmpTTALANG" != "en-us" ] && tmpTTALANG=$output
      fi
    done
    [ "$TTALANG" = "$tmpTTALANG" ] && TTALANG=en-us || TTALANG=$tmpTTALANG	
    echo "$l_usinglang $TTALANG"
  elif [ "$nposslangs" -eq 1 ]; then
    TTALANG=`echo $posslangs | sed -e 's/.*\///'`
  else
    echo "$lf_reinst"
    exit 5
  fi
fi

TTAMSG=`pwd`/$TTALANG
export TTAMSG TTALANG
if [ $trace ]; then echo "   trace: Language dir = $TTAMSG"; fi

if [ -f $TTAMSG/common ]; then
  . $TTAMSG/common
else
  _lang=`basename $TTAMSG`
  _parent=`dirname $TTAMSG`
  _parent=`dirname $_parent`
  if [ -f $_parent/$_lang/common ]; then
    . $_parent/$_lang/common
  else
    echo "Unable to open message file: $TTAMSG/common"
    exit 1
  fi
fi
if [ -f $TTAMSG/setup ]; then
  . $TTAMSG/setup
else
  echo "Unable to open message file: $TTAMSG/setup"
  exit 1
fi

    fi

    get_httpport() { 
    ##################################################################
    # HTTP port for TWS
    #
    if [ -n "$ASK_HTTPPORT" ]; then
        case `$TTA_TMPDIR/ttahostprobe localhost:$a_httpport` in
           "n" ) prompt_httpport=${p_httpport} ;;
            * ) prompt_httpport="${p_httpport}${s_port}${a_httpport}/tcp${s_inuse}" ;;
        esac
echo; echo
echo $_ss_headlines
echo "$h_httpport"
echo $_ss_headlines

echo "$prompt_httpport"
echo # blank line between prompt and question
_valid=false
while [ $_valid = false ]
do
  echo $N "$q_httpport [$a_httpport] $C"
  read _answer
  if [ -z "$_answer" ]
  then
    _answer="$a_httpport"   # default
  fi
  _valid=`case $_answer in [1-9]*) if expr $_answer + 1 >/dev/null 2>/dev/null; then echo true; else echo false; fi;; *) echo false;; esac`
done
a_httpport="$_answer"

        while [ "`$TTA_TMPDIR/ttahostprobe localhost:$a_httpport`" = "y" ]; do
            httpprompt="${s_port}${a_httpport}/tcp${s_inuse}"
echo "$httpprompt"
echo # blank line between prompt and question
_valid=false
while [ $_valid = false ]
do
  echo $N "$q_httpport [$a_httpport] $C"
  read _answer
  if [ -z "$_answer" ]
  then
    _answer="$a_httpport"   # default
  fi
  _valid=`case $_answer in [1-9]*) if expr $_answer + 1 >/dev/null 2>/dev/null; then echo true; else echo false; fi;; *) echo false;; esac`
done
a_httpport="$_answer"

        done
    fi
    }

    a_Archive=$a_yes a_cron="" a_CronDay="" a_CronTime=""
a_cron="" a_CronDay="" a_CronTime=""
_cronline=`crontab -l 2>/dev/null | grep "/tarantella archive" | grep -v '^#'`
if [ -n "$_cronline" ]; then
  a_cron=t
  a_CronDay=`echo "$_cronline" | awk '{print $5}'`
  a_CronTime=`echo "$_cronline" | awk '{print $2}'`
fi

    [ -z "$a_CronTime" ] && a_CronTime=03
    [ -z "$a_CronDay" ] && a_CronDay=0
    a_CronTimeOrig=$a_CronTime
    a_CronDayOrig=$a_CronDay

    if [ "$PRODUCT_TTA_PKGNAME" = "ttajive" ]; then
	a_definstdir=`echo "$a_definstdir" | sed 's/tarantella/ttajive/'`
	a_definstdir2=`echo "$a_definstdir2" | sed 's/tarantella/ttajive/'`
    fi

    a_InstDir=$a_definstdir2
    # try to find sensible default directory
    if [ -d "$a_definstdir" ]; then
case "$MACHINEARCH" in
i3li*|ppli*)  _kflag=kP;;
*)	_kflag=k
esac

_path=$a_definstdir
while [ ! -d "$_path" ]; do
if [ -z "$_path" ]; then
  _path=.
else
  _path=`expr "$_path/" : '\(/\)/*[^/]*//*$'  \| \
    "$_path/" : '\(.*[^/]\)//*[^/][^/]*//*$' \| \
    .`
fi

done
if [ -f /bin/pwd ]
then
    origdir=`/bin/pwd`
    cd "$_path"
    dir=`/bin/pwd`
else
    origdir=`pwd`
    cd "$_path"
    dir=`pwd`
fi

kbytes=""

dirname="$dir/"
apple=`df -${_kflag}l $dirname > /dev/null 2>&1`
if [ $? -eq 0 ]
then
    # NOT any of the following
    # pahp0901 axo10300 axo10400 spsu0412 spsu0413 spsu0414 rsai0302
    # rsai0401 rsai0402

    banana=`df -${_kflag}l $dirname 2>/dev/null | egrep '[Aa]vail' > /dev/null 2>&1`
    if [ $? -eq 0 ]
    then
	# NOT any of the following
	# i3sc0325 mpsx0543 pahp1001 pahp1100
	# System V style output
	kbytes=`(df -${_kflag} $dirname 2>/dev/null | egrep -v '[Aa]vail' | tr '\012' ' '; echo) | sed -e '
{
s/^[^ 	]*[ 	]*[a-zA-Z]*[ 	]*[0-9]*[ 	]*[0-9]*[ 	]*\([0-9]*\).*$/\1/
q
}'`
    else
	cumquat=`df -bl $dirname 2>/dev/null | grep "Kbytes free" > /dev/null 2>&1`
	if [ $? -eq 0 ]
	then
	    # pahp10* pahp11*


	    # pahp1002 core dumps if you try df -k on an NFS drive
	    # pahp1020 gives you the wrong info with df -b
	    #     but the right info with df -k !!!
	    # so use df -f and divide the answer
	    kbytes=`df -f $dirname 2>/dev/null | sed -e '
{
s/.*[	 ]*.*:[	 ]*\([0-9]*\)[	 ]*blocks.*$/\1/
q
}'`
	    kbytes=`expr $kbytes / 2`
	else
	    ## probably i3sc0325
	    kbytes=`df -${_kflag} $dirname 2>/dev/null | sed -e '
{
s/.*[ 	]*.*:[ 	]*\([0-9]*\)[ 	]*blocks.*$/\1/
q
}'`
	fi
    fi
else
    dewberry=`df -${_kflag} $dirname 2>/dev/null | grep Free > /dev/null 2>&1`
    if [ $? -eq 0 ]
    then
	# rsai04* style output
	kbytes=`df -${_kflag} $dirname 2>/dev/null | grep -v Free  | sed -e '
{
s/^[^ 	]*[ 	]*[0-9]*[ 	]*\([0-9]*\).*$/\1/
q
}'`
    else
	elderberry=`df $dirname > /dev/null 2>&1`
	if [  $? -eq 0  ]
	then
	    # spsu style output
	    kbytes=`df $dirname 2>/dev/null | egrep -v '[Aa]vail' | sed -e '
{
s/^[^ 	]*[ 	]*[0-9]*[ 	]*[0-9]*[ 	]*\([0-9]*\).*$/\1/
q
}'`
	    if [ "x$kbytes" = "x" ]
	    then
		kbytes=`df $dirname 2>/dev/null | sed -e '
{
s/.*[ 	]*.*:[ 	]*\([0-9]*\)[ 	]*blocks.*$/\1/
q
}'`
	    case "$kbytes" in
		    *free*) # rsai03* old style
			dk_space=`df $dirname 2>/dev/null | grep -v free  | sed -e '
{
s/^[^   ]*[ 	]*[0-9]*[ 	]*\([0-9]*\).*$/\1/
q
}'`
		    if [ -n "$dk_space" ]
			then
			    kbytes=$dk_space
			fi
		    ;;
		    *)
			dd of=$_path/._._._ bs=1000 if=/bin/ls count=1 > /dev/null 2>&1
			sz=`du -s $_path/._._._`
			sz=`expr "$sz" : '\([0-9]*\).*'`
			rm -f $_path/._._._
			case $sz in
			2*)
				kbytes=`expr $kbytes / $sz`
			    ;;
			    *)
			    ;;
			esac
		esac
	    fi
	else
	    dd of=$_path/._._._ bs=1000 if=/bin/ls count=1 > /dev/null 2>&1
	    sz=`du -s $_path/._._._`
	    sz=`expr "$sz" : '\([0-9]*\).*'`
	    rm -f $_path/._._._
	    while [ "$dirname" != "" ]
	    do
		kbytes=`df 2>/dev/null | egrep "^$dirname[ 	]*\(.*$" | sed -e '
{
s/^[^\)]*.:[ 	]*\([0-9]*\)[ 	]*blocks.*$/\1/
q
}'`
	    if [ "$kbytes" != "" -o "$dirname" = "/"  ]
		then
		    break
		fi
if [ -z "$dirname" ]; then
  dirname=.
else
  dirname=`expr "$dirname/" : '\(/\)/*[^/]*//*$'  \| \
    "$dirname/" : '\(.*[^/]\)//*[^/][^/]*//*$' \| \
    .`
fi

	    done
	    case $sz in
		2*)
		    kbytes=`expr $kbytes / $sz`
		;;
		*)
		;;
	    esac
	fi
    fi
fi

cd $origdir

	if [ "${kbytes}0" -gt "${NEEDKB}0" ]; then
	    a_InstDir=$a_definstdir
	fi
    elif [ -d "$a_base_definstdir" ]; then
case "$MACHINEARCH" in
i3li*|ppli*)  _kflag=kP;;
*)	_kflag=k
esac

_path=$a_base_definstdir
while [ ! -d "$_path" ]; do
if [ -z "$_path" ]; then
  _path=.
else
  _path=`expr "$_path/" : '\(/\)/*[^/]*//*$'  \| \
    "$_path/" : '\(.*[^/]\)//*[^/][^/]*//*$' \| \
    .`
fi

done
if [ -f /bin/pwd ]
then
    origdir=`/bin/pwd`
    cd "$_path"
    dir=`/bin/pwd`
else
    origdir=`pwd`
    cd "$_path"
    dir=`pwd`
fi

kbytes=""

dirname="$dir/"
apple=`df -${_kflag}l $dirname > /dev/null 2>&1`
if [ $? -eq 0 ]
then
    # NOT any of the following
    # pahp0901 axo10300 axo10400 spsu0412 spsu0413 spsu0414 rsai0302
    # rsai0401 rsai0402

    banana=`df -${_kflag}l $dirname 2>/dev/null | egrep '[Aa]vail' > /dev/null 2>&1`
    if [ $? -eq 0 ]
    then
	# NOT any of the following
	# i3sc0325 mpsx0543 pahp1001 pahp1100
	# System V style output
	kbytes=`(df -${_kflag} $dirname 2>/dev/null | egrep -v '[Aa]vail' | tr '\012' ' '; echo) | sed -e '
{
s/^[^ 	]*[ 	]*[a-zA-Z]*[ 	]*[0-9]*[ 	]*[0-9]*[ 	]*\([0-9]*\).*$/\1/
q
}'`
    else
	cumquat=`df -bl $dirname 2>/dev/null | grep "Kbytes free" > /dev/null 2>&1`
	if [ $? -eq 0 ]
	then
	    # pahp10* pahp11*


	    # pahp1002 core dumps if you try df -k on an NFS drive
	    # pahp1020 gives you the wrong info with df -b
	    #     but the right info with df -k !!!
	    # so use df -f and divide the answer
	    kbytes=`df -f $dirname 2>/dev/null | sed -e '
{
s/.*[	 ]*.*:[	 ]*\([0-9]*\)[	 ]*blocks.*$/\1/
q
}'`
	    kbytes=`expr $kbytes / 2`
	else
	    ## probably i3sc0325
	    kbytes=`df -${_kflag} $dirname 2>/dev/null | sed -e '
{
s/.*[ 	]*.*:[ 	]*\([0-9]*\)[ 	]*blocks.*$/\1/
q
}'`
	fi
    fi
else
    dewberry=`df -${_kflag} $dirname 2>/dev/null | grep Free > /dev/null 2>&1`
    if [ $? -eq 0 ]
    then
	# rsai04* style output
	kbytes=`df -${_kflag} $dirname 2>/dev/null | grep -v Free  | sed -e '
{
s/^[^ 	]*[ 	]*[0-9]*[ 	]*\([0-9]*\).*$/\1/
q
}'`
    else
	elderberry=`df $dirname > /dev/null 2>&1`
	if [  $? -eq 0  ]
	then
	    # spsu style output
	    kbytes=`df $dirname 2>/dev/null | egrep -v '[Aa]vail' | sed -e '
{
s/^[^ 	]*[ 	]*[0-9]*[ 	]*[0-9]*[ 	]*\([0-9]*\).*$/\1/
q
}'`
	    if [ "x$kbytes" = "x" ]
	    then
		kbytes=`df $dirname 2>/dev/null | sed -e '
{
s/.*[ 	]*.*:[ 	]*\([0-9]*\)[ 	]*blocks.*$/\1/
q
}'`
	    case "$kbytes" in
		    *free*) # rsai03* old style
			dk_space=`df $dirname 2>/dev/null | grep -v free  | sed -e '
{
s/^[^   ]*[ 	]*[0-9]*[ 	]*\([0-9]*\).*$/\1/
q
}'`
		    if [ -n "$dk_space" ]
			then
			    kbytes=$dk_space
			fi
		    ;;
		    *)
			dd of=$_path/._._._ bs=1000 if=/bin/ls count=1 > /dev/null 2>&1
			sz=`du -s $_path/._._._`
			sz=`expr "$sz" : '\([0-9]*\).*'`
			rm -f $_path/._._._
			case $sz in
			2*)
				kbytes=`expr $kbytes / $sz`
			    ;;
			    *)
			    ;;
			esac
		esac
	    fi
	else
	    dd of=$_path/._._._ bs=1000 if=/bin/ls count=1 > /dev/null 2>&1
	    sz=`du -s $_path/._._._`
	    sz=`expr "$sz" : '\([0-9]*\).*'`
	    rm -f $_path/._._._
	    while [ "$dirname" != "" ]
	    do
		kbytes=`df 2>/dev/null | egrep "^$dirname[ 	]*\(.*$" | sed -e '
{
s/^[^\)]*.:[ 	]*\([0-9]*\)[ 	]*blocks.*$/\1/
q
}'`
	    if [ "$kbytes" != "" -o "$dirname" = "/"  ]
		then
		    break
		fi
if [ -z "$dirname" ]; then
  dirname=.
else
  dirname=`expr "$dirname/" : '\(/\)/*[^/]*//*$'  \| \
    "$dirname/" : '\(.*[^/]\)//*[^/][^/]*//*$' \| \
    .`
fi

	    done
	    case $sz in
		2*)
		    kbytes=`expr $kbytes / $sz`
		;;
		*)
		;;
	    esac
	fi
    fi
fi

cd $origdir

	if [ "${kbytes}0" -gt "${NEEDKB}0" ]; then
	    a_InstDir=$a_definstdir
	fi
    fi

    a_Restart=$a_yes

    a_AsadPort=3144

    a_PeerDNS=""
    [ -n "$ASK_PEERDNS" ] && a_PeerDNS=`$ASK_PEERDNS`

    a_httpport=${apachePort:-80}

    upgrade=""
    dupgrade=false # dubious "upgrade", following an uninstall

    # get configuration info for an existing installed tta package
    jive_PkgInst="" jive_InstDir="" jive_DataDir="" jive_Build="" 
    if [ -s "$a_InstDir/etc/pkg/rpm_tta_upgradefrom" ]; then
	# RPM -> RPM upgrade case
	jive_PkgInst="tta"
	jive_InstDir="$a_InstDir"
	jive_DataDir="$a_InstDir/var"
	jive_Build=`cat $a_InstDir/etc/pkg/rpm_tta_upgradefrom`
    else
# find the latest instance of the package
instver=0
pkginst=''
# get the package name
shortpkgname=`echo tta | sed 's,^\(.*\)\..*$,\1,'`
# get info on instances of this package
pkginfo=`pkginfo $shortpkgname.\* 2>/dev/null`
res=$?
if [ $res -eq 0 ]; then
    pkginfo=`echo "$pkginfo" | awk '{printf (" %s ",$2)}'`
    # return the first one (in case none have INSTVER set)
    pkginst=`echo $pkginfo | awk '{print $1}'`
    for inst in $pkginfo
    do
	thisinst=`pkgparam $inst INSTVER 2>/dev/null`
	if [ -n "$thisinst" ]; then
	    if [ "$thisinst" -gt "$instver" ]; then
		instver=$thisinst
		pkginst=$inst
	    fi
	fi
    done
fi

	if [ "${res}0" -eq 0 ]; then
	    jive_InstDir=`pkgparam $pkginst INSTDIR 2>/dev/null`
	    # sanity check
	    if [ -z "`pkginfo -l $pkginst 2>/dev/null | grep INSTDATE:`" -o ! -f "${jive_InstDir}/bin/bin/ttaauxserv" ]; then
		jive_InstDir=""
	    else
		jive_DataDir=${jive_InstDir}/var
		jive_Build=`pkgparam $pkginst BUILD 2>/dev/null`
		jive_PkgInst=$pkginst
	    fi
	fi
    fi

    # Not really upgrading either, but maybe upgrading following an uninstall.
    if [ -z "$jive_InstDir" -a -r "$a_InstDir/var/pkginfo" ]; then
	jive_InstDir=`sed -n 's;INSTDIR=\(.*\);\1;p' $a_InstDir/var/pkginfo`
	jive_DataDir=${jive_InstDir}/var
	jive_Build=`sed -n 's;BUILD=\(.*\);\1;p' $a_InstDir/var/pkginfo`
	jive_PkgInst=""
	dupgrade=true
	if [ -z "$jive_InstDir" -o -z "$jive_Build" ]; then
	    jive_InstDir="" jive_DataDir="" jive_Build="" upgrade="" oldver="" dupgrade=false
	fi
    fi

    # if there is an existing install, try to reuse the peer DNS name, may 
    # not be the same as what is returned by ttahostname, fitz/600820
    localbootstrap="$jive_InstDir/var/serverconfig/local/bootstrap.properties"
    if [ -r "$localbootstrap" ]; then
        origpeername=`sed -n 's;^tarantella.config.server.dns.peer=\(.*\);\1;p' "$localbootstrap"`
        [ ! -z $origpeername ] && a_PeerDNS=$origpeername
    fi

    # care, changes & sets a number of vars
if [ -n "$jive_InstDir" -a "${dupgrade}" = "false" ]; then
  # Re-install or upgrade of a Jive package: use existing values
  a_InstDir=$jive_InstDir
  upgrade=$jive_Build

  # Check for compatibilities
_tmp=`echo $jive_Build | sed -e 's/\([0-9][0-9]*\)\.\([0-9]\)\([0-9]*\)\.\([0-9][0-9]*\)/\1 \2 \3 \4/'`
read _omajor _ofeature _obug _obuild <<EOF
$_tmp
EOF

_tmp=`echo $PRODUCT_VERSION_FULL | sed -e 's/\([0-9][0-9]*\)\.\([0-9]\)\([0-9]*\)\.\([0-9][0-9]*\)/\1 \2 \3 \4/'`
read _nmajor _nfeature _nbug _nbuild <<EOF
$_tmp
EOF

if [ $jive_Build = $PRODUCT_VERSION_FULL ]; then
	INSTTYPE=$a_reinstall
elif [ $_omajor -lt $_nmajor ]; then
	INSTTYPE=$a_upgrade
elif [ $_omajor = $_nmajor -a $_ofeature -lt $_nfeature ]; then
	INSTTYPE=$a_upgrade
elif [ $_omajor = $_nmajor -a $_ofeature = $_nfeature -a $_obug -lt $_nbug ]; then
	INSTTYPE=$a_upgrade
elif [ $_omajor = $_nmajor -a $_ofeature = $_nfeature -a $_obug = $_nbug -a $_obuild -lt $_nbuild ]; then
	INSTTYPE=$a_upgrade
else
	INSTTYPE=$a_downgrade
fi


  # We don't allow downgrades
  [ "$INSTTYPE" = "$a_downgrade" ] && {
    echo "a_installtype='$INSTTYPE'; export a_installtype; 
    oldver='$jive_Build'; export oldver;" >$RESPONSE
    return $CANT_DOWNGRADE
  }
  # Check it's a supported upgrade
suppupgrade=f
# get supported upgrade list as a pipe-delimited pattern
_supported_upgrades=`echo "$SUPPORTED_UPGRADES" | tr ' ' '|'`
[ -n "$jive_Build" ] && suppupgrade=`/bin/sh -c "\
    case $jive_Build in
    $_supported_upgrades) echo t;;
    *) echo f
    esac"`

  [ "$suppupgrade" = "f" ] && {
    echo "a_installtype='$INSTTYPE'; export a_installtype; 
    oldver='$jive_Build'; export oldver;" >$RESPONSE
    return $CANT_UPGRADE
  }
else
  INSTTYPE="$a_install"
  suppupgrade=f
fi


    # only set during install - only time we'll uninstall anything.
    p_oldpkg=""
    if [ "$ASK_INSTDIR" = "t" ]; then
	# Check for pkg compatibility
	incompat=""
	compat_file=$REQDIR/${PKG}compat
if [ -f $compat_file ]; then
  # can we work with them?
  incompat="`
    egrep -v \"^$|^[# ]\" $compat_file | while read c_switch c_pkg c_reqver; do
      if [ ! -z \"$c_pkg\" ]; then 
# find the latest instance of the package
theinstver=0
c_target=''
# get the package name
shortpkgname=\`echo $c_pkg | sed 's,^\(.*\)\..*$,\1,'\`
# get info on instances of this package
pkginfo=\`pkginfo $shortpkgname.\* 2>/dev/null\`
res=$?
if [ $res -eq 0 ]; then
    pkginfo=\`echo \"$pkginfo\" | awk '{printf (\" %s \",$2)}'\`
    # return the first one (in case none have INSTVER set)
    c_target=\`echo $pkginfo | awk '{print $1}'\`
    for inst in $pkginfo
    do
	thisinst=\`pkgparam $inst INSTVER 2>/dev/null\`
	if [ -n \"$thisinst\" ]; then
	    if [ "$thisinst" -gt "$theinstver" ]; then
		theinstver=$thisinst
		c_target=$inst
	    fi
	fi
    done
fi

      fi
      [ ! -z \"$c_target\" ] && c_instver=\`pkgparam $c_target BUILD 2>/dev/null\` || continue 
      [ $? -ne 0 ] && continue # not installed
_omajor=\`echo $c_instver | sed -e 's;\([0-9][0-9]*\)\..*;\1;'\`
_ofeature=\`echo $c_instver | sed -e 's;[0-9][0-9]*\.\([0-9]\)[0-9]\..*;\1;'\`
_obug=\`echo $c_instver | sed -e 's;[0-9][0-9]*\.[0-9]\([0-9]*\)\..*;\1;'\`
_obuild=\`echo $c_instver | sed -e 's;[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\);\1;'\`


_nmajor=\`echo $c_reqver | sed -e 's;\([0-9][0-9]*\)\..*;\1;'\`
_nfeature=\`echo $c_reqver | sed -e 's;[0-9][0-9]*\.\([0-9]\)[0-9]\..*;\1;'\`
_nbug=\`echo $c_reqver | sed -e 's;[0-9][0-9]*\.[0-9]\([0-9]*\)\..*;\1;'\`
_nbuild=\`echo $c_reqver | sed -e 's;[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\);\1;'\`


if [ $c_instver = $c_reqver ]; then
	c_allow=t
elif [ $_omajor -lt $_nmajor ]; then
	c_allow=f
elif [ $_omajor = $_nmajor -a $_ofeature -lt $_nfeature ]; then
	c_allow=f
elif [ $_omajor = $_nmajor -a $_ofeature = $_nfeature -a $_obug -lt $_nbug ]; then
	c_allow=f
elif [ $_omajor = $_nmajor -a $_ofeature = $_nfeature -a $_obug = $_nbug -a $_obuild -lt $_nbuild ]; then
	c_allow=f
else
	c_allow=t
fi

      [ "$c_allow" = "f" ] && echo "$c_target"
      c_pkg=""
    done`"
fi

	incompat=" `echo $incompat | tr \"\n\" \" \"` "
 
	# need to do this here instead of postinstall to catch a reinstall, where compat would be OK,
	# but depends wouldn't.

	# Uninstall all other instances
# get the package name
shortpkgname=`echo $PKG | sed 's,^\(.*\)\..*$,\1,'`
# get info on instances of this package
pkginfo=`pkginfo $shortpkgname.\* 2>/dev/null | awk '{printf (" %s ",$2)}'`
res=$?
if [ $res -eq 0 ]; then
    # get list of package instances
    oldpkgtmp="$pkginfo"
else
    oldpkgtmp=""
fi

	# also remove all "ttapatch" packages
# get the package name
shortpkgname=`echo ttapatch | sed 's,^\(.*\)\..*$,\1,'`
# get info on instances of this package
pkginfo=`pkginfo $shortpkgname.\* 2>/dev/null | awk '{printf (" %s ",$2)}'`
res=$?
if [ $res -eq 0 ]; then
    # get list of package instances
    oldttapatch="$pkginfo"
else
    oldttapatch=""
fi


	oldpkg=" $oldttapatch $incompat $oldpkgtmp "
	
	# Look for any other old dependent packages
	pkgDirs=""
	[ -n "${jive_InstDir}" ] && pkgDirs="${pkgDirs} ${jive_InstDir}/etc/pkg"
	for pkgDir in ${pkgDirs}; do
	    for dependFile in ${pkgDir}/*/depend; do
		case "${dependFile}" in
		*/pkg/tta/depend|*/pkg/tta.*/depend)
		    # base pack entry, therefore not a dependent
		    ;;
		*)  dependentPkg=`expr "${dependFile}" : '.*/pkg/\([^/]*\)/depend'`
		    basePkg=`cat ${dependFile} 2>/dev/null`
		    case "${basePkg}" in
		    # $PKGINST)
			# The base pack is the package currently being installed:
			# we don't want to uninstall its dependents.
			# echo "basePkg=$basePkg  PKGINST=$PKGINST"
			# ;;
		    *)
			# use and keep spaces so ttasecure doesn't match ttasecure.2
			if [ `echo \"$oldpkg\" | grep " ${dependentPkg} " 1>/dev/null 2>&1; echo $?` -ne 0 ]; then
			    oldpkg=" ${dependentPkg} ${oldpkg} "
			fi
		    esac
		esac
	    done
	done
	
	# list of packages that we are going to uninstall
	# that we are going to tell the user about.
	for oldp in $oldpkg; do
	    case $oldp in
		tta|tta.* ) ;;
		tt*pip|tt*pip.* ) ;;
		ttawcp|ttawcp.* ) ;;
		ttapatch|ttapatch.* ) ;;
		ttexprsip|ttexprsip.* ) ;;
		ttajava|ttajava.* ) ;;
		* ) p_oldpkg="$oldp $p_oldpkg" ;;
	    esac
	done
    fi

    # if this is a reinstall or an upgrade 
    # and there is no crontab entry 
    # assume the user didnt want one
    # in the previous install
    if [ "$INSTTYPE" = "$a_reinstall" -o "$INSTTYPE" = "$a_upgrade" ]; then
	[ -z "$a_cron" ] && a_Archive=$a_no
    fi

    if [ "$INSTTYPE" = "$a_reinstall" -o "$suppupgrade" = "f" ]; then
	INSTMSG="$INSTTYPE $PRODUCT_VERSION_FULL"
    else
	INSTMSG="$INSTTYPE $jive_Build -> $PRODUCT_VERSION_FULL"
    fi

    qURetVal=$OK

    a_ArchiveOrig=$a_Archive
    a_Webtop=$a_no
    a_PrtSetup=$a_no

    # work out the rctype
_dummy_="" a_RcCurRun="" a_RcInstRun="" a_RcKillRun="" a_RcType="unknown" a_RcFile=""
if [ -d /etc/rc.d/rc2.d -o -d /etc/rc.d/rc3.d ]; then
  a_RcType="rcddir" a_RcFile="/etc/rc.d" _dummy_="/etc/rc.d" _rcbase="/etc/rc.d/rc"
  [ -d /etc/init.d ] && a_RcType="$a_RcType-initd"
elif [ -d /etc/rc2.d -o -d /etc/rc3.d ]; then
  a_RcType="svr4" a_RcFile="/etc" _dummy_="/etc" _rcbase="/etc/rc"
  [ -d /etc/init.d ] && a_RcType="$a_RcType-initd"
elif [ -d /sbin/rc2.d -o -d /sbin/rc3.d ]; then
  a_RcType="sbin" a_RcFile="/sbin" _dummy_="/sbin" _rcbase="/sbin/rc"
elif [ -f /etc/rc.local ]; then
  a_RcType="local" a_RcFile="/etc/rc.local"
elif [ -f /etc/rc.d/rc.local ]; then
  a_RcType="rcd" a_RcFile="/etc/rc.d/rc.local"
elif [ -f /etc/rc.nfs ]; then
  a_RcType="nfs" a_RcFile="/etc/rc.nfs"
elif [ -f /etc/rc ]; then
  a_RcType="basic" a_RcFile="/etc/rc"
fi
case "$a_RcType" in
svr4*|sbin|rcddir*)
  a_RcCurRun=`who -r 2>/dev/null | awk '{print $3;}'`
  [ ! -z "$a_RcCurRun" ] && {
    case $a_RcCurRun in [0-9]);; *) a_RcCurRun=`who -r 2>/dev/null | awk '{print $2;}'`;; esac;
  } || a_RcCurRun=`/sbin/runlevel 2>/dev/null | awk '{print $2}'`;
  [ -z "$a_RcCurRun" ] && a_RcCurRun=2 # guess
  a_RcKillRun=1
  for _i in 5 4 3 2 1 S; do
    [ -r ${_rcbase}${_i}.d/$INST_RCFILE ] && { a_RcInstRun=${_i}; break; }
  done
  _dummy_=$a_RcFile/rc$a_RcKillRun.d/_dummy_
  a_RcFile=$a_RcFile/rc$a_RcCurRun.d/$INST_RCFILE
esac

    a_RunLevel="$a_RcCurRun"
    [ -n "$a_RcInstRun" ] && a_RunLevel="$a_RcInstRun"

    SettingsOK="n"
    firsthdr=0
    insist=""
    show_insist_prompt=""
    while [ "$SettingsOK" = "n" ]; do

	##################################################################
	# Work out current license mode on basis of installed license numbers.
	# 
	licinfo_str=`GetLicInfo "$l_mode_eval" "$l_mode_eval2" "$l_mode_full" "$l_mode_full2" "$l_unlimited" "$LICINFO" "$PRODUCT_LICENSE_PRODUCT_CODE" "$a_LicenseKeys"`
	licmode=`expr "$licinfo_str" : '[^%]*%\([^%]*\)%.*'`
	licmode_ext=`expr "$licinfo_str" : '.*%\([^%]*\)$'`

	echo " "; echo " "
	summarystr="$l_summary"
echo $_ss_headlines
echo "$summarystr"
echo $_ss_headlines

	if [ "${firsthdr}0" -eq 0 ]; then
	    echo "$l_recommend"; echo " "
	    firsthdr=1
	else
	    echo " "; echo " "
	fi

	##################################################################
	# Display current settings
	#
	[ -n "$INSTTYPE" ] && echo "$q_installtype = $INSTMSG"
	[ -n "$ASK_INSTDIR" ] && echo "$q_instdir = $a_InstDir"
	[ -n "$ASK_PEERDNS" ] && echo "$q_peerdns = $a_PeerDNS"
	[ -n "$ASK_LICMODE" ] && echo "$h_licmode = ${licmode}${licmode_ext}"
        if [ -n "$ASK_HTTPPORT" -a "$INSTTYPE" != "$a_upgrade" ]; then
            httpinuse=`$TTA_TMPDIR/ttahostprobe localhost:$a_httpport`
            echo $N "$q_httpport = $a_httpport $C"
            [ "$httpinuse" = "y" ] && echo $N "$p_httpinuse$C" || echo $N "$p_httpnotinuse$C"
            echo " "
        fi
	if [ -n "$ASK_CRONTAB" ]; then
	    echo $N "$q_checkpoint = $a_Archive$C"
	    if [ "$a_Archive" = "$a_yes" ]; then
  case $a_CronDay in
    0 ) a_daystr="$l_sun";;
    1 ) a_daystr="$l_mon";;
    2 ) a_daystr="$l_tue";;
    3 ) a_daystr="$l_wed";;
    4 ) a_daystr="$l_thu";;
    5 ) a_daystr="$l_fri";;
    6 ) a_daystr="$l_sat";;
  esac

		echo $N " ($a_daystr $C"
		echo $N "$a_CronTime$q_hours)$C"
	    fi
	    echo
	fi
	if [ -n "$ASK_RC" ]; then
	    if [ "$a_RcType" != "unknown" ]; then
		case $a_RunLevel in
		2|3|4|5 ) 
		    ;;
		* ) case "$a_RcType" in
		    svr4*|sbin|rcddir*)
			echo $N "$q_restart = $a_Restart$C"
			if [ "$a_Restart" = "yes" -a "$a_RunLevel" != "" ]; then
			    echo " ($q_runlevel = $a_RunLevel)"
			else
			    echo " "
			fi
		    esac
		esac
	    fi
	fi
	[ -n "$ASK_WEBTOP" ] && echo "$q_webtop = $a_Webtop"
	[ -n "$ASK_PRINTER" ] && echo "$q_prtsetup = $a_PrtSetup"
	if [ ! -z "$p_oldpkg" ]; then
	    echo "$q_pkguninst"
	    for uninst in $p_oldpkg; do
		[ ! -z "$uninst" ] && echo " - `pkgparam $uninst NAME`"
	    done
	    echo "$q_pkguninst2"
	fi

	[ "$dupgrade" != "false" -a -n "${jive_Build}" ] && echo "${l_dupgrade}${jive_Build}${l_dupgrade1}"

	# Warn about unsupported upgrades from pre-release builds of same version
	if [ -n "$jive_Build" -a -n "$PRODUCT_VERSION_FULL" ]; then
	    oldVer=`expr "$jive_Build" : '\(.*\..*\)\..*'`
	    oldBld=`expr "$jive_Build" : '.*\..*\.\(.*\)'`
	    newVer=`expr "$PRODUCT_VERSION_FULL" : '\(.*\..*\)\..*'`
	    if [ -n "$oldVer" -a -n "$newVer" -a -n "$oldBld" ]; then
		[ "$oldVer" = "$newVer" -a "$oldBld" -lt 901 ] && echo "$l_unsupported_upgrade"
	    fi
	fi

	#
	##################################################################

        #  check there is enough space to (re)install
        # How much space is available in $a_InstDir?
case "$MACHINEARCH" in
i3li*|ppli*)  _kflag=kP;;
*)	_kflag=k
esac

_path=$a_InstDir
while [ ! -d "$_path" ]; do
if [ -z "$_path" ]; then
  _path=.
else
  _path=`expr "$_path/" : '\(/\)/*[^/]*//*$'  \| \
    "$_path/" : '\(.*[^/]\)//*[^/][^/]*//*$' \| \
    .`
fi

done
if [ -f /bin/pwd ]
then
    origdir=`/bin/pwd`
    cd "$_path"
    dir=`/bin/pwd`
else
    origdir=`pwd`
    cd "$_path"
    dir=`pwd`
fi

kbytes=""

dirname="$dir/"
apple=`df -${_kflag}l $dirname > /dev/null 2>&1`
if [ $? -eq 0 ]
then
    # NOT any of the following
    # pahp0901 axo10300 axo10400 spsu0412 spsu0413 spsu0414 rsai0302
    # rsai0401 rsai0402

    banana=`df -${_kflag}l $dirname 2>/dev/null | egrep '[Aa]vail' > /dev/null 2>&1`
    if [ $? -eq 0 ]
    then
	# NOT any of the following
	# i3sc0325 mpsx0543 pahp1001 pahp1100
	# System V style output
	kbytes=`(df -${_kflag} $dirname 2>/dev/null | egrep -v '[Aa]vail' | tr '\012' ' '; echo) | sed -e '
{
s/^[^ 	]*[ 	]*[a-zA-Z]*[ 	]*[0-9]*[ 	]*[0-9]*[ 	]*\([0-9]*\).*$/\1/
q
}'`
    else
	cumquat=`df -bl $dirname 2>/dev/null | grep "Kbytes free" > /dev/null 2>&1`
	if [ $? -eq 0 ]
	then
	    # pahp10* pahp11*


	    # pahp1002 core dumps if you try df -k on an NFS drive
	    # pahp1020 gives you the wrong info with df -b
	    #     but the right info with df -k !!!
	    # so use df -f and divide the answer
	    kbytes=`df -f $dirname 2>/dev/null | sed -e '
{
s/.*[	 ]*.*:[	 ]*\([0-9]*\)[	 ]*blocks.*$/\1/
q
}'`
	    kbytes=`expr $kbytes / 2`
	else
	    ## probably i3sc0325
	    kbytes=`df -${_kflag} $dirname 2>/dev/null | sed -e '
{
s/.*[ 	]*.*:[ 	]*\([0-9]*\)[ 	]*blocks.*$/\1/
q
}'`
	fi
    fi
else
    dewberry=`df -${_kflag} $dirname 2>/dev/null | grep Free > /dev/null 2>&1`
    if [ $? -eq 0 ]
    then
	# rsai04* style output
	kbytes=`df -${_kflag} $dirname 2>/dev/null | grep -v Free  | sed -e '
{
s/^[^ 	]*[ 	]*[0-9]*[ 	]*\([0-9]*\).*$/\1/
q
}'`
    else
	elderberry=`df $dirname > /dev/null 2>&1`
	if [  $? -eq 0  ]
	then
	    # spsu style output
	    kbytes=`df $dirname 2>/dev/null | egrep -v '[Aa]vail' | sed -e '
{
s/^[^ 	]*[ 	]*[0-9]*[ 	]*[0-9]*[ 	]*\([0-9]*\).*$/\1/
q
}'`
	    if [ "x$kbytes" = "x" ]
	    then
		kbytes=`df $dirname 2>/dev/null | sed -e '
{
s/.*[ 	]*.*:[ 	]*\([0-9]*\)[ 	]*blocks.*$/\1/
q
}'`
	    case "$kbytes" in
		    *free*) # rsai03* old style
			dk_space=`df $dirname 2>/dev/null | grep -v free  | sed -e '
{
s/^[^   ]*[ 	]*[0-9]*[ 	]*\([0-9]*\).*$/\1/
q
}'`
		    if [ -n "$dk_space" ]
			then
			    kbytes=$dk_space
			fi
		    ;;
		    *)
			dd of=$_path/._._._ bs=1000 if=/bin/ls count=1 > /dev/null 2>&1
			sz=`du -s $_path/._._._`
			sz=`expr "$sz" : '\([0-9]*\).*'`
			rm -f $_path/._._._
			case $sz in
			2*)
				kbytes=`expr $kbytes / $sz`
			    ;;
			    *)
			    ;;
			esac
		esac
	    fi
	else
	    dd of=$_path/._._._ bs=1000 if=/bin/ls count=1 > /dev/null 2>&1
	    sz=`du -s $_path/._._._`
	    sz=`expr "$sz" : '\([0-9]*\).*'`
	    rm -f $_path/._._._
	    while [ "$dirname" != "" ]
	    do
		kbytes=`df 2>/dev/null | egrep "^$dirname[ 	]*\(.*$" | sed -e '
{
s/^[^\)]*.:[ 	]*\([0-9]*\)[ 	]*blocks.*$/\1/
q
}'`
	    if [ "$kbytes" != "" -o "$dirname" = "/"  ]
		then
		    break
		fi
if [ -z "$dirname" ]; then
  dirname=.
else
  dirname=`expr "$dirname/" : '\(/\)/*[^/]*//*$'  \| \
    "$dirname/" : '\(.*[^/]\)//*[^/][^/]*//*$' \| \
    .`
fi

	    done
	    case $sz in
		2*)
		    kbytes=`expr $kbytes / $sz`
		;;
		*)
		;;
	    esac
	fi
    fi
fi

cd $origdir


        # Is it enough?
        if [ -n "$ASK_INSTDIR" -a "${kbytes}0" -le "${NEEDKB}0" ]; then   
	    show_insist_prompt=t
            SettingsOK="N"
            # tell the user there is not enough space
            echo " "; echo " "
            echo "$e_nospace1$a_InstDir"
            # but if they insist, let them ...
	    if [ -z "$insist" ]; then
		echo "$e_nospace2$NEEDKB$e_nospace3"
	    else
		echo "$e_carryonregardless"
		SettingsOK="Y"
	    fi
        else
            ## check if ok
            [ "${SettingsOK}" != "N" ] && SettingsOK="Y"
	fi

        # Are they trying to install in a sensible place?
	instdircontents=""
	[ -d "${a_InstDir}" ] && instdircontents=`ls "${a_InstDir}" | egrep -v '^(tmp.*|temp.*|tta.*|bin|etc|var|webserver)$'`
	if [ -n "${instdircontents}" ]; then
	    show_insist_prompt=t
	    SettingsOK="N"
	    # tell the user the prospective instdir is not empty
	    echo "${e_instdircontents1}${a_InstDir}${e_instdircontents2}`cd ${a_InstDir};ls -l \"${instdircontents}\"`"
	    # but if they insist, let them ...
	    if [ -n "$insist" ]; then
		echo "
$e_carryonregardless"
		SettingsOK="Y"
	    fi
        else
            ## check if ok
            [ "${SettingsOK}" != "N" ] && SettingsOK="Y"
	fi

        # check for HTTP port availability
        if [ -n "$ASK_HTTPPORT" -a "$INSTTYPE" != "$a_upgrade" -a "$httpinuse" = "y" ]; then
            echo "$e_httpport_inuse"
            get_httpport
            SettingsOK="n"
            continue
        fi

	extra_qprompt="${q_or_q}"
	case "$SettingsOK" in
	y|Y)
            echo " "
	    extra_qprompt=""
echo "$p_damage"
echo # blank line between prompt and question
_valid=false
while [ $_valid = false ]
do
  echo $N "$q_damage [$SettingsOK] $C"
  read _answer
  if [ -z "$_answer" ]
  then
    _answer="$SettingsOK"   # default
  fi
  case "$_answer" in y|Y|n|N|q|Q)_valid=true;;esac
done
SettingsOK="$_answer"

# the language can alter the behaviour of tr
SettingsOK=`echo $SettingsOK | LANG=C LC_ALL=C tr '[a-z]' '[A-Z]'`

        esac

	case "$SettingsOK" in
	q|Q)
	    echo " "
echo $_ss_headlines
echo "$h_nochange"
echo $_ss_headlines

	    # tell the wrapper script to exit quietly
	    echo "#USERQUIT" >>$TTA_TMPDIR/ttainst.cmds_to_webwrap 2>/dev/null
	    qURetVal=$QUIT
	    return $qURetVal
	    ;;
	n|N)
	    # User wants to change something
	    # Loop again
	    SettingsOK="n"
	    ;;
	y|Y)
	    if [ "${dupgrade}" != "false" ]; then
		dupgrade="${jive_Build}"
		[ -z "${dupgrade}" ] && dupgrade="0.00.000"
		jive_InstDir=""
		jive_DataDir=""
		jive_Build=""
		jive_PkgInst=""
		oldpkg=""
	    fi
	    [ "$INSTTYPE" = "${a_upgrade}" ] && a_httpport="%%oldhttpport"
	    echo \
"a_Archive='$a_Archive' export a_Archive
a_ArchiveOrig='$a_ArchiveOrig' export a_ArchiveOrig
a_AsadPort='$a_AsadPort' export a_AsadPort
a_CronDay='$a_CronDay' export a_CronDay
a_CronDayOrig='$a_CronDayOrig' export a_CronDayOrig
a_CronTime='$a_CronTime' export a_CronTime
a_CronTimeOrig='$a_CronTimeOrig' export a_CronTimeOrig
a_InstDir='$a_InstDir' export a_InstDir
a_LicenseKeys='$a_LicenseKeys' export a_LicenseKeys
a_PeerDNS='$a_PeerDNS' export a_PeerDNS
a_PrtSetup='$a_PrtSetup' export a_PrtSetup
a_RcCurRun='$a_RcCurRun' export a_RcCurRun
a_RcFile='$a_RcFile' export a_RcFile
a_RcInstRun='$a_RcInstRun' export a_RcInstRun
a_RcKillRun='$a_RcKillRun' export a_RcKillRun
a_RcType='$a_RcType' export a_RcType
a_Restart='$a_Restart' export a_Restart
a_RunLevel='$a_RunLevel' export a_RunLevel
a_Webtop='$a_Webtop' export a_Webtop
jive_InstDir='$jive_InstDir' export jive_InstDir
jive_DataDir='$jive_DataDir' export jive_DataDir
jive_Build='$jive_Build' export jive_Build
jive_PkgInst='$jive_PkgInst' export jive_PkgInst
oldpkg='$oldpkg' export oldpkg
a_httpport='$a_httpport' export a_httpport
dupgrade='$dupgrade' export dupgrade" >$RESPONSE
	    break ;;
	esac

	##################################################################
	# Installation directory
	#
	if [ -n "$ASK_INSTDIR" ]; then
	    echo " "; echo " "
echo $_ss_headlines
echo "$h_instdir"
echo $_ss_headlines

	    prompt="$p_instdir"; [ -n "$show_insist_prompt" ] && prompt="${prompt}${p_instdir_insist}"
echo "$prompt"
echo # blank line between prompt and question
_valid=false
while [ $_valid = false ]
do
  _valid2=false
  _tmp_dirname=""
  echo $N "$q_instdir$extra_qprompt [$a_InstDir] $C"
  read _dirname
  _tmp_dirname=`echo $N "$_dirname$C" | tr -ds '[\001-\037]@#$%^&*()|{}~?><' '+'`
  if [ "$_tmp_dirname" != "$_dirname" ]
  then
     _valid=false
  elif [ -z "$_dirname" ]
  then
    _dirname="$a_InstDir"   # default
    _valid=true
  fi
  if [ -d "$_dirname" ]
  then
    if [ "$_dirname" = "/" ]
    then
       _valid=false
    else
       _valid=true
       _valid2=true
       a_makeinstdir=$a_yes
    fi
  else
    _valid=true
    a_makeinstdir=$a_yes
  fi
  if [ -f "$_dirname" ]
  then
    echo "$m_isafile"
    _valid=false
  fi
  if [ "$_valid" = "true" ]
  then
     # find out if the first character is a / if not then _dirname is invalid
     case "$_dirname" in
     /*)  _valid=true ;;
     Q|q) _valid=true ;;
     *)   _valid=false
     esac
  fi
  if [ "$_valid" = "true" ]
  then
    while [ $_valid2 = false -a -n "" ]
    do
      echo $N " [$a_makeinstdir] $C"
      read _answer
      if [ -z "$_answer" ]
      then
        _answer="$a_makeinstdir"   # default
      fi
      case "$_answer" in
      [${a_case_yes}]*)
        a_makeinstdir=$s_yes
        _valid2=true
        _valid=true
        ;;
      [${a_case_no}]*)
        a_makeinstdir=$s_no
        _valid=false
        _valid2=true
      esac
    done
  fi
done
a_InstDir="$_dirname"

	    insist=""
	    case "$a_InstDir" in
	    *\!) a_InstDir=`expr "$a_InstDir" : '\(.*\).$'`; insist="t" ;;
	    q|Q) echo " "
echo $_ss_headlines
echo "$h_nochange"
echo $_ss_headlines

		# tell the wrapper script to exit quietly
		echo "#USERQUIT" >>$TTA_TMPDIR/ttainst.cmds_to_webwrap 2>/dev/null
		qURetVal=$QUIT
		return $qURetVal
	    esac
	fi
	show_insist_prompt=""

	# Not really upgrading either, but maybe upgrading following an uninstall.
	if [ -z "$pkginst" ]; then  # no current install
	    if [ -r "$a_InstDir/var/pkginfo" ]; then
		jive_InstDir=`sed -n 's;INSTDIR=\(.*\);\1;p' $a_InstDir/var/pkginfo`
		jive_DataDir=${jive_InstDir}/var
		jive_Build=`sed -n 's;BUILD=\(.*\);\1;p' $a_InstDir/var/pkginfo`
		jive_PkgInst=""
		dupgrade=true
		if [ -z "$jive_InstDir" -o -z "$jive_Build" ]; then
		    jive_InstDir="" jive_DataDir="" jive_Build="" upgrade="" oldver="" dupgrade=false
		fi	
	    else
		jive_InstDir="" jive_DataDir="" jive_Build="" upgrade="" oldver="" dupgrade=false
	    fi

	    # care, changes & sets a number of vars    
if [ -n "$jive_InstDir" -a "${dupgrade}" = "false" ]; then
  # Re-install or upgrade of a Jive package: use existing values
  a_InstDir=$jive_InstDir
  upgrade=$jive_Build

  # Check for compatibilities
_tmp=`echo $jive_Build | sed -e 's/\([0-9][0-9]*\)\.\([0-9]\)\([0-9]*\)\.\([0-9][0-9]*\)/\1 \2 \3 \4/'`
read _omajor _ofeature _obug _obuild <<EOF
$_tmp
EOF

_tmp=`echo $PRODUCT_VERSION_FULL | sed -e 's/\([0-9][0-9]*\)\.\([0-9]\)\([0-9]*\)\.\([0-9][0-9]*\)/\1 \2 \3 \4/'`
read _nmajor _nfeature _nbug _nbuild <<EOF
$_tmp
EOF

if [ $jive_Build = $PRODUCT_VERSION_FULL ]; then
	INSTTYPE=$a_reinstall
elif [ $_omajor -lt $_nmajor ]; then
	INSTTYPE=$a_upgrade
elif [ $_omajor = $_nmajor -a $_ofeature -lt $_nfeature ]; then
	INSTTYPE=$a_upgrade
elif [ $_omajor = $_nmajor -a $_ofeature = $_nfeature -a $_obug -lt $_nbug ]; then
	INSTTYPE=$a_upgrade
elif [ $_omajor = $_nmajor -a $_ofeature = $_nfeature -a $_obug = $_nbug -a $_obuild -lt $_nbuild ]; then
	INSTTYPE=$a_upgrade
else
	INSTTYPE=$a_downgrade
fi


  # We don't allow downgrades
  [ "$INSTTYPE" = "$a_downgrade" ] && {
    echo "a_installtype='$INSTTYPE'; export a_installtype; 
    oldver='$jive_Build'; export oldver;" >$RESPONSE
    return $CANT_DOWNGRADE
  }
  # Check it's a supported upgrade
suppupgrade=f
# get supported upgrade list as a pipe-delimited pattern
_supported_upgrades=`echo "$SUPPORTED_UPGRADES" | tr ' ' '|'`
[ -n "$jive_Build" ] && suppupgrade=`/bin/sh -c "\
    case $jive_Build in
    $_supported_upgrades) echo t;;
    *) echo f
    esac"`

  [ "$suppupgrade" = "f" ] && {
    echo "a_installtype='$INSTTYPE'; export a_installtype; 
    oldver='$jive_Build'; export oldver;" >$RESPONSE
    return $CANT_UPGRADE
  }
else
  INSTTYPE="$a_install"
  suppupgrade=f
fi

	    if [ "$INSTTYPE" = "$a_reinstall" -o "$suppupgrade" = "f" ]; then
		INSTMSG="$INSTTYPE $PRODUCT_VERSION_FULL"
	    else
		INSTMSG="$INSTTYPE $jive_Build -> $PRODUCT_VERSION_FULL"
	    fi

	fi

	##################################################################
	# Peer DNS name
	#
	if [ -n "$ASK_PEERDNS" ]; then
            echo " "; echo " "
echo $_ss_headlines
echo "$h_peerdns"
echo $_ss_headlines


echo "$p_peerdns"
echo # blank line between prompt and question
_valid=false
while [ $_valid = false ]
do
  echo $N "$q_peerdns [$a_PeerDNS] $C"
  read _answer
  if [ -z "$_answer" ]
  then
    _answer="$a_PeerDNS"   # default
  fi
  _valid=true
done
a_PeerDNS="$_answer"

	fi


        [ "$INSTTYPE" != "$a_upgrade" ] && get_httpport 

	##################################################################
	# Archive logs weekly?
	#
	if [ -n "$ASK_CRONTAB" ]; then
echo; echo
echo $_ss_headlines
echo "$h_checkpoint"
echo $_ss_headlines

echo "$p_checkpoint"
echo # blank line between prompt and question
_valid=false
while [ $_valid = false ]
do
  echo $N "$q_checkpoint [$a_Archive] $C"
  read _answer
  if [ -z "$_answer" ]
  then
    _answer="$a_Archive"   # default
  fi
  case "$_answer" in
    [${a_case_yes}]* )
	    _answer=$s_yes
	    _valid=true
	    ;;
    [${a_case_no}]* )
	    _answer=$s_no
	    _valid=true
	    ;;
  esac
done
a_Archive="$_answer"

     
	    if [ "$a_Archive" = "$a_yes" ]; then
echo "$p_checkday"
_valid=false
while [ $_valid = false ]
do
  echo $N "$q_checkday [$a_CronDay] $C"
  read _answer
  if [ -z "$_answer" ]
  then
    _answer="$a_CronDay"   # default
  fi
  case "$_answer" in
  [0-6] )
      _valid=true
      a_CronDay=$_answer
      ;;
  *)
    echo "$v_badday"
    ;;
  esac
done

echo "$p_checktime"
_valid=false
while [ $_valid = false ]
do
  echo $N "$q_checktime [$a_CronTime] $C"
  read _answer
  if [ -z "$_answer" ]
  then
    _answer="$a_CronTime"   # default
  fi
  case "$_answer" in
  [0-9]|[0-9][0-9])
    if [ `expr $_answer \< 24` != "0" ]; then
      _valid=true
      a_CronTime=$_answer
    else
      echo "$v_badnumber"
    fi
    ;;
  *)
    echo "$v_badnumber"
    ;;
  esac
done

	    fi
	fi

	##################################################################
	# Restart Tarantella on system reboot?
	#
	if [ -n "$ASK_RC" ]; then
	    if [ "$a_RcType" != "unknown" ]; then
		a_Restart="yes"
		case "$a_RunLevel" in
		2|3|4|5 ) 
		    ;;
		* ) case "$a_RcType" in
		    svr4*|sbin|rcddir*)
echo; echo
echo $_ss_headlines
echo "$h_restart"
echo $_ss_headlines

echo "$p_restart"
echo # blank line between prompt and question
_valid=false
while [ $_valid = false ]
do
  echo $N "$q_restart [$a_Restart] $C"
  read _answer
  if [ -z "$_answer" ]
  then
    _answer="$a_Restart"   # default
  fi
  case "$_answer" in
    [${a_case_yes}]* )
	    _answer=$s_yes
	    _valid=true
	    ;;
    [${a_case_no}]* )
	    _answer=$s_no
	    _valid=true
	    ;;
  esac
done
a_Restart="$_answer"

			
			if [ "$a_Restart" = "yes" ]
			then
case "$a_RcType" in
"svr4"|"sbin")
  if [ "$a_RcType" = "svr4" ]
  then
    _rcbase=/etc/rc
  else
    _rcbase=/sbin/rc
  fi

  # check the installed runlevel
  _instrun=""
  for _i in S 1 2 3 4 5
  do
    if [ -f "$_rcbase$_i.d/$INST_RCFILE" ]
    then
      _instrun=$_i
      break
    fi
  done

  # check the current run level
  _currun=`who -r 2>/dev/null | awk '{print $3;}'`
  [ ! -z "$_currun" ] && {
    case $_currun in [0-9]);; *) _currun=`who -r 2>/dev/null | awk '{print $2;}'`;; esac;
  } || _currun=`/sbin/runlevel 2>/dev/null | awk '{print $2}'`;
  [ -z "$_currun" ] && _currun=2 # guess

  # display all known information
  echo "$p_runlevel"
  if [ ! -z "$_currun" ]
  then
    echo "$p_currun$_currun"
    a_RunLevel=$_currun
  fi
  if [ ! -z "$_instrun" ]
  then
    echo "$p_instrun$_instrun"
    a_RunLevel=$_instrun
  fi

  _valid="false"
  while [ $_valid = false ]
  do
    echo $N "$q_runlevel [$a_RunLevel] $C"
    read _answer
    if [ -z "$_answer" ]
    then
      _answer="$a_RunLevel"   # default
    fi
    case "$_answer" in
    "s")
      _answer="S"
      ;;
    "1"|"2"|"3"|"4"|"S")
      ;;
    *)
      echo "$v_runlevel"
      continue
      ;;
    esac

    # check the rcdir exists
    if [ ! -d $_rcbase$_answer.d ]
    then
      _valid2=false
      while  [ "$_valid2" != "true" ]
      do
        echo $N "$q_mkrcdir [$a_yes] $C"
        read _answer2
        if [ -z "$_answer2" ]
        then
          _answer2=$a_yes
        fi
        case "$_answer2" in
        [${a_case_yes}]*)
          _valid2=true
          _valid=true
          ;;
        [${a_case_no}]*)
          _valid2=true
        esac
      done
    else
      _valid=true
    fi
  done

  a_RunLevel="$_answer"
  a_RcFile=$_rcbase$a_RunLevel.d/$INST_RCFILE
  ;;
"local")
  a_RcFile=/etc/rc.local
  ;;
"rcd")
  a_RcFile=/etc/rc.d/rc.local
  ;;
"nfs")
  a_RcFile=/etc/rc.nfs
  ;;
"basic")
  a_RcFile=/etc/rc
  ;;
*)
  a_RcFile=""
  ;;
esac

			fi
		    esac
		esac
	    fi
	fi

	##################################################################
	# Create default webtop objects?
	#
	if [ -n "$ASK_WEBTOP" ]; then
echo; echo
echo $_ss_headlines
echo "$h_webtop"
echo $_ss_headlines

echo "$p_webtop"
echo # blank line between prompt and question
_valid=false
while [ $_valid = false ]
do
  echo $N "$q_webtop [$a_Webtop] $C"
  read _answer
  if [ -z "$_answer" ]
  then
    _answer="$a_Webtop"   # default
  fi
  case "$_answer" in
    [${a_case_yes}]* )
	    _answer=$s_yes
	    _valid=true
	    ;;
    [${a_case_no}]* )
	    _answer=$s_no
	    _valid=true
	    ;;
  esac
done
a_Webtop="$_answer"

	fi

	##################################################################
	# Create Tarantella printer?
	#
	if [ -n "$ASK_PRINTER" ]; then
echo; echo
echo $_ss_headlines
echo "$h_prtsetup"
echo $_ss_headlines

echo "$p_prtsetup"
echo # blank line between prompt and question
_valid=false
while [ $_valid = false ]
do
  echo $N "$q_prtsetup [$a_PrtSetup] $C"
  read _answer
  if [ -z "$_answer" ]
  then
    _answer="$a_PrtSetup"   # default
  fi
  case "$_answer" in
    [${a_case_yes}]* )
	    _answer=$s_yes
	    _valid=true
	    ;;
    [${a_case_no}]* )
	    _answer=$s_no
	    _valid=true
	    ;;
  esac
done
a_PrtSetup="$_answer"

	fi
    done

    return $qURetVal
}
