#!/bin/sh
#
# Copyright (c) 1996-2004, Adobe Systems Incorporated
# All Rights Reserved
#
# This is an example script to show you how to launch Netscape (TM) with
# Acrobat 5.0.9 integration.  If the script is run unmodified, it will
# query the user for: 1). the installation directory for Acrobat 5.0.9 and
# 2). the installation directory for Netscape.  You may modify the
# script where indicated to identify the proper directories.
#

#
# Initialization
#
osname=`uname -s`
osrelease=`uname -r`
args="$@"

echoawk ()
{
  echo $* | awk '{ printf "%s", $0 }'
}

echon ()
{
  echo -n "$*"
}

echoc ()
{
  echo "${*}\c"
}

if [ `echo "x\c"` = "x" ] ; then
  echonl=echoc
else
  echonl=echon
fi

ndefault="/usr/local/Netscape"
adefault="/usr/local/Acrobat5"
case "$osname" in
  SunOS)
    case "$osrelease" in
      4.1.[34]*)
        adefault="/usr/Acrobat5"
        ;;
      5.*)
        adefault="/opt/Acrobat5"
        ;;
    esac
    ;;
  HP-UX)
    case "$osrelease" in
      *.09.*)
        adefault="/usr/local/Acrobat5"
        ;;
      *.10.*)
        adefault="/opt/Acrobat5"
        ;;
      esac
    ;;
  Linux)
    adefault="/usr/local/Acrobat5"
    ;;
esac

#
# The Shell variable "adir" identifies the Acrobat 5.0.9 installation
# directory.  If the value of "$adir" is zero length, the user will
# be prompted to enter the installation directory for Acrobat 5.0.9
# The correct directory for Acrobat may be added after the equals
# sign on the line below.
#
adir=

#
# The Shell variable "ndir" identifies the Netscape installation
# directory.  If the value of "$ndir" is zero length, the user will
# be prompted to enter the installation directory for Netscape.
# The correct directory for Netscape may be added after the equals
# sign on the line below.
# NOTE: If the "netscape" executable is in the $ndir path, this
# script will succeed also. (e.g. /usr/bin/netscape).
#
ndir=

#
# The following lines are fairly generic and should not require
# any modification. They just test to see if the Acrobat installation
# directory is somewhat valid.
#
while [ -z "$adir" ] ; do
  $echonl "Enter the Acrobat 5.0.9 install directory [$adefault] "
  read answer
  if [ -z "$answer" ] ; then
    adir="$adefault"
  else
    adir="$answer"
  fi
done
if [ ! -d "$adir" ] || [ ! -d "$adir"/Browsers ] ; then
  echo " "
  echo "The installation directory:"
  echo " "
  echo "$adir"
  echo " "
  echo "is not a valid Acrobat 5.0.9 installation.  You will not"
  echo "be able to view embedded PDF's and view PDF's in Netscape."
  echo "Please consult a system administrator at your site to get the"
  echo "pathname to the Acrobat 5.0.9 installation."
  echo " "
fi

while [ -z "$ndir" ] ; do
  $echonl "Enter the directory containing Netscape [$ndefault] "
  read answer
  if [ -z "$answer" ] ; then
    ndir="$ndefault"
  else
    ndir="$answer"
  fi
done

case "$osname" in
  SunOS)
    osplatform=`uname -p`
    case "$osplatform" in
	sparc)
            case "$osrelease" in
              4.1.[34]*)
                 pconfig=sparcsun
                 XNLSPATH="$ndir"/nls
                 export XNLSPATH
	         ;;
              5.3*) pconfig=sparcsolaris 
		;;
              5.[4567]*) pconfig=sparcsolaris 
		;;
             esac
             ;;
   esac 
   ;;
  HP-UX) pconfig=hppahpux 
    ;;
  Linux) pconfig=intellinux
    ;;
  AIX) pconfig=rs6000aix
    ;;
esac


#
# Point Netscape to its Keysym Database.  This is recommended practice.
# but can cause very bad results if pointed at the wrong directory.
# XKEYSYMDB="$ndir"/XKeysymDB
# export XKEYSYMDB
#echo "XKEYSYMDB is $XKEYSYMDB"

#
# This points Netscape to the Acrobat viewer plug-in so that PDF's
# may be viewed inside of the Netscape window.
#
NPX_PLUGIN_PATH="$adir"/Browsers/$pconfig
export NPX_PLUGIN_PATH
#echo "NPX_PLUGIN_PATH is $NPX_PLUGIN_PATH"

#
# We must make sure that the Acrobat Reader and/or Exchange are on
# the execution search path.  The Acrobat plug-in for Netscape tries
# to execute the correct version of Acrobat.
#
PATH="$adir"/bin:$PATH
export PATH

#
# Netscape needs to have its current resources so let's set them here.
#
XENVIRONMENT="$ndir"/Netscape.ad
export XENVIRONMENT

#
# Now to launch Netscape.  We take a look to see if the directory exists
# and if the file called "netscape" inside of the directory is executable.
# If neither condition is true, then we blurt out a short error message.
#

if [ -d "$ndir" ] ; then
  if [ -x "$ndir"/netscape ] ; then
    exec "$ndir"/netscape ${netscape_args} $args
  else
    if [ -x "$ndir"/netscape-communicator ] ; then
      exec "$ndir"/netscape-communicator ${netscape_args} $args
    else
      echo " "
      echo "$ndir/netscape or netscape-communicator either does not exist"
      echo "or is not executable."
      echo "Please consult a system administrator for the correct path"
      echo "to the Netscape browser installation directory."
      echo " "
    fi
  fi
else
  echo " "
  echo "$ndir either does not exist, or is not a directory."
  echo "Please consult a system administrator for the corret path"
  echo "to the Netscape browser installation directory."
  echo " "
fi

exit 1

