#!/bin/sh
#  Copyright (C) 1996-2005 Tarantella, Inc. 
#  All Rights Reserved.
#  $Id: restart.sh,v 1.13 2005/06/20 19:15:58 peterc Exp $
#
#  Author: Bill Weir
#  Restarts the product

# This is a generic product script used to establish an environment
# before starting/stopping a product or component.
# This script was built from shell library
#   $Id: startup.shlib,v 10.165.6.1 2006/04/03 09:51:35 billwe Exp $
# This script has to run on every platform we support.  Any suggestions
# for improvement are welcome (but must be portable!)

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

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

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

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

ARCHIVE_SUFFIX="F"

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

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

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

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

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

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

# Client versions of server strings; same format, name prefixed by CLIENT
# Asad between a webtop client and server:
CLIENTCAPABILITIES_ASAD_WEBTOPCLIENT_REQUIRED="(1.1 || 1.2)"
CLIENTCAPABILITIES_ASAD_WEBTOPCLIENT_PROVIDED="1.1 1.2"


# 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

u="`LANG=C LC_ALL=C id | sed 's/.*uid=\([0-9][0-9]*\).*/\1/'`"
if [ "$u" = "0" ]
then
  : # all is okay
else
  echo "You must be root to run this program"
  exit 15
fi

if [ -f $TTAMSG/common -a -f $TTAMSG/tta_restart ]; then
  . $TTAMSG/common
  . $TTAMSG/tta_restart
else
  echo "Unable to open message file: $TTAMSG/tta_restart"
  exit 1
fi

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


case "$trace" in
x) set -x
esac

c_killarg=''
c_quietarg=''

while [ ! -z "$1" ] ; do 
    case "$1" in 
	--help ) 
	    echo "$lf_usage" 1>&2
	    exit 0
	    ;;
	--kill | --force )
	    c_killarg=$1
       break
	    ;;
	--quiet )
            c_quietarg=$1
            break
            ;;
	--warm )
	    ${TTADIR}/bin/tarantella stop --restart --quiet
	    if [ $? -eq 0 ] ; then 
		echo "$restarted_warm_req"
		exit 0
	    fi
	    pid=0
	    for p in `cat ${TTADATADIR}/info/auxserver.pid 2>/dev/null`; do
		kill -USR1 $p 2>/dev/null && pid=$p
	    done
	    if [ $pid -ne 0 ]; then
		echo "$restarted_warm_force"
		exit 0
	    fi
	    # Couldn't find a process to signal. 
	    # Fall through to a normal restart.
	    # Note that this allows combinations with other options.
       break
	    ;;
	* ) 
       echo "${l_invalid_arg1}$1${l_invalid_arg2}" 1>&2
	    echo "${sf_usage}" 1>&2       
	    exit 1
	    ;;
    esac
    shift
done

${TTADIR}/bin/tarantella stop $c_killarg $c_quietarg
[ $? -eq 0 ] && exec ${TTADIR}/bin/tarantella start
