#!/bin/sh
#
# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
# $Id: request.sh 109678 2015-03-31 12:27:33Z pc161604 $
#
##########################################
##########################################
if [ -f /tmp/pkgadd.debug ]; then
    echo "Debug Output On"
    echo "---------------"
    echo " "
    set
    set -x	
    trace=x export trace
fi

[ ! -f /tmp/tta_noreqcd ] && cd /tmp

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

# version number in the licenses:
LICVERSION=3

#versioninfo
# Version numbers
PRODUCT_VERSION="5.60.514"
PRODUCT_VERSION_FULL="5.60.514"
PRODUCT_VERSION_MAJOR=5
PRODUCT_VERSION_FEATURE=6
PRODUCT_VERSION_BUG=0
PRODUCT_VERSION_BUILD=514
PRODUCT_VERSION_BUILD_DECIMAL=514
PRODUCT_VERSION_AS_NUMBER=560514
PRODUCT_VERSION_CAB=5,6,0,514
PRODUCT_VERSION_RPM=5.60-514

# Product names
PRODUCT_FULL_NAME="Oracle Secure Global Desktop"
PRODUCT_SHORT_NAME="Secure Global Desktop"
PRODUCT_IDENT="SSGD"
PRODUCT_SHORT_FILENAME="Tarantella"
PRODUCT_LSBSCRIPTNAME="sun.com-sgd-base"
PRODUCT_LSBSCRIPT_RUN_LEVEL="90"
TSP_FULL_NAME="Oracle Secure Global Desktop Security Pack"
TSP_SHORT_NAME="Security Pack"
WCP_FULL_NAME="Oracle Secure Global Desktop Windows Connectivity Pack"
WCP_SHORT_NAME="Windows Connectivity Pack"
TN3270_FULL_NAME="Oracle Secure Global Desktop Mainframe Connectivity Pack"
TN3270_SHORT_NAME="Mainframe Connectivity Pack"
AS400_FULL_NAME="Oracle Secure Global Desktop AS/400 Connectivity Pack"
AS400_SHORT_NAME="AS/400 Connectivity Pack"
S1PSTK_FULL_NAME="Oracle Secure Global Desktop Channel for Sun ONE Portal Server"
S1PSIP_FULL_NAME="Oracle 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="Oracle Secure Global Desktop Native Client for Windows 3.1"
NATIVE_WIN16_SHORT_NAME="Native Client for Windows 3.1"
NATIVE_WIN32_FULL_NAME="Oracle 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="Oracle Secure Global Desktop Native Client for Wyse"
NATIVE_WYSE_SHORT_NAME="Native Client for Wyse"
NATIVE_FULL_NAME="Oracle Secure Global Desktop Native Client"
NATIVE_SHORT_NAME="Native Client"
NATIVE_REGISTRY_NAME="Tarantella Native Client"
INTCLI_FULL_NAME="Oracle Secure Global Desktop Client"
INTCLI_SHORT_NAME="Client"
TCC_FULL_NAME="Oracle Secure Global Desktop Client"
TCC_HELPER_NAME="Oracle Secure Global Desktop Client Helper"
TCC_ACTIVEX_NAME="Oracle Secure Global Desktop ActiveX Control"
TCC_PLUGIN_NAME="Oracle Secure Global Desktop Netscape Plug-in"
T3COMPONENT_WIN_NAME="Oracle Secure Global Desktop Enhancement Module for Windows"
T3COMPONENT_UNIX_NAME="Oracle Secure Global Desktop Enhancement Module for UNIX(TM) and Linux Platforms"
T3COMPONENT_SHORT_UNIX_NAME="tem"
T3COMPONENT_NAME="Oracle Secure Global Desktop Enhancement Module"
T3COMPONENT_LSBSCRIPTNAME="sun.com-sgd-em"
T3COMPONENT_LSBSCRIPT_RUN_LEVEL="90"
GWCOMPONENT_UNIX_NAME="Oracle Secure Global Desktop Gateway for UNIX(TM) and Linux Platforms"
GWCOMPONENT_NAME="Oracle Secure Global Desktop Gateway"
GWCOMPONENT_SHORTNAME="SGD Gateway"
GWCOMPONENT_LSBSCRIPTNAME="sun.com-sgd-gw"
GWCOMPONENT_LSBSCRIPT_RUN_LEVEL="91"

# 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"
WEBSTART_JAR_NAME="sgdwscs"
ARCHIVE_SUFFIX="K"

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

PRODUCT_VENDOR="Oracle Corporation, Inc."
PRODUCT_SHORT_VENDOR="Oracle"

# 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"

# Top-level item names in ENS datastore
DEFAULT_ROOT_ENS="organization"
SYSTEM_ROOT_ENS="Tarantella System Objects"
APP_ROOT_ENS="applications"
APPSERVER_ROOT_ENS="appservers"

WEB_SERVICES_VERSION=1.9
# Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
# Modify these lists whenever the list of supported upgrades changes.
#
# The lists are egrep regular expressions.  Spaces can be inserted
# for readability: they are squeezed out at run time.
#
# POSSIBLE_UPGRADES is a full list of previous versions which stand
# a reasonable chance of being upgradable, although they may not
# necessarily all be supported.
#
# SUPPORTED_UPGRADES are the previous versions from which upgrades
# are officially supported.  SUPPORTED_UPGRADES should either be
# identical to POSSIBLE_UPGRADES, or a subset of POSSIBLE_UPGRADES.
#
POSSIBLE_UPGRADES='4\.63\.9[0-9][0-9] | 4\.71\.9[0-9][0-9] | 5\.(00|10|20|30)\.9[0-9][0-9]'
SUPPORTED_UPGRADES="${POSSIBLE_UPGRADES}"

#Marks RPM as obsoleting this version and below.
RPM_OBSOLETES=5.10
# the License Product Code
PRODUCT_LICENSE_PRODUCT_CODE="8388608"
TSP_US_LICENSE_PRODUCT_CODE="4194304"
TSP_INTL_LICENSE_PRODUCT_CODE="2097152"
USER_RESTRICTION="1"


# 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="--------------------------------------------------------------------------"

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


REQDIR=${INST_DATADIR}/${PKG}/reloc/etc/pkg/tta/install
[ -n ${TTA_RPM} -o -n ${TTA_DEVINSTALL} ] && REQDIR=${INST_DATADIR}/${PKG}/install
if [ ! -d "$REQDIR" ]
then
    echo "<--- $who_i_am"
    exit $FAIL
fi

TTA_TMPDIR=${TMPDIR:-/tmp}

[ ! -f /tmp/tta_noreqcd ] && cd ${TTA_TMPDIR}
LOGDIR=$TTA_TMPDIR
LOGFILE=$LOGDIR/$PKG.log
scriptname=`expr "//$0" : '.*/\(.*\)' `
chmod 640 $LOGFILE >/dev/null 2>&1
echo "---> $scriptname" >>$LOGFILE
chmod 640 $LOGFILE >/dev/null 2>&1
export LOGFILE


posslangs=`(cd "$REQDIR" ; ls ??-??_setup 2>/dev/null)`
case $posslangs in
  "" )						# no languages!
    PKGLANG=""
    echo "Can't find any language files in directory $REQDIR" >>$LOGFILE
    exit 1
  ;;
  ??-??_setup )    					# Good; just one
    PKGLANG=`expr "$posslangs" : "\(..-..\)"`
  ;;
  * )						# Choices, choices
    case $LANG in
      ""|C|POSIX )
      ;;					# Ignored
      * )					# Some OS specific string
        LA=`expr $LANG : "\(..\)"`    		# 1st two chars
        # must ensure tr uses C locale to lower case!
	la=`echo $LA | LANG=C LC_ALL=C tr '[A-Z]' '[a-z]'`
	goodlangs=`echo "$posslangs" | grep "^$la"`
	if [ -n "$goodlangs" ]
	then
	  posslangs=$goodlangs			# ones that match $LANG
        fi
	;;
    esac
    # Pick the first language in posslangs, or en-us if that is empty
    if [ -z "$posslangs" ]; then
	PKGLANG="en-us"
    else
	PKGLANG=`expr "$posslangs" : "\(..-..\)"`
    fi
  ;;
esac
if [ -n "$PKGLANG" ]; then
    # read the strings in
    . ${REQDIR}/${PKGLANG}_setup
    # store the strings file in the $PKGSAV directory
    if [ -n "${PKGSAV}" -a "${PKGSAV}" != "/" -a -d "${PKGSAV}" -a ! -f ${PKGSAV}/${PKGLANG}_setup ]; then
	cp ${REQDIR}/${PKGLANG}_setup ${PKGSAV}/${PKGLANG}_setup >/dev/null 2>&1
    fi
fi


# spinning cursor function
spin ()
{
  [ ! -d "$TTA_TMPDIR" ] && return
  B="\b"
  char1='|'
  char2='/'
  char3='-'
  char4='\\'
  sleepcmd="sleep"
  sleeptime="1"
  if [ -z "$sleeptime" ]; then sleeptime=1; fi
  if [ -z "$sleepcmd" ]; then sleeptime=""; fi

  if [ -f $TTA_TMPDIR/spinning ]; then
      #stop an existining spinner
      rm -f $TTA_TMPDIR/spinning >/dev/null 2>&1
      $sleepcmd $sleeptime
  fi
  touch $TTA_TMPDIR/spinning >/dev/null 2>&1
  set +x
  while [ -f $TTA_TMPDIR/spinning ]
  do
     if [ -f $TTA_TMPDIR/spinning ]; then
	echo $N $char1"$B$C"
     else
	break
     fi
     $sleepcmd $sleeptime
     if [ -f $TTA_TMPDIR/spinning ]; then
	echo $N $char2"$B$C"
     else
	break
     fi
     $sleepcmd $sleeptime
     if [ -f $TTA_TMPDIR/spinning ]; then
	echo $N $char3"$B$C"
     else
	break
     fi
     $sleepcmd $sleeptime
     if [ -f $TTA_TMPDIR/spinning ]; then
	echo $N $char4"$B$C"
      else
	break
      fi
     $sleepcmd $sleeptime
  done
  rm -f $TTA_TMPDIR/spinning >/dev/null 2>&1
  echo $N " $B$C"
}


