#!/bin/sh
#
# Copyright (c) 1996, Adobe Systems Incorporated
# All Rights Reserved
#
# This is an example script to show you how to launch Netscape (TM) with
# Acrobat 4.0 integration.  If the script is run unmodified, it will
# query the user for: 1). the installation directory for Acrobat 4.0 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/Acrobat4"
case "$osname" in
  SunOS)
    case "$osrelease" in
      4.1.[34]*)
        adefault="/usr/Acrobat4"
        ;;
      5.*)
        adefault="/opt/Acrobat4"
        ;;
    esac
    ;;
  IRIX)
    adefault="/opt/Acrobat4"
    ;;
  HP-UX)
    case "$osrelease" in
      *.09.*)
        adefault="/usr/local/Acrobat4"
        ;;
      *.10.*)
        adefault="/opt/Acrobat4"
        ;;
      esac
    ;;
  Linux)
    adefault="/usr/local/Acrobat4"
    ;;
esac

#
# The Shell variable "adir" identifies the Acrobat 4.0 installation
# directory.  If the value of "$adir" is zero length, the user will
# be prompted to enter the installation directory for Acrobat 4.0
# 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.
#
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 directory containing Acrobat 4.0 [$adefault] "
  read answer
  if [ -z "$answer" ] ; then
    adir="$adefault"
  else
    adir="$answer"
  fi
done
if [ ! -d "$adir" ] ; then
  echo " "
  echo "The installation directory:"
  echo " "
  echo "$adir"
  echo " "
  echo "is not a valid Acrobat 4.0 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 4.0 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
	i386)
            pconfig=intelsolaris ;;
	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 
    ;;
  IRIX) pconfig=mipsirix
    ;;
  Linux) pconfig=intellinux
    ;;
  OSF1) pconfig=alphaosf 
    ;;
  AIX) pconfig=rs6000aix
    ;;
esac


#
# Point Netscape to its Keysym Database.  This is recommended practice.
#
XKEYSYMDB="$ndir"/XKeysymDB
export 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
    echo " "
    echo "$ndir/netscape either does not exist or is not executable."
    echo "Please consult a system administrator for the correct path"
    echo "to the Netscape browser installation."
    echo " "
  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."
  echo " "
fi

exit 1