NUSERS="0"
THISKEY=""
NEWUSERS="0"

${REQDIR}/checkinstall >/dev/null 2>&1 || exit $OK

# licinfo binary
LICINFO="$TTA_TMPDIR/licinfo"
cp ${REQDIR}/licinfo $LICINFO >/dev/null 2>&1
chmod 700 $LICINFO >/dev/null 2>&1

# ttaregisterinfo binary
TTAREGISTERINFO="$TTA_TMPDIR/ttaregisterinfo"
cp ${REQDIR}/ttaregisterinfo $TTAREGISTERINFO >/dev/null 2>&1
chmod 700 $TTAREGISTERINFO >/dev/null 2>&1

# ttahostname binary
TTAHOSTNAME="$TTA_TMPDIR/ttahostname"
cp ${REQDIR}/ttahostname $TTAHOSTNAME >/dev/null 2>&1
chmod 700 $TTAHOSTNAME >/dev/null 2>&1

TTAHOSTPROBE="$TTA_TMPDIR/ttahostprobe"
cp ${REQDIR}/ttahostprobe $TTAHOSTPROBE >/dev/null 2>&1
chmod 700 $TTAHOSTPROBE >/dev/null 2>&1

# setup response file
SAVE_FILE=$TTA_TMPDIR/tta.resp
chmod 777 $SAVE_FILE >/dev/null 2>&1

# how much space do we need
if [ -f $TTA_TMPDIR/tta.size ]; then
    kb_needed=`cat $TTA_TMPDIR/tta.size`
    res=$?; if [ $res -ne 0 ]; then kb_needed=0; fi
else
    # pkg is being installed by pkgadd not from
    # the shx file - let pkgadd deal with this
    kb_needed=0
fi

cleanup()
{
    trap '' 1 2 3 15
    echo "<--- $who_i_am" >>$LOGFILE
    rm -f $LICINFO >/dev/null 2>&1
    rm -f $TTAHOSTPROBE $TTAHOSTNAME >/dev/null 2>&1
    rm -f $SAVE_FILE $TTA_TMPDIR/spinning > /dev/null 2>&1
    rm -f $TTAREGISTERINFO >/dev/null 2>&1
    [ -n "${TTA_TMPDIR}" -a "${TTA_TMPDIR}" != "/" -a -f "${TTA_TMPDIR}/locale.tar" ] && rm -rf $TTA_TMPDIR/locale $TTA_TMPDIR/locale.tar 2>/dev/null
    return 0
}

cleanandexit()
{
    cleanup
    exit $1
}

trap 'cleanup; exit 1' 1 2 3 15

# INSERT-DIALOG-FILE-HERE (do not remove or change this line!)
# $Id: tta_setup,v 1.2 2015-03-31 12:24:26 pc161604 Exp $
#  Copyright 2005 Sun Microsystems, Inc. All rights reserved.
# Messages for the tarantella setup script.

tta_setup_desc="  setup              Changes Setup options, restores original objects"

l_errprefix="Error: "
lf_usage="Usage: tarantella setup
 - Changes Setup options, and optionally restores factory-default objects."

l_cantfindinstall="Setup couldn't find the $PRODUCT_SHORT_NAME installation."
l_cantchangeports="Setup can't change ports for an existing instance."
l_needasadport="You must supply an ASAD port number for a new instance."
l_needasadport="You must supply an SSL port number for a new instance."

l_nosuchdir="No such directory: "
l_filenotfound="File not found: "

l_cantupgrade1="Setup can't upgrade your database from version "
l_cantupgrade2="
to the current version."

l_errcantstart="An error occurred starting the $PRODUCT_SHORT_NAME server.
Setup will now exit."


# Log messages

l_creatingdir1="Creating directory "
l_creatingdir2="..."

l_creatingsymlink1="Creating symbolic link to "
l_creatingsymlink2="..."

l_copyingfiles1="Copying files from "
l_copyingfiles2="..."

l_running="Running "

l_removedb="Removing your existing database (if any)..."
l_movedb="Moving your existing database (if any)..."
l_stopserver="Stopping any server currently running"
l_servernotstopped="Server not stopped"

l_removing1="Removing everything in "
l_moving1="Moving everything in "
l_removing2="."
l_moving2=" to "

l_portnums1="Recording port numbers ("
l_portnums2=", "
l_portnums3=")..."

l_chgasad="Changing ASAD port. Stopping old server..."
l_chgsecure="Changing SSL port. Stopping old server..."

l_stoprestart="Trying to stop and restart the currently running server..."
l_trykill="Trying to kill the running server..."

####

# For setup summary heading
l_summary="Setting up $PRODUCT_FULL_NAME"
l_recommend="Setup recommends you use the following settings:"

####
# Add entry to rc file
h_restart="Start $PRODUCT_SHORT_NAME on reboot"
p_restart="\
Would you like the $PRODUCT_SHORT_NAME server to start automatically
when the UNIX host reboots?"
q_restart="Start $PRODUCT_SHORT_NAME on reboot?"
p_runlevel="
At which run level should the $PRODUCT_SHORT_NAME server start?
Choose from:
  S - Single-user mode
  1 - Administration mode
  2 - Multi-user mode
  3 - Remote file-sharing mode
  4 - Alternative remote file-sharing mode
"
p_currun="Current run level is: "
p_instrun="Currently installed at run level: "
q_runlevel="Run level"
q_mkrcdir="The correct run-level directory doesn't exist. Do you want to create
it?"
v_runlevel="The valid run levels are S, 1, 2, 3 and 4."

####
# Is it OK type stuff

p_damage="
Are these settings OK?
  Y - Yes, use these settings
  N - No, tell me more about the options and let me change the settings
  Q - Quit now"

q_damage="OK to use these settings?"

h_nochange="$PRODUCT_FULL_NAME Setup made no changes to your system"

h_change="$PRODUCT_FULL_NAME Setup made any changes you requested"

####
# Yes and No

a_case_y="yY"
a_case_yes="yY"
s_yes="yes"

a_case_n="nN"
a_case_no="nN"
s_no="no"

a_case_q="qQ"
a_case_quit="qQ"
s_quit="quit"

a_case_a="aA"

a_y="y"
a_n="n"
a_q="q"
a_a="a"

a_yes="yes"
a_no="no"
a_quit="quit"
a_auto="auto"

####
# Add entry to crontab to archive logs
h_checkpoint="Archive logs every week"
p_checkpoint="\
Would you like the $PRODUCT_SHORT_NAME server to archive its log files
every week?"
q_checkpoint="Archive logs every week?"
p_checktime="
At what time should the archive occur?
Type a number between 0 (midnight) and 23 (11pm).
"
q_checktime="Archive time"
q_hours=":00 hours"
v_badnumber="Please type a number from 0 to 23, inclusive."
p_checkday="
On what day should the archive occur?
Type a number between 0 (Sunday) and 6 (Saturday).
"
q_checkday="Archive day"
v_badday="Please type a number from 0 to 6, inclusive."

###
#ask whether to create the default webtop
h_webtop="Create default objects and webtop links"
p_webtop="\
Would you like Setup to recreate the default objects and webtop links,
as if this was a new installation?

Note: This won't remove any objects you've created, but it will
replace any objects with the same names as the originals."

q_webtop="Create default objects and webtop links?"
l_makingchanges="Setup is applying any changes"

l_removingoldpacks="
Removing old (upgraded) packs..."
#!/bin/sh
# $Id: setup_dialog.sh 144933 2017-02-08 09:50:25Z justin.carveley@oracle.com $
# Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
#
# Prompt user for setup information.
##########################################

machinearch ()
{
#!/bin/sh
#  $Id: ixiarch.sh 23561 2012-05-15 08:22:43Z ww161634 $
#  Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
#  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]*\)'`
       ;;
      # MacOS X (Intel)
      i386::Darwin::*::*)
        CPU=i3
        OS=dw
        NAME="Darwin (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]*\)'`
       ;;
      # 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`


preInstalledKeys=`cat $TTA_TMPDIR/LICENSE.tta 2>/dev/null`
apachePort=80 apacheSPort=443

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

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

#versioninfo
# Version numbers
PRODUCT_VERSION="5.60.514"
PRODUCT_VERSION_FULL="5.60.514"
PRODUCT_VERSION_MAJOR=5
PRODUCT_VERSION_FEATURE=6
PRODUCT_VERSION_BUG=0
PRODUCT_VERSION_BUILD=514
PRODUCT_VERSION_BUILD_DECIMAL=514
PRODUCT_VERSION_AS_NUMBER=560514
PRODUCT_VERSION_CAB=5,6,0,514
PRODUCT_VERSION_RPM=5.60-514

# Product names
PRODUCT_FULL_NAME="Oracle Secure Global Desktop"
PRODUCT_SHORT_NAME="Secure Global Desktop"
PRODUCT_IDENT="SSGD"
PRODUCT_SHORT_FILENAME="Tarantella"
PRODUCT_LSBSCRIPTNAME="sun.com-sgd-base"
PRODUCT_LSBSCRIPT_RUN_LEVEL="90"
TSP_FULL_NAME="Oracle Secure Global Desktop Security Pack"
TSP_SHORT_NAME="Security Pack"
WCP_FULL_NAME="Oracle Secure Global Desktop Windows Connectivity Pack"
WCP_SHORT_NAME="Windows Connectivity Pack"
TN3270_FULL_NAME="Oracle Secure Global Desktop Mainframe Connectivity Pack"
TN3270_SHORT_NAME="Mainframe Connectivity Pack"
AS400_FULL_NAME="Oracle Secure Global Desktop AS/400 Connectivity Pack"
AS400_SHORT_NAME="AS/400 Connectivity Pack"
S1PSTK_FULL_NAME="Oracle Secure Global Desktop Channel for Sun ONE Portal Server"
S1PSIP_FULL_NAME="Oracle 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="Oracle Secure Global Desktop Native Client for Windows 3.1"
NATIVE_WIN16_SHORT_NAME="Native Client for Windows 3.1"
NATIVE_WIN32_FULL_NAME="Oracle 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="Oracle Secure Global Desktop Native Client for Wyse"
NATIVE_WYSE_SHORT_NAME="Native Client for Wyse"
NATIVE_FULL_NAME="Oracle Secure Global Desktop Native Client"
NATIVE_SHORT_NAME="Native Client"
NATIVE_REGISTRY_NAME="Tarantella Native Client"
INTCLI_FULL_NAME="Oracle Secure Global Desktop Client"
INTCLI_SHORT_NAME="Client"
TCC_FULL_NAME="Oracle Secure Global Desktop Client"
TCC_HELPER_NAME="Oracle Secure Global Desktop Client Helper"
TCC_ACTIVEX_NAME="Oracle Secure Global Desktop ActiveX Control"
TCC_PLUGIN_NAME="Oracle Secure Global Desktop Netscape Plug-in"
T3COMPONENT_WIN_NAME="Oracle Secure Global Desktop Enhancement Module for Windows"
T3COMPONENT_UNIX_NAME="Oracle Secure Global Desktop Enhancement Module for UNIX(TM) and Linux Platforms"
T3COMPONENT_SHORT_UNIX_NAME="tem"
T3COMPONENT_NAME="Oracle Secure Global Desktop Enhancement Module"
T3COMPONENT_LSBSCRIPTNAME="sun.com-sgd-em"
T3COMPONENT_LSBSCRIPT_RUN_LEVEL="90"
GWCOMPONENT_UNIX_NAME="Oracle Secure Global Desktop Gateway for UNIX(TM) and Linux Platforms"
GWCOMPONENT_NAME="Oracle Secure Global Desktop Gateway"
GWCOMPONENT_SHORTNAME="SGD Gateway"
GWCOMPONENT_LSBSCRIPTNAME="sun.com-sgd-gw"
GWCOMPONENT_LSBSCRIPT_RUN_LEVEL="91"

# 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"
WEBSTART_JAR_NAME="sgdwscs"
ARCHIVE_SUFFIX="K"

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

PRODUCT_VENDOR="Oracle Corporation, Inc."
PRODUCT_SHORT_VENDOR="Oracle"

# 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"

# Top-level item names in ENS datastore
DEFAULT_ROOT_ENS="organization"
SYSTEM_ROOT_ENS="Tarantella System Objects"
APP_ROOT_ENS="applications"
APPSERVER_ROOT_ENS="appservers"

WEB_SERVICES_VERSION=1.9
# Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
# Modify these lists whenever the list of supported upgrades changes.
#
# The lists are egrep regular expressions.  Spaces can be inserted
# for readability: they are squeezed out at run time.
#
# POSSIBLE_UPGRADES is a full list of previous versions which stand
# a reasonable chance of being upgradable, although they may not
# necessarily all be supported.
#
# SUPPORTED_UPGRADES are the previous versions from which upgrades
# are officially supported.  SUPPORTED_UPGRADES should either be
# identical to POSSIBLE_UPGRADES, or a subset of POSSIBLE_UPGRADES.
#
POSSIBLE_UPGRADES='4\.63\.9[0-9][0-9] | 4\.71\.9[0-9][0-9] | 5\.(00|10|20|30)\.9[0-9][0-9]'
SUPPORTED_UPGRADES="${POSSIBLE_UPGRADES}"

#Marks RPM as obsoleting this version and below.
RPM_OBSOLETES=5.10
# the License Product Code
PRODUCT_LICENSE_PRODUCT_CODE="8388608"
TSP_US_LICENSE_PRODUCT_CODE="4194304"
TSP_INTL_LICENSE_PRODUCT_CODE="2097152"
USER_RESTRICTION="1"


#packageinfo
# Version numbers
PRODUCT_VERSION="5.60.514"
PRODUCT_VERSION_FULL="5.60.514"
PRODUCT_VERSION_MAJOR=5
PRODUCT_VERSION_FEATURE=6
PRODUCT_VERSION_BUG=0
PRODUCT_VERSION_BUILD=514
PRODUCT_VERSION_BUILD_DECIMAL=514
PRODUCT_VERSION_AS_NUMBER=560514
PRODUCT_VERSION_CAB=5,6,0,514
PRODUCT_VERSION_RPM=5.60-514

# Product names
PRODUCT_FULL_NAME="Oracle Secure Global Desktop"
PRODUCT_SHORT_NAME="Secure Global Desktop"
PRODUCT_IDENT="SSGD"
PRODUCT_SHORT_FILENAME="Tarantella"
PRODUCT_LSBSCRIPTNAME="sun.com-sgd-base"
PRODUCT_LSBSCRIPT_RUN_LEVEL="90"
TSP_FULL_NAME="Oracle Secure Global Desktop Security Pack"
TSP_SHORT_NAME="Security Pack"
WCP_FULL_NAME="Oracle Secure Global Desktop Windows Connectivity Pack"
WCP_SHORT_NAME="Windows Connectivity Pack"
TN3270_FULL_NAME="Oracle Secure Global Desktop Mainframe Connectivity Pack"
TN3270_SHORT_NAME="Mainframe Connectivity Pack"
AS400_FULL_NAME="Oracle Secure Global Desktop AS/400 Connectivity Pack"
AS400_SHORT_NAME="AS/400 Connectivity Pack"
S1PSTK_FULL_NAME="Oracle Secure Global Desktop Channel for Sun ONE Portal Server"
S1PSIP_FULL_NAME="Oracle 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="Oracle Secure Global Desktop Native Client for Windows 3.1"
NATIVE_WIN16_SHORT_NAME="Native Client for Windows 3.1"
NATIVE_WIN32_FULL_NAME="Oracle 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="Oracle Secure Global Desktop Native Client for Wyse"
NATIVE_WYSE_SHORT_NAME="Native Client for Wyse"
NATIVE_FULL_NAME="Oracle Secure Global Desktop Native Client"
NATIVE_SHORT_NAME="Native Client"
NATIVE_REGISTRY_NAME="Tarantella Native Client"
INTCLI_FULL_NAME="Oracle Secure Global Desktop Client"
INTCLI_SHORT_NAME="Client"
TCC_FULL_NAME="Oracle Secure Global Desktop Client"
TCC_HELPER_NAME="Oracle Secure Global Desktop Client Helper"
TCC_ACTIVEX_NAME="Oracle Secure Global Desktop ActiveX Control"
TCC_PLUGIN_NAME="Oracle Secure Global Desktop Netscape Plug-in"
T3COMPONENT_WIN_NAME="Oracle Secure Global Desktop Enhancement Module for Windows"
T3COMPONENT_UNIX_NAME="Oracle Secure Global Desktop Enhancement Module for UNIX(TM) and Linux Platforms"
T3COMPONENT_SHORT_UNIX_NAME="tem"
T3COMPONENT_NAME="Oracle Secure Global Desktop Enhancement Module"
T3COMPONENT_LSBSCRIPTNAME="sun.com-sgd-em"
T3COMPONENT_LSBSCRIPT_RUN_LEVEL="90"
GWCOMPONENT_UNIX_NAME="Oracle Secure Global Desktop Gateway for UNIX(TM) and Linux Platforms"
GWCOMPONENT_NAME="Oracle Secure Global Desktop Gateway"
GWCOMPONENT_SHORTNAME="SGD Gateway"
GWCOMPONENT_LSBSCRIPTNAME="sun.com-sgd-gw"
GWCOMPONENT_LSBSCRIPT_RUN_LEVEL="91"

# 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"
WEBSTART_JAR_NAME="sgdwscs"
ARCHIVE_SUFFIX="K"

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

PRODUCT_VENDOR="Oracle Corporation, Inc."
PRODUCT_SHORT_VENDOR="Oracle"

# 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"

# Top-level item names in ENS datastore
DEFAULT_ROOT_ENS="organization"
SYSTEM_ROOT_ENS="Tarantella System Objects"
APP_ROOT_ENS="applications"
APPSERVER_ROOT_ENS="appservers"

WEB_SERVICES_VERSION=1.9
# 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_GW_PKGNAME="SUNWsgdg"

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 ttasecure tta3270 tta5250 ttafandr ttafhang ttaficl ttaforie ttafscot"
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_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"

PRODUCT_PACKAGE_SPECIAL_PRENAME_SUNWsgdg=""
PRODUCT_PACKAGE_SPECIAL_NAME_SUNWsgdg=" Gateway"
PRODUCT_PACKAGE_CATEGORY_SUNWsgdg="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

GetPrivUsrGrp()
{
    cat ${INSTDIR}/var/serverconfig/global/array.properties 2>/dev/null | awk -F= \
	'BEGIN { u="ttasys"; wu="ttaserv"; g="ttaserv" }
	$1 == "tarantella.config.array.privilegeduser" { u = $2 }
	$1 == "tarantella.config.array.webserveruser" { wu = $2 }
	$1 == "tarantella.config.array.privilegedgroup" { g = $2 }
	END { print u " " wu " " g }'
}
_privusrgrp=`GetPrivUsrGrp`
privusr=`expr "$_privusrgrp" : '\([^ ]*\) .*'`
webservusr=`expr "$_privusrgrp" : '.* \([^ ]*\) .*'`
privgrp=`expr "$_privusrgrp" : '.* \([^ ]*\)$'`

    [ -z "${privusr}" ] && privusr="ttasys"
    [ -z "${privgrp}" ] && privgrp="ttaserv"

    NUSERS="0"
    THISKEY=""
    NEWUSERS="0"
    LICINFO=":"
    RESPONSE="/dev/null"
    NEEDKB="0"
    INSTTYPE=""
    INSTMSG=""
    GOTSTRINGS=""

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

    CALLER=""

    a_LicenseKeys=""

    ######################################################################
    # command-line args
    #
    while [ -n "$1" ]; do
	case "$1" in
	--caller=*)	CALLER=`expr "$1" : '.*=\(.*\)'`; shift;;
	--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_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;;
	--ask_instsecure) ASK_INSTSECURE="t"; shift;;
	*)  echo "$0: unknown arg '$1'" >&2
	    return $FAIL
	esac
    done
    INSTALLED_IN=""
    case "${CALLER}" in
    postinstall:*)
	INSTALLED_IN=`expr "${CALLER}" : '.*:\(.*\)'`
	CALLER="postinstall"
	;;
    esac

    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 ?) TTALANG=en-us;; esac
    tmpTTALANG=$TTALANG
    for a_lang in $posslangs; do
      output=`echo $a_lang | sed -e 's/.*\///'`
      if [ -f $output/common -o -f ../$output/common ]; then
	[ "$tmpTTALANG" != "en-us" ] && tmpTTALANG=$output
      fi
    done
    [ "$TTALANG" = "$tmpTTALANG" ] && TTALANG=en-us || TTALANG=$tmpTTALANG	
  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() { 
    if [ -n "$ASK_HTTPPORT" ]; then
        case `$TTA_TMPDIR/ttahostprobe localhost:$a_httpport` in
           "n" ) prompt_httpport=${i18n_p_httpport} ;;
            * ) s_inuse=`printf "${i18n_pf1_port}" "${a_httpport}"`
                prompt_httpport="${i18n_p_httpport}${s_inuse}" ;;
        esac
echo; echo
echo $_ss_headlines
echo "$i18n_q_httpport"
echo $_ss_headlines

echo "$prompt_httpport"
echo # blank line between prompt and question
_valid=false
while [ $_valid = false ]
do
  echo $N "$i18n_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=`printf "${i18n_pf1_port}" "${a_httpport}"`
[ "$httpprompt" != "NOPROMPT" ] && echo "$httpprompt"
echo # blank line between prompt and question
_valid=false
while [ $_valid = false ]
do
  echo $N "$i18n_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
    }

    get_httpsport() { 
    if [ -n "$ASK_HTTPPORT" ]; then
        case `$TTA_TMPDIR/ttahostprobe localhost:$a_httpsport` in
           "n" ) prompt_httpsport=${i18n_p_httpsport} ;;
            * ) s_inuse=`printf "${i18n_pf1_port}" "${a_httpsport}"`
                prompt_httpsport="${i18n_p_httpsport}${s_inuse}" ;;
        esac
echo; echo
echo $_ss_headlines
echo "$i18n_q_httpport_https"
echo $_ss_headlines

echo "$prompt_httpsport"
echo # blank line between prompt and question
_valid=false
while [ $_valid = false ]
do
  echo $N "$i18n_q_httpport_https [$a_httpsport] $C"
  read _answer
  if [ -z "$_answer" ]
  then
    _answer="$a_httpsport"   # 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_httpsport="$_answer"

        while [ "`$TTA_TMPDIR/ttahostprobe localhost:$a_httpsport`" = "y" ]; do
            httpprompt=`printf "${i18n_pf1_port}" "${a_httpsport}"`
[ "$httpprompt" != "NOPROMPT" ] && echo "$httpprompt"
echo # blank line between prompt and question
_valid=false
while [ $_valid = false ]
do
  echo $N "$i18n_q_httpport_https [$a_httpsport] $C"
  read _answer
  if [ -z "$_answer" ]
  then
    _answer="$a_httpsport"   # 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_httpsport="$_answer"

        done
    fi
    }

    a_InstSecure=$i18n_s_yes a_InstSecureCert='*' a_InstSecureKey=$i18n_s_no a_InstSecureRoot=$i18n_s_no
    a_InstSecureAlready=''
    a_Archive=$i18n_s_yes a_cron="" a_CronDay=0 a_CronTime=03
    a_CronTimeOrig=$a_CronTime
    a_CronDayOrig=$a_CronDay

    if [ -n "${INSTALLED_IN}" ]; then
	a_InstDir=${INSTALLED_IN}
    else
	a_InstDir=$a_definstdir2
	# try to find sensible default directory
	if [ -d "$a_definstdir" ]; then
	    a_InstDir=$a_definstdir
	elif [ -d "$a_base_definstdir" ]; then
	    a_InstDir=$a_definstdir
    fi
    fi

    a_Restart=$i18n_s_yes

    a_AsadPort=3144

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

    a_httpport=${apachePort:-80}
    a_httpsport=${apacheSPort:-443}

    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
	pkginst="tta"
	jive_PkgInst="tta"
	jive_InstDir="$a_InstDir"
	jive_DataDir="$a_InstDir/var"
	jive_Build=`cat $a_InstDir/etc/pkg/rpm_tta_upgradefrom`
    elif [ -n "${TTA_RPM}" ]; then
	# PKG -> RPM upgrade case
# 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
	    [ "$thisinst" -ge 999999 ] && thisinst=1
	    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 VERSION 2>/dev/null`
		jive_PkgInst=$pkginst
	    fi
	fi
    else
	# PKG -> PKG upgrade case
	allpkginst=""
# get the package name
shortpkgname=`echo tta | 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
    allpkginst="$pkginfo"
else
    allpkginst=""
fi

	ninstances=`echo "${allpkginst}" | wc -w`
	if [ "${CALLER}" = "request"     -a ${ninstances} -ge 1 -o \
	     "${CALLER}" = "postinstall" -a ${ninstances} -gt 1 ]; then
# find the upgraded instance of the package
instver=999999
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
	    [ "$thisinst" -ge 999999 ] && thisinst=1
	    if [ "$thisinst" -lt "$instver" ]; then
		instver=$thisinst
		pkginst=$inst
	    fi
	fi
    done
fi
[ "$instver" -eq "999999" ] && instver=0

	    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 VERSION 2>/dev/null`
		    jive_PkgInst=$pkginst
		fi
	    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;VERSION=\(.*\);\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
[ -z "${i18n_upgrade}" ] && i18n_upgrade=${a_upgrade}
[ -z "${i18n_install}" ] && i18n_reinstall=${a_install}
[ -z "${i18n_reinstall}" ] && i18n_reinstall=${a_reinstall}
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=$i18n_reinstall
elif [ $_omajor -lt $_nmajor ]; then
	INSTTYPE=$i18n_upgrade
elif [ $_omajor = $_nmajor -a $_ofeature -lt $_nfeature ]; then
	INSTTYPE=$i18n_upgrade
elif [ $_omajor = $_nmajor -a $_ofeature = $_nfeature -a $_obug -lt $_nbug ]; then
	INSTTYPE=$i18n_upgrade
elif [ $_omajor = $_nmajor -a $_ofeature = $_nfeature -a $_obug = $_nbug -a $_obuild -lt $_nbuild ]; then
	INSTTYPE=$i18n_upgrade
else
	INSTTYPE=downgrade
fi


  # We don't allow downgrades
  [ "$INSTTYPE" = "downgrade" ] && {
    echo "a_installtype='$INSTTYPE'; export a_installtype; 
    oldver='$jive_Build'; export oldver;" >$RESPONSE
    return $CANT_DOWNGRADE
  }
  # Check it's a supported upgrade
  _currpatt="`expr \"${PRODUCT_VERSION_FULL}\" : '\(.....\).*' | sed 's/\./,./g;s/$/.*/' | tr ',' '\134'`"
  _patt="^(`echo \"${POSSIBLE_UPGRADES}|${_currpatt}\" | tr -d ' '`)\$"
  suppupgrade="f"
  [ -n "`echo \"${jive_Build}\" | egrep \"${_patt}\"`" ] && suppupgrade="t"

  [ "$suppupgrade" = "f" ] && {
    if [ -f "${jive_InstDir}/var/UPGRADE" ]; then
      suppupgrade="ff"
    else
      echo "a_installtype='$INSTTYPE'; export a_installtype; 
      oldver='$jive_Build'; export oldver;" >$RESPONSE
      return $CANT_UPGRADE
    fi
  }
else
  INSTTYPE="$i18n_install"
  suppupgrade=f
fi

    if [ "${suppupgrade}" = "ff" ]; then
	qURetVal=${FORCE_UPGRADE}
    else
	qURetVal=${OK}
    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
	    [ "$thisinst" -ge 999999 ] && thisinst=1
	    if [ "$thisinst" -gt "$theinstver" ]; then
		theinstver=$thisinst
		c_target=$inst
	    fi
	fi
    done
fi

      fi
      [ ! -z \"$c_target\" ] && c_instver=\`pkgparam $c_target VERSION 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

    # On Solaris we probably don't have permission to find out whether there is
    # an existing crontab entry, so set the "clean install" default if we are unable
    # to find the crontab entry.
    if [ "$INSTTYPE" = "$i18n_reinstall" -o "$INSTTYPE" = "$i18n_upgrade" ]; then
	[ -z "$a_cron" ] && a_Archive=$i18n_s_yes
    fi

    a_InstSecureAlready=''
    if [ "$INSTTYPE" = "$i18n_reinstall" -o "$suppupgrade" = "f" ]; then
	# clean install
	INSTMSG="$INSTTYPE $PRODUCT_VERSION_FULL"
    elif [ "${CALLER}" = "request" ]; then
	# upgrade
	INSTMSG="$INSTTYPE $jive_Build -> $PRODUCT_VERSION_FULL"
    else
	# upgrade
	INSTMSG="$INSTTYPE $jive_Build (${i18n_modestd}) -> $PRODUCT_VERSION_FULL"
	# are we in secure mode?
	if [ -n "`grep '^tarantella\.config\.server\.security\.mechanism=.*ssl' ${INSTDIR}/var/serverconfig/local/server.properties`" ]; then
	    a_InstSecureAlready=t
	elif [ -f "${INSTDIR}/webserver/.TWS_secure" ]; then
	    a_InstSecureAlready=t
	fi
	[ -n "${a_InstSecureAlready}" ] && {
	    a_InstSecure=${i18n_s_no}
	    INSTMSG="$INSTTYPE $jive_Build (${i18n_modessl}) -> $PRODUCT_VERSION_FULL (${i18n_modessl})"
	}
    fi

    qURetVal=$OK

    a_Webtop=$i18n_s_no
    a_PrtSetup=$i18n_s_no

    SettingsOK="${i18n_no}"
    firsthdr=0
    insist="" insistdns="" show_insist_prompt="" show_insistdns_prompt=""
    while [ "$SettingsOK" = "${i18n_no}" ]; do

	echo " "; echo " "
	summarystr="$i18n_summary"
echo $_ss_headlines
echo "$summarystr"
echo $_ss_headlines

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

	##################################################################
	# Display current settings
	#
	[ -n "$INSTTYPE" ] && printf "$i18n_pf1_installtype" "$INSTMSG"
	[ -n "$ASK_INSTSECURE" -a -z "${a_InstSecureAlready}" ] && {
	    echo "$i18n_q_instsecure = $a_InstSecure"
	    [ "$a_InstSecure" = "${i18n_s_yes}" ] && {
		echo "$i18n_q_instsecurecert = $a_InstSecureCert"
		[ "$a_InstSecureKey" != "${i18n_s_no}" ] && echo "$i18n_q_instsecurekey = $a_InstSecureKey"
		[ "$a_InstSecureRoot" != "${i18n_s_no}" ] && echo "$i18n_q_instsecureroot = $a_InstSecureRoot"
	    }
	}
	[ -n "$ASK_INSTDIR" ] && echo "$i18n_instdir = $a_InstDir"
	[ -n "$ASK_PEERDNS" ] && echo "$i18n_q_peerdns = $a_PeerDNS"
        if [ -n "$ASK_HTTPPORT" -a "$INSTTYPE" != "$i18n_upgrade" ]; then
	    httpinuse=`$TTA_TMPDIR/ttahostprobe localhost:$a_httpport`
	    httpsinuse=`$TTA_TMPDIR/ttahostprobe localhost:$a_httpsport`
	    if [ "$httpinuse" = "y" ]; then
		if [ "$a_InstSecure" != "${i18n_s_yes}" ]; then
		    printf "$i18n_pf1_httpportinuse" "$a_httpport"
		else
		    # We are installing in secure mode, so we can choose our own replacement
		    # for HTTP port 80 (since it's used only during installation).
		    while [ "$httpinuse" = "y" -a "$a_httpport" -lt 99 ]; do
			a_httpport=`expr "$a_httpport" + 1`
			httpinuse=`$TTA_TMPDIR/ttahostprobe localhost:$a_httpport`
		    done
		    if [ "$httpinuse" = "y" ]; then
			printf "$i18n_pf1_httpportinuse" "$a_httpport"
		    else
			printf "$i18n_pf1_httpportfree" "$a_httpport"
		    fi
		fi
	    else
		printf "$i18n_pf1_httpportfree" "$a_httpport"
	    fi
	    if [ "$a_InstSecure" = "${i18n_s_yes}" ]; then
		if [ "$httpsinuse" = "y" ]; then
		    printf "$i18n_pf1_httpportinuse_https" "$a_httpsport"
		else
		    printf "$i18n_pf1_httpportfree_https" "$a_httpsport"
		fi
	    fi
        fi
	if [ -n "$ASK_CRONTAB" ]; then
	    echo $N "$i18n_q_checkpoint = $a_Archive$C"
	    if [ "$a_Archive" = "$i18n_s_yes" ]; then
[ -z "${i18n_sun}" ] && i18n_sun="${l_sun}"
[ -z "${i18n_mon}" ] && i18n_mon="${l_mon}"
[ -z "${i18n_tue}" ] && i18n_tue="${l_tue}"
[ -z "${i18n_wed}" ] && i18n_wed="${l_wed}"
[ -z "${i18n_thu}" ] && i18n_thu="${l_thu}"
[ -z "${i18n_fri}" ] && i18n_fri="${l_fri}"
[ -z "${i18n_sat}" ] && i18n_sat="${l_sat}"
  case $a_CronDay in
    0 ) a_daystr="$i18n_sun";;
    1 ) a_daystr="$i18n_mon";;
    2 ) a_daystr="$i18n_tue";;
    3 ) a_daystr="$i18n_wed";;
    4 ) a_daystr="$i18n_thu";;
    5 ) a_daystr="$i18n_fri";;
    6 ) a_daystr="$i18n_sat";;
  esac

		printf "${i18n_pf2_hours}" "$a_daystr" "$a_CronTime"
	    fi
	    echo
	fi
	[ -n "$ASK_WEBTOP" ] && echo "$q_webtop = $a_Webtop"
	[ -n "$ASK_PRINTER" ] && echo "$q_prtsetup = $a_PrtSetup"
	if [ ! -z "$p_oldpkg" ]; then
	    echo "$i18n_pkguninst"
	    for uninst in $p_oldpkg; do
		[ ! -z "$uninst" ] && echo " - `pkgparam $uninst NAME`"
	    done
	fi

	[ "$dupgrade" != "false" -a -n "${jive_Build}" ] && printf "${i18n_pf1_dupgrade}" "${jive_Build}"

	# Warn about unsupported upgrades from pre-release builds of same version,
	# or other unsupported upgrade paths.  For 4.3, we are supporting upgrades
	# only from 3.42 or 4.2.
	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
  _currpatt="`expr \"${PRODUCT_VERSION_FULL}\" : '\(.....\).*' | sed 's/\./,./g;s/$/.*/' | tr ',' '\134'`"
  _patt="^(`echo \"${SUPPORTED_UPGRADES}|${_currpatt}\" | tr -d ' '`)\$"
  supported_upgrade="f"
  [ -n "`echo \"${jive_Build}\" | egrep \"${_patt}\"`" ] && supported_upgrade="t"

		[ "${supported_upgrade}" = "f" ] && echo "$i18n_unsupported_upgrade"
	    fi
	fi

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

	[ "${SettingsOK}" != "${i18n_N}" ] && SettingsOK="${i18n_Y}"

        # Are they trying to install in a sensible place?
	# (Can't do this check for RPM installs because we have already installed
	# before we get here in the RPM case.)
	instdircontents=""
	[ -n "${ASK_INSTDIR}" -a -d "${a_InstDir}" ] && instdircontents=`ls "${a_InstDir}" 2>/dev/null | egrep -v '^(tmp.*|temp.*|tta.*|bin|etc|lib|var|webserver)$'`
	if [ -n "${instdircontents}" ]; then
	    show_insist_prompt=t
	    SettingsOK="${i18n_N}"
	    # tell the user the prospective instdir is not empty
	    printf "${i18n_pf1_instdircontents}" "${a_InstDir}"
	    (cd ${a_InstDir};ls -ld ${instdircontents})
	    # but if they insist, let them ...
	    if [ -n "$insist" ]; then
		echo "
$i18n_carryonregardless"
		SettingsOK="${i18n_Y}"
	    fi
        else
            ## check if ok
            [ "${SettingsOK}" != "${i18n_N}" ] && SettingsOK="${i18n_Y}"
	fi

	# check that the peer DNS name looks like an FQDN
	if [ -n "$ASK_PEERDNS" ]; then
	    case "${a_PeerDNS}" in
	    *.*) # looks OK - got at least one dot anyway
		[ "${SettingsOK}" != "${i18n_N}" ] && SettingsOK="${i18n_Y}"
		;;
	    *)  show_insistdns_prompt=t
		SettingsOK="${i18n_N}"
		# tell the user it doesn't look like an FQDN
		echo "${i18n_badpeerdns}"
		# but if they insist, let them ...
		if [ -n "$insistdns" ]; then
		    echo "$i18n_carryonregardless"
		    SettingsOK="${i18n_Y}"
		fi
	    esac
	fi

        if [ -n "$ASK_HTTPPORT" -a "$INSTTYPE" != "$i18n_upgrade" ]; then
	    [ "$httpinuse" = "y" ] && {
		# check for HTTP port availability
		echo "$i18n_httpport_inuse"
		get_httpport
		SettingsOK="${i18n_no}"
		continue
	    }
	    if [ "$a_InstSecure" = "${i18n_s_yes}" ]; then
		[ "$httpsinuse" = "y" ] && {
		    # check for HTTPS port availability
		    echo "$i18n_httpport_inuse_https"
		    get_httpsport
		    SettingsOK="${i18n_no}"
		    continue
		}
	    fi
        fi

	instdir_prompt="${i18n_instdir_or_q}"
	case "$SettingsOK" in
	[${i18n_case_yes}]*)
            echo " "
	    instdir_prompt="${i18n_instdir}"
	    awkscript='{v="true"; if (NF!=1 || $1!~/^['${i18n_case_yes}${i18n_case_no}${i18n_case_quit}'].*$/) v="false"; print v}'
[ "$i18n_damage" != "NOPROMPT" ] && echo "$i18n_damage"
echo # blank line between prompt and question
_valid=false
while [ $_valid = false ]
do
  echo $N "$i18n_q_damage [$SettingsOK] $C"
  read _answer
  if [ -z "$_answer" ]
  then
    _answer="$SettingsOK"   # default
  fi
   _valid=`echo "$_answer" | sed 's/[, ][, ]*/ /g' | awk "$awkscript"` 
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
	[${i18n_case_quit}]*)
	    echo " "
echo $_ss_headlines
echo "$i18n_nochange"
echo $_ss_headlines

	    # tell the wrapper script to exit quietly
	    [ -n "${TTA_TMPDIR}" ] && echo "#USERQUIT" >>$TTA_TMPDIR/ttainst.cmds_to_webwrap 2>/dev/null
	    qURetVal=$QUIT
	    return $qURetVal
	    ;;
	[${i18n_case_no}]*)
	    # User wants to change something
	    # Loop again
	    SettingsOK="${i18n_no}"
	    ;;
	[${i18n_case_yes}]*)
	    case "${INSTTYPE}" in
	    ${i18n_upgrade} | ${i18n_reinstall} )
		# They are doing an upgrade or a reinstall.  Try to see if they are running pkgadd
		# with an admin file - if not, create a suitable admin file and give them the option
		# of restarting the install with it.
		[ -z "${TTA_RPM}" -a "${CALLER}" = "request" -a -z "`ps -ef | grep 'pkgadd.* -a' | grep -v grep`" ] && {
		    ADMINBASE="/tmp/pkgadmin"; ADMINFILE="${ADMINBASE}"; ADMINFILE_OK=''; n=0
		    while [ -d "${ADMINFILE}" -o -f "${ADMINFILE}" ]; do
			[ -f "${ADMINFILE}" -a \
			  -n "`grep 'conflict=nocheck' ${ADMINFILE}`" -a \
			  -n "`grep 'instance=unique'  ${ADMINFILE}`" ] && {
			    ADMINFILE_OK='t'; break
			}
			n=`expr $n + 1`
			ADMINFILE="${ADMINBASE}${n}"
		    done
		    [ "$a_InstDir" != "$BASEDIR" ] && {
		        BASEDIR_ADMIN="basedir=${a_InstDir}"
		    }
		    
		    [ -z "${ADMINFILE_OK}" ] && echo "\
conflict=nocheck
instance=unique
$BASEDIR_ADMIN" >${ADMINFILE}
		    chmod ugo+r ${ADMINFILE}
		    printf "${i18n_pf2_adminfile}" "${ADMINFILE}" "${ADMINFILE}"
		    adminfile_reply="${i18n_Y}"
[ -z "${i18n_yes}" ] && i18n_yes="${a_yes}"
[ -z "${i18n_no}" ] && i18n_no="${a_no}"
[ -z "${i18n_case_yes}" ] && i18n_case_yes="${a_case_yes}"
[ -z "${i18n_case_no}" ] && i18n_case_no="${a_case_no}"
[ -z "${i18n_s_yes}" ] && i18n_s_yes="${s_yes}"
[ -z "${i18n_s_no}" ] && i18n_s_no="${s_no}"
[ "" != "NOPROMPT" ] && echo ""
echo # blank line between prompt and question
_valid=false
while [ $_valid = false ]
do
  echo $N "${i18n_pf2_q_adminfile} [$adminfile_reply] $C"
  read _answer
  if [ -z "$_answer" ]
  then
    _answer="$adminfile_reply"   # default
  fi
  case "$_answer" in
    [${i18n_case_yes}]* )
	    _answer=$i18n_s_yes
	    _valid=true
	    ;;
    [${i18n_case_no}]* )
	    _answer=$i18n_s_no
	    _valid=true
	    ;;
  esac
done
adminfile_reply="$_answer"

		    case "${adminfile_reply}" in
		    [${i18n_case_yes}]* ) qURetVal=$QUIT; return $qURetVal
		    esac
		}
	    esac
	    if [ "${dupgrade}" != "false" ]; then
		dupgrade="${jive_Build}"
		[ -z "${dupgrade}" ] && dupgrade="0.00.000"
		jive_InstDir=""
		jive_DataDir=""
		jive_Build=""
		jive_PkgInst=""
		oldpkg=""
	    fi
	    [ "$INSTTYPE" = "${i18n_upgrade}" ] && a_httpport="%%oldhttpport" a_httpsport="%%oldhttpsport"
	    echo \
"a_Archive='$a_Archive' export a_Archive
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_InstSecure='$a_InstSecure' export a_InstSecure
a_InstSecureCert='$a_InstSecureCert' export a_InstSecureCert
a_InstSecureKey='$a_InstSecureKey' export a_InstSecureKey
a_InstSecureRoot='$a_InstSecureRoot' export a_InstSecureRoot
a_InstSecureAlready='$a_InstSecureAlready' export a_InstSecureAlready
a_LicenseKeys='$a_LicenseKeys' export a_LicenseKeys
a_PeerDNS='$a_PeerDNS' export a_PeerDNS
a_PrtSetup='$a_PrtSetup' export a_PrtSetup
a_Restart='$a_Restart' export a_Restart
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
a_httpsport='$a_httpsport' export a_httpsport
dupgrade='$dupgrade' export dupgrade" >$RESPONSE
	    break ;;
	esac

	##################################################################
	# Install in secure mode?
	#
	[ -n "$ASK_INSTSECURE" -a -z "${a_InstSecureAlready}" ] && {
[ -z "${i18n_yes}" ] && i18n_yes="${a_yes}"
[ -z "${i18n_no}" ] && i18n_no="${a_no}"
[ -z "${i18n_case_yes}" ] && i18n_case_yes="${a_case_yes}"
[ -z "${i18n_case_no}" ] && i18n_case_no="${a_case_no}"
[ -z "${i18n_s_yes}" ] && i18n_s_yes="${s_yes}"
[ -z "${i18n_s_no}" ] && i18n_s_no="${s_no}"
echo; echo
echo $_ss_headlines
echo "$i18n_h_instsecure"
echo $_ss_headlines

echo "$i18n_p_instsecure"
echo # blank line between prompt and question
_valid=false
while [ $_valid = false ]
do
  echo $N "$i18n_q_instsecure [$a_InstSecure] $C"
  read _answer
  if [ -z "$_answer" ]
  then
    _answer="$a_InstSecure"   # default
  fi
  case "$_answer" in
    [${i18n_case_yes}]* )
	    _answer=$i18n_s_yes
	    _valid=true
	    ;;
    [${i18n_case_no}]* )
	    _answer=$i18n_s_no
	    _valid=true
	    ;;
  esac
done
a_InstSecure="$_answer"

	    [ "${a_InstSecure}" = "${i18n_s_yes}" ] && {
		CBegin='-----BEGIN .*CERTIFICATE-----'	CEnd='-----END .*CERTIFICATE-----'
		KBegin='-----BEGIN .*KEY-----'		KEnd='-----END .*KEY-----'
		OSSLPROG="openssl"
		OSSLHELP="${INSTDIR}/bin/scripts/openssl_lib.sh"
		CertCheckMsg() {	# error conditions returned by "openssl helper"
		    case "$1" in
		    4)  echo;echo "${i18n_certcheck4}";;
		    7)  echo;echo "${i18n_certcheck7}";;
		    -*) echo;echo "${i18n_certcheckca}";;
		    *)  echo;echo "${i18n_certcheckerr}"
		    esac
		}
		while :; do
		    # ask for a cert file
[ -z "${i18n_yes}" ] && i18n_yes="${a_yes}"; [ -z "${i18n_no}" ] && i18n_no="${a_no}"
[ -z "${i18n_case_yes}" ] && i18n_case_yes="${a_case_yes}"; [ -z "${i18n_case_no}" ] && i18n_case_no="${a_case_no}"
[ -z "${i18n_s_yes}" ] && i18n_s_yes="${s_yes}"; [ -z "${i18n_s_no}" ] && i18n_s_no="${s_no}"
[ -n "$i18n_q_instsecurecert" ] && {
    echo; echo
echo $_ss_headlines
echo "$i18n_q_instsecurecert"
echo $_ss_headlines

}
echo "$i18n_p_instsecurecert"; echo
_ok=''; while [ -z "$_ok" ]; do
  echo $N "$i18n_q_instsecurecert [$a_InstSecureCert] $C"
  read _fnam
  [ -z "${_fnam}" ] && _fnam="$a_InstSecureCert"
  [ -z "${_fnam}" ] && _fnam="*"
  case "${_fnam}" in
  [${i18n_case_no}]*) _fnam="${i18n_s_no}";;
  esac
  [ -n "*" -a "${_fnam}" = "*" ] && break
  case "$_fnam" in
  ${i18n_s_no})
     _ok=t;;
  /*)if [ ! -f "$_fnam" ] || [ -z "`egrep -e \"$CBegin\" $_fnam`" -o -z "`egrep -e \"$CEnd\" $_fnam`" ]; then
       _ok=''; echo "$i18n_badcertfile"
     elif [ "`su $privusr -c \"[ -r $_fnam ] && echo t\"`" != "t" ]; then
       _ok=''; echo "$i18n_badcertfile"
     else
       _ok=t
     fi;;
  *) _ok=''; echo "$i18n_badcertfile"
  esac
done
a_InstSecureCert="$_fnam"

		    case "${a_InstSecureCert}" in
		    /?*) # got a cert file; does it need a key file?
			${OSSLHELP} checkkey --cert=${a_InstSecureCert}
			ret=$?
			[ "${ret}" -eq 6 ] && {
			    # we need a key file
[ -z "${i18n_yes}" ] && i18n_yes="${a_yes}"; [ -z "${i18n_no}" ] && i18n_no="${a_no}"
[ -z "${i18n_case_yes}" ] && i18n_case_yes="${a_case_yes}"; [ -z "${i18n_case_no}" ] && i18n_case_no="${a_case_no}"
[ -z "${i18n_s_yes}" ] && i18n_s_yes="${s_yes}"; [ -z "${i18n_s_no}" ] && i18n_s_no="${s_no}"
[ -n "$i18n_q_instsecurekey" ] && {
    echo; echo
echo $_ss_headlines
echo "$i18n_q_instsecurekey"
echo $_ss_headlines

}
echo "$i18n_p_instsecurekey"; echo
_ok=''; while [ -z "$_ok" ]; do
  echo $N "$i18n_q_instsecurekey [$a_InstSecureKey] $C"
  read _fnam
  [ -z "${_fnam}" ] && _fnam="$a_InstSecureKey"
  [ -z "${_fnam}" ] && _fnam="${i18n_s_no}"
  case "${_fnam}" in
  [${i18n_case_no}]*) _fnam="${i18n_s_no}";;
  esac
  [ -n "${i18n_s_no}" -a "${_fnam}" = "${i18n_s_no}" ] && break
  case "$_fnam" in
  ${i18n_s_no})
     _ok=t;;
  /*)if [ ! -f "$_fnam" ] || [ -z "`egrep -e \"$KBegin\" $_fnam`" -o -z "`egrep -e \"$KEnd\" $_fnam`" ]; then
       _ok=''; echo "$i18n_badkeyfile"
     elif [ "`su $privusr -c \"[ -r $_fnam ] && echo t\"`" != "t" ]; then
       _ok=''; echo "$i18n_badkeyfile"
     else
       _ok=t
     fi;;
  *) _ok=''; echo "$i18n_badkeyfile"
  esac
done
a_InstSecureKey="$_fnam"

			    case "${a_InstSecureKey}" in
			    /?*) ${OSSLHELP} checkkey --cert=${a_InstSecureCert} --key=${a_InstSecureKey} >/dev/null 2>&1; ret=$?;;
			    *)   continue
			    esac
			}
			[ "${ret}" -ne 0 ] && { CertCheckMsg ${ret}; continue; }
			# got a cert file (and a key file if we need it); ask for a root cert file
			errmsg=''
			while :; do
			    prompt="$i18n_p_instsecureroot"; [ -n "$errmsg" ] && prompt="${errmsg}
${prompt}"
[ -z "${i18n_yes}" ] && i18n_yes="${a_yes}"; [ -z "${i18n_no}" ] && i18n_no="${a_no}"
[ -z "${i18n_case_yes}" ] && i18n_case_yes="${a_case_yes}"; [ -z "${i18n_case_no}" ] && i18n_case_no="${a_case_no}"
[ -z "${i18n_s_yes}" ] && i18n_s_yes="${s_yes}"; [ -z "${i18n_s_no}" ] && i18n_s_no="${s_no}"
[ -n "$i18n_q_instsecureroot" ] && {
    echo; echo
echo $_ss_headlines
echo "$i18n_q_instsecureroot"
echo $_ss_headlines

}
echo "$prompt"; echo
_ok=''; while [ -z "$_ok" ]; do
  echo $N "$i18n_q_instsecureroot [$a_InstSecureRoot] $C"
  read _fnam
  [ -z "${_fnam}" ] && _fnam="$a_InstSecureRoot"
  [ -z "${_fnam}" ] && _fnam="${i18n_s_no}"
  case "${_fnam}" in
  [${i18n_case_no}]*) _fnam="${i18n_s_no}";;
  esac
  [ -n "${i18n_s_no}" -a "${_fnam}" = "${i18n_s_no}" ] && break
  case "$_fnam" in
  ${i18n_s_no})
     _ok=t;;
  /*)if [ ! -f "$_fnam" ] || [ -z "`egrep -e \"$CBegin\" $_fnam`" -o -z "`egrep -e \"$CEnd\" $_fnam`" ]; then
       _ok=''; echo "$i18n_badcertfile"
     elif [ "`su $privusr -c \"[ -r $_fnam ] && echo t\"`" != "t" ]; then
       _ok=''; echo "$i18n_badcertfile"
     else
       _ok=t
     fi;;
  *) _ok=''; echo "$i18n_badcertfile"
  esac
done
a_InstSecureRoot="$_fnam"

			    case "${a_InstSecureRoot}" in
			    /?*) ${OSSLHELP} checkca --cacert=${a_InstSecureRoot} --cert=${a_InstSecureCert} >/dev/null 2>&1; ret=$?;;
			    *)   break
			    esac
			    [ "${ret}" -ne 0 ] && { errmsg=`CertCheckMsg -${ret}`; continue; }
			    break
			done
			break
			;;
		    *)  a_InstSecureKey=$i18n_s_no a_InstSecureRoot=$i18n_s_no
			break
		    esac
		done
	    }
	}

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

	    prompt="$i18n_p_instdir"; [ -n "$show_insist_prompt" ] && prompt="${prompt}${i18n_instdir_insist}"
[ -z "${i18n_yes}" ] && i18n_yes="${a_yes}"
[ -z "${i18n_no}" ] && i18n_no="${a_no}"
[ -z "${i18n_case_yes}" ] && i18n_case_yes="${a_case_yes}"
[ -z "${i18n_case_no}" ] && i18n_case_no="${a_case_no}"
[ -z "${i18n_s_yes}" ] && i18n_s_yes="${s_yes}"
[ -z "${i18n_s_no}" ] && i18n_s_no="${s_no}"
echo "$prompt"
echo # blank line between prompt and question
_valid=false
while [ $_valid = false ]
do
  _valid2=false
  _tmp_dirname=""
  echo $N "$instdir_prompt [$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=$i18n_yes
    fi
  else
    _valid=true
    a_makeinstdir=$i18n_yes
  fi
  if [ -f "$_dirname" ]
  then
    echo "$i18n_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
      [${i18n_case_yes}]*)
        a_makeinstdir=$i18n_s_yes
        _valid2=true
        _valid=true
        ;;
      [${i18n_case_no}]*)
        a_makeinstdir=$i18n_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" ;;
	    [${i18n_case_quit}]*) echo " "
echo $_ss_headlines
echo "$i18n_nochange"
echo $_ss_headlines

		# tell the wrapper script to exit quietly
		[ -n "${TTA_TMPDIR}" ] && 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;VERSION=\(.*\);\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    
[ -z "${i18n_upgrade}" ] && i18n_upgrade=${a_upgrade}
[ -z "${i18n_install}" ] && i18n_reinstall=${a_install}
[ -z "${i18n_reinstall}" ] && i18n_reinstall=${a_reinstall}
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=$i18n_reinstall
elif [ $_omajor -lt $_nmajor ]; then
	INSTTYPE=$i18n_upgrade
elif [ $_omajor = $_nmajor -a $_ofeature -lt $_nfeature ]; then
	INSTTYPE=$i18n_upgrade
elif [ $_omajor = $_nmajor -a $_ofeature = $_nfeature -a $_obug -lt $_nbug ]; then
	INSTTYPE=$i18n_upgrade
elif [ $_omajor = $_nmajor -a $_ofeature = $_nfeature -a $_obug = $_nbug -a $_obuild -lt $_nbuild ]; then
	INSTTYPE=$i18n_upgrade
else
	INSTTYPE=downgrade
fi


  # We don't allow downgrades
  [ "$INSTTYPE" = "downgrade" ] && {
    echo "a_installtype='$INSTTYPE'; export a_installtype; 
    oldver='$jive_Build'; export oldver;" >$RESPONSE
    return $CANT_DOWNGRADE
  }
  # Check it's a supported upgrade
  _currpatt="`expr \"${PRODUCT_VERSION_FULL}\" : '\(.....\).*' | sed 's/\./,./g;s/$/.*/' | tr ',' '\134'`"
  _patt="^(`echo \"${POSSIBLE_UPGRADES}|${_currpatt}\" | tr -d ' '`)\$"
  suppupgrade="f"
  [ -n "`echo \"${jive_Build}\" | egrep \"${_patt}\"`" ] && suppupgrade="t"

  [ "$suppupgrade" = "f" ] && {
    if [ -f "${jive_InstDir}/var/UPGRADE" ]; then
      suppupgrade="ff"
    else
      echo "a_installtype='$INSTTYPE'; export a_installtype; 
      oldver='$jive_Build'; export oldver;" >$RESPONSE
      return $CANT_UPGRADE
    fi
  }
else
  INSTTYPE="$i18n_install"
  suppupgrade=f
fi

	    if [ "${suppupgrade}" = "ff" ]; then
		qURetVal=${FORCE_UPGRADE}
	    else
		qURetVal=${OK}
	    fi
	    if [ "$INSTTYPE" = "$i18n_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 "$i18n_h_peerdns"
echo $_ss_headlines

	    while :; do
		prompt="$i18n_p_peerdns"; [ -n "$show_insistdns_prompt" ] && prompt="${prompt}
${i18n_badpeerdns}${i18n_peerdns_insist}"
[ "$prompt" != "NOPROMPT" ] && echo "$prompt"
echo # blank line between prompt and question
_valid=false
while [ $_valid = false ]
do
  echo $N "$i18n_q_peerdns [$a_PeerDNS] $C"
  read _answer
  if [ -z "$_answer" ]
  then
    _answer="$a_PeerDNS"   # default
  fi
  _valid=true
done
a_PeerDNS="$_answer"

		insistdns=""
		case "$a_PeerDNS" in
		*\!) # they insist
		    a_PeerDNS=`expr "$a_PeerDNS" : '\(.*\).$'`; insistdns="t"
		    break
		    ;;
		*.*) # looks OK - got at least one dot anyway
		    break
		    ;;
		[${i18n_case_quit}]*) # they've had enough and they want out
		    echo " "
echo $_ss_headlines
echo "$i18n_nochange"
echo $_ss_headlines

		    # tell the wrapper script to exit quietly
		    [ -n "${TTA_TMPDIR}" ] && echo "#USERQUIT" >>$TTA_TMPDIR/ttainst.cmds_to_webwrap 2>/dev/null
		    qURetVal=$QUIT
		    return $qURetVal
		    ;;
		*)  # tell the user it doesn't look like an FQDN
		    show_insistdns_prompt="t"
		esac
	    done
	fi
	show_insistdns_prompt=""


	##################################################################
	# HTTP/S port
	#
        [ "$INSTTYPE" != "$i18n_upgrade" ] && {
	    get_httpport
	    [ "$a_InstSecure" = "${i18n_s_yes}" ] && get_httpsport
	}

	##################################################################
	# Archive logs weekly?
	#
	if [ -n "$ASK_CRONTAB" ]; then
[ -z "${i18n_yes}" ] && i18n_yes="${a_yes}"
[ -z "${i18n_no}" ] && i18n_no="${a_no}"
[ -z "${i18n_case_yes}" ] && i18n_case_yes="${a_case_yes}"
[ -z "${i18n_case_no}" ] && i18n_case_no="${a_case_no}"
[ -z "${i18n_s_yes}" ] && i18n_s_yes="${s_yes}"
[ -z "${i18n_s_no}" ] && i18n_s_no="${s_no}"
echo; echo
echo $_ss_headlines
echo "$i18n_h_checkpoint"
echo $_ss_headlines

echo "$i18n_p_checkpoint"
echo # blank line between prompt and question
_valid=false
while [ $_valid = false ]
do
  echo $N "$i18n_q_checkpoint [$a_Archive] $C"
  read _answer
  if [ -z "$_answer" ]
  then
    _answer="$a_Archive"   # default
  fi
  case "$_answer" in
    [${i18n_case_yes}]* )
	    _answer=$i18n_s_yes
	    _valid=true
	    ;;
    [${i18n_case_no}]* )
	    _answer=$i18n_s_no
	    _valid=true
	    ;;
  esac
done
a_Archive="$_answer"

     
	    if [ "$a_Archive" = "$i18n_s_yes" ]; then
echo "$i18n_p_checkday"
_valid=false
while [ $_valid = false ]
do
  echo $N "$i18n_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 "$i18n_badday"
    ;;
  esac
done

echo "$i18n_p_checktime"
_valid=false
while [ $_valid = false ]
do
  echo $N "$i18n_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 "$i18n_badnumber"
    fi
    ;;
  *)
    echo "$i18n_badnumber"
    ;;
  esac
done

	    fi
	fi

	##################################################################
	# Create default webtop objects?
	#
	if [ -n "$ASK_WEBTOP" ]; then
[ -z "${i18n_yes}" ] && i18n_yes="${a_yes}"
[ -z "${i18n_no}" ] && i18n_no="${a_no}"
[ -z "${i18n_case_yes}" ] && i18n_case_yes="${a_case_yes}"
[ -z "${i18n_case_no}" ] && i18n_case_no="${a_case_no}"
[ -z "${i18n_s_yes}" ] && i18n_s_yes="${s_yes}"
[ -z "${i18n_s_no}" ] && i18n_s_no="${s_no}"
echo; echo
echo $_ss_headlines
echo "$h_webtop"
echo $_ss_headlines

echo "$i18n_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
    [${i18n_case_yes}]* )
	    _answer=$i18n_s_yes
	    _valid=true
	    ;;
    [${i18n_case_no}]* )
	    _answer=$i18n_s_no
	    _valid=true
	    ;;
  esac
done
a_Webtop="$_answer"

	fi

	##################################################################
	# Create Tarantella printer?
	#
	if [ -n "$ASK_PRINTER" ]; then
[ -z "${i18n_yes}" ] && i18n_yes="${a_yes}"
[ -z "${i18n_no}" ] && i18n_no="${a_no}"
[ -z "${i18n_case_yes}" ] && i18n_case_yes="${a_case_yes}"
[ -z "${i18n_case_no}" ] && i18n_case_no="${a_case_no}"
[ -z "${i18n_s_yes}" ] && i18n_s_yes="${s_yes}"
[ -z "${i18n_s_no}" ] && i18n_s_no="${s_no}"
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
    [${i18n_case_yes}]* )
	    _answer=$i18n_s_yes
	    _valid=true
	    ;;
    [${i18n_case_no}]* )
	    _answer=$i18n_s_no
	    _valid=true
	    ;;
  esac
done
a_PrtSetup="$_answer"

	fi
    done

    return $qURetVal
}

getLicenseUpgradeInfo()
{
    # get configuration info for an existing installed tta package
    jive_PkgInst="" jive_InstDir="" jive_DataDir="" jive_Build="" OldVersionAsNumber=0
# find the upgraded instance of the package
instver=999999
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
	    [ "$thisinst" -ge 999999 ] && thisinst=1
	    if [ "$thisinst" -lt "$instver" ]; then
		instver=$thisinst
		pkginst=$inst
	    fi
	fi
    done
fi
[ "$instver" -eq "999999" ] && instver=0

    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 VERSION 2>/dev/null`
            OldVersionAsNumber=`echo "${jive_Build}" | tr -d .`
	    case "${OldVersionAsNumber}" in
	    [0-9][0-9][0-9][0-9][0-9][0-9]) ;;
	    *) OldVersionAsNumber=0
	    esac
            jive_PkgInst=$pkginst
        fi
    fi
    [ -z "${jive_InstDir}" ] && return 0

    # check license status
    DATADIR="${jive_DataDir}"
    LICTMPDIR="${TTA_TMPDIR}"
    rm -f ${LICTMPDIR}/licdata* 2>/dev/null
    for licinfo in /var/sadm/pkg/tta*/install/licinfo; do
	cp ${licinfo} ${LICTMPDIR} 2>/dev/null
	chmod +x ${LICTMPDIR}/licinfo 2>/dev/null
	break
    done
    lickeys=`awk '$1=="License-Key:"{print $2}' "${DATADIR}/info/lickeys.msg" 2>/dev/null`
    [ -n "${lickeys}" -a -x ${LICTMPDIR}/licinfo ] && {	# failsafe: need license key(s) and licinfo program
	echo 0 >${LICTMPDIR}/licdata.maint
	echo 0 >${LICTMPDIR}/licdata.users
	echo "${lickeys}" | tee ${LICTMPDIR}/licdata.keys | while read lickey; do
	    ${LICTMPDIR}/licinfo ${lickey} >${LICTMPDIR}/licdata 2>/dev/null
	    [ $? -ne 0 ] && continue				# failsafe: ignore keys that make licinfo fail
	    [ -n "`grep '^TTALIC_COMPONENTS=.*38' ${LICTMPDIR}/licdata`" ] && {
		# right-to-upgrade trumps all maintenance keys
		echo "+999999999" >>${LICTMPDIR}/licdata.maint
		continue
	    }
	    users=`sed '/^TTALIC_USERS=/!d;s/.*=//' ${LICTMPDIR}/licdata`
	    case "${users}" in
	    [0-9]*)
		if [ -n "`grep '^TTALIC_COMPONENTS=.*37' ${LICTMPDIR}/licdata`" ]; then
		    echo "+${users}" >>${LICTMPDIR}/licdata.maint
		elif [ -n "`grep '^TTALIC_COMPONENTS=.0' ${LICTMPDIR}/licdata`" ]; then
		    echo "+${users}" >>${LICTMPDIR}/licdata.users
		fi
	    esac
	done
	maint_total=`(tr -d '\012' <${LICTMPDIR}/licdata.maint;echo)|bc`
	users_total=`(tr -d '\012' <${LICTMPDIR}/licdata.users;echo)|bc`
	[ "${OldVersionAsNumber}" -lt 420000 -a ${maint_total} -lt ${users_total} ] && {
	    echo " "
	    echo "$i18n_cantupgrade"
	    return 1
	}
    }
    return 0
}

getLicenseUpgradeInfo
rVal=$?
[ $rVal -ne $OK ] && cleanandexit $rVal

setup_dialog --caller=request --gotstrings --licinfo $LICINFO --response $SAVE_FILE --needkb $kb_needed --ask_instdir
rVal=$?
# Can't downgrade from any version, and can't upgrade *directly* from versions older than 3.30
if [ "$rVal" -eq "$CANT_DOWNGRADE" -o "$rVal" -eq "$CANT_UPGRADE" ]; then
    . $SAVE_FILE
    if [ "$a_installtype" = "downgrade" ]; then
	echo
	printf "${i18n_pf1_cantdowngrade}" "$oldver" | tee -a $LOGFILE
	echo
    else
	oldinstdir=/tmp
# find the upgraded instance of the package
oldinstver=999999
oldpkginst=''
# 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)
    oldpkginst=`echo $pkginfo | awk '{print $1}'`
    for inst in $pkginfo
    do
	thisinst=`pkgparam $inst INSTVER 2>/dev/null`
	if [ -n "$thisinst" ]; then
	    [ "$thisinst" -ge 999999 ] && thisinst=1
	    if [ "$thisinst" -lt "$oldinstver" ]; then
		oldinstver=$thisinst
		oldpkginst=$inst
	    fi
	fi
    done
fi
[ "$oldinstver" -eq "999999" ] && oldinstver=0

	[ "${res}0" -eq 0 ] && oldinstdir=`pkgparam $oldpkginst INSTDIR 2>/dev/null`
	echo
	printf "${i18n_pf1_cantupgrade}" "${oldver}" "${oldinstdir}/var/UPGRADE" | tee -a $LOGFILE
	echo
    fi
    echo "<--- $who_i_am" >>$LOGFILE
    rm -f "$LICINFO" "$TTAHOSTPROBE" "$TTAHOSTNAME" $TTA_TMPDIR/LICENSE.tta* $TTAREGISTERINFO >/dev/null 2>&1
    [ -n "${TTA_TMPDIR}" -a "${TTA_TMPDIR}" != "/" -a -f "${TTA_TMPDIR}/locale.tar" ] && rm -rf $TTA_TMPDIR/locale $TTA_TMPDIR/locale.tar 2>/dev/null
    exit 1
elif [ "$rVal" -eq "$FORCE_UPGRADE" ]; then
    echo
    echo "${i18n_forceupgrade}" | tee -a $LOGFILE
    echo
    rVal=${OK}
fi
[ $rVal -ne $OK ] && cleanandexit $rVal

NEWKEYS=""
for i in `cat $TTA_TMPDIR/LICENSE.tta 2>/dev/null` ; do
    NEWKEYS="$NEWKEYS $i"
done
OLDKEYS=""
for i in `cat $TTA_TMPDIR/LICENSE.tta.old 2>/dev/null` ;do
    OLDKEYS="$OLDKEYS $i"
done

echo "NEWKEYS='$NEWKEYS'
OLDKEYS='$OLDKEYS'" >>$SAVE_FILE

echo " "
echo "$i18n_recordingsettings"

#instver holds the "installation number" -increment it
if [ -z "$instver" ]; then
    instver=0
elif [ "$instver" -ge 999999 ]; then
    instver=1
fi
instver=`expr $instver + 1`


cat >$1 << EOF
BASEDIR="$a_InstDir"
INSTDIR="$a_InstDir"
DATADIR="${a_InstDir}/var"
INSTVER="$instver"
UPGRADE="$upgrade"
LKEYS="$a_LicenseKeys"
TTA_TMPDIR="$TTA_TMPDIR"
EOF

if [ -f $TTA_TMPDIR/UPGRADE.tta ]; then
  # if we are being run from an shx script
  # spin the spinner
  (spin)&
fi

rm -f "$LICINFO" "$TTAHOSTPROBE" "$TTAHOSTNAME" $TTA_TMPDIR/LICENSE.tta* $TTAREGISTERINFO >/dev/null 2>&1
echo "<--- $who_i_am" >>$LOGFILE
exit $OK


