#!/bin/sh
#


setLangENU()
{
ST_LANG="ENU"
ST_LANG_SMALL="enu"
ST_READER_RPM_NAME="AdobeReader_enu"
ST_EXCHANGE_RPM_NAME="AdobeAcrobat_enu"
ST_COMMENT_WORD="Comment"
ST_DESCRIPTION_WORD="Description"
ST_COMMENT_RPM="Launch Adobe Reader 7.0"
ST_DES_RPM="Adobe Reader for Linux. An application that can view, navigate and print PDF documents."
ST_DES_TAG01="Adobe Reader can read documents in PDF format."
ST_DES_TAG02="Adobe Reader also allows you to search within PDF files,"
ST_DES_TAG03="search for PDF files on the internet and participate in collaborative document reviews."
ST_DES_TAG04="For details, please check www.adobe.com."
ST_THE_FILE="The file"
ST_FOR="for"
ST_YES="yes"
ST_NO="no"
ST_OR="or"
ST_SMALL_Y="y"
ST_SMALL_N="n"
ST_CAPS_Y="Y"
ST_CAPS_N="N"
ST_ACCEPT_CAPS="ACCEPT"
ST_DECLINE_CAPS="DECLINE"
ST_ACCEPT="accept"
ST_DECLINE="decline"
ST_VERSION="version"
ST_STATEMENT_ACCEPT_DECLINE="Please type \\\"accept\\\" to accept the terms and conditions of license agreement; Type \\\"decline\\\" to exit. "
ST_RESTATEMENT_ACCEPT_DECLINE="Invalid response, expected \\\"accept\\\" or \\\"decline\\\" ... try again ?"
ST_ER_INVALID_RESP1="ERROR: Invalid response, expected"
ST_ER_INVALID_RESP2="ERROR: Invalid response ... try again"
ST_ER_INVALID_RESP3="... try again ?"
ST_ER_NO_LIC_FILE="ERROR: Cannot find license file ... aborting"
ST_TO_ACCEPT="To accept the terms and conditions of this agreement enter"
ST_TO_DECLINE="To decline the terms and conditions of this agreement enter"
ST_REQ0101="Please type"
ST_REQ0102="to accept the terms and conditions of license agreement;"
ST_REQ0103="Type"
ST_REQ0104="to exit. "
ST_ER_LIC_NOT_ACCP="License agreement not accepted ... aborting installation"
ST_FREE_SPACE_INFO01="This installation requires"
ST_FREE_SPACE_INFO02="MB of free disk space."
ST_DONE_WORD="Done"
ST_ER_INSTALLING01="ERROR installing"
ST_ER_INSTALLING02="invalid product name"
ST_RES_INST_DIR="Enter installation directory for Adobe Reader"
ST_ER_SAME_FILE_NAME_AS_DIR="exists but is not a directory. Please specify a different location."
ST_DIR_INFO01="Directory"
ST_DIR_INFO02="does not exist."
ST_QUES_CREAT_DIR="Do you want to create it now? [y] "
ST_ER_EXIT="Exiting installation..."
ST_ER_DIR="ERROR: Cannot make directory"
ST_ER_WRITE="ERROR: Cannot write to directory"
ST_ER_NO_LIBCURL01="Not able to locate libcurl.so. Some of the functionality of Adobe Reader may be hampered."
ST_ER_NO_LIBCURL02="It is recommended to install curl ver."
ST_ER_NO_LIBCURL03="or any version later than ver."
ST_WARN_NO_LIBSSL01="WARNING: The libssl.so version on your machine is not compatible to libssl.so.0.9.6."
ST_WARN_NO_LIBSSL02="Please install libssl.so.0.9.6."
ST_WARN_LD_LIB01="exists in the directory"
ST_WARN_LD_LIB02="but this directory is not included in LD_LIBRARY_PATH."
ST_WARN_LD_LIB03="Please include the directory"
ST_WARN_LD_LIB04="in LD_LIBRARY_PATH"
ST_WARN_LD_LIB05="exists in the directory"
ST_ER_NO_CONFIG="ERROR: No configurations found ... aborting"
ST_WARN_NO_CONFIG="WARNING: The chosen configuration will not run on your current platform"
ST_QUE_CONT="Continue installation?"
ST_INFO_DEF_CONFIG1="Install default configuration"
ST_INFO_DEF_CONFIG2="The following configurations are available for installation:"
ST_QUE_CONFIG="Enter the configuration number to install: "
ST_EXIT_INFO="Exit Acrobat installation"
ST_PLAT_INDEP_FILES="Installing platform independent files ... "
ST_PLAT_DEP_FILES="Installing platform dependent files ... "
ST_RPM_CAN_NOT_DEL="could not be deleted as it has some extra file or files that were not installed by rpm"
ST_WEL_ALK="Welcome to the Asian Language Kit installation."
ST_INFO_ALK01="This installation will not work if you do not have the"
ST_INFO_ALK02="Unix Adobe Reader version 7.0 installed prior to this installation."
ST_INFO_ALK03="If you do not have Adobe Reader version 7.0 already installed on your"
ST_INFO_ALK04="system please do so before installing this Asian Language Kit."
ST_ER_ALK01="ERROR: directory must be an absolute path"
ST_ER_ALK02="ERROR: Directory "
ST_ER_ALK03="does not exist."
ST_ER_ALK04="ERROR: AcroVersion file does not exist."
ST_ER_ALK05="ERROR: Incorrect Acrobat version:"
ST_ER_ALK06="ERROR: Could not find distribution ... aborting"
ST_IF_ALK07="Enter the location where you installed the Adobe Reader"
ST_INFO_ALK_CMPLT="Installation completed."
ST_WEL_HLK="Welcome to the Extended Language Pack installation."
ST_INFO_HLK04="system please do so before installing this Extended Language Pack."
ST_INFO_HLK05="Installing Extended Language Pack Files ... "
ST_WEL_CLK="Welcome to the Central European Font Pack installation."
ST_INFO_CLK04="system please do so before installing this Central European Font Pack."
ST_INFO_CLK05="Installing Central European Language Pack Files ... "
ST_ER_AR01="ERROR: Cannot determine current directory."
ST_ER_AR02="ERROR: Cannot find installation directory."
ST_ER_AR03="ERROR: Cannot find"
ST_INFO_AR01="The OS named "
ST_INFO_AR02="is currently not installed."
ST_INFO_AR03="Try running on an installed platform and connecting to your display."
ST_INFO_AR04="Installed platform(s) include the following:"
ST_INFO_AR05="not installed for this configuration,"
ST_IBP_MISC_03="Mozilla"
ST_IBP_MISC_04="Firefox"
ST_IBP_MISC_05="Netscape"
ST_IBP_MISC_06="Quit"
ST_IBP_INFO_01="This will install the browser plugin for acroread."
ST_IBP_INFO_02="Perform global installation"
ST_IBP_INFO_03="Perform user-specific installation"
ST_IBP_INFO_04="Enter your choice"
ST_IBP_INFO_05="Do you want to install another browser ?"
ST_IBP_INFO_06="Enter the install directory for Adobe Reader 7.0"
ST_IBP_INFO_07="Enter the browser install directory"
ST_IBP_INFO_08="The plugin seems to be already installed. Are you sure you want to overwrite ?"
ST_IBP_INFO_09="Installation cancelled."
ST_IBP_INFO_10="Installation successful."
ST_IBP_INFO_11="This will enable the plugin for Mozilla, Firefox and Netscape."
ST_IBP_INFO_12="If you are facing any problem in getting the installation to work for your browser, please copy the following file to the plugin folder of the browser:"
ST_IBP_INFO_13="Acroread path specified"
ST_IBP_INFO_14="Press <Enter> to continue"
ST_IBP_INFO_15="In case of difficulties please refer to the documentation provided along with the browser for addition of new plugins."
ST_IBP_INFO_16="Installing plugin in"
ST_IBP_INFO_17="Do you want to perform automatic installation ?"
ST_IBP_INFO_18="Finished with automatic install."
ST_IBP_INFO_19="Do you want to perform manual installation ?"
ST_IBP_INFO_20="Do you want to install the browser plugin ?"
ST_IBP_INFO_21="Browser plugin installation skipped."
ST_IBP_INFO_22_1="Run"
ST_IBP_INFO_22_2="to install browser plugin."
ST_IBP_INFO_23="has been added."
ST_IBP_INFO_24="Trying to install plugin for browser"
ST_IBP_INFO_25="Installation failed"
ST_IBP_ERR_01="Could not find the browser plugin file"
ST_IBP_ERR_02="Could not find the browser plugins folder"
ST_IBP_ERR_03="Could not find the browser folder"
ST_IBP_ERR_04="Could not remove previous version of the plugin in"
ST_IBP_ERR_05_1="Could not copy the plugin file"
ST_IBP_ERR_05_2="to"
ST_IBP_ERR_06="Could not create the directory"
ST_IBP_ERR_07="Could not find browser plugin install script."
ST_IBP_ERR_08="already exists as a special file and cannot overwrite it."
ST_IBP_ERR_09="Unable to query HOME variable from the environment. Cannot find your home directory."
ST_IBP_ERR_10="Could not find the installation folder"
ST_IBP_ERR_11="INTERNAL ERROR ..... No matching OS name."
ST_SEP_INFO_01="Enter the install directory for Adobe Reader 7.0"
ST_SEP_INFO_02="INTERNAL ERROR ..... No matching OS name."
ST_SEP_INFO_03="Unable to find appropriate files in the installation path."
ST_SEP_INFO_04="Resetting old contexts"
ST_SEP_INFO_05="Setting new contexts for library files"
ST_SEP_INFO_06="This will try to update the library files to make them SELinux aware."
ST_SEP_INFO_07="Could not find the installation folder."
ST_SEP_INFO_08="Finished setting the contexts. You can check the log at"
ST_SEP_INFO_09="Failure in command"
ST_SEP_INFO_10="Patch might not have completed properly. You can check the log at"
ST_IOP_ERR1="OpenOffice PDF Plugin could not be registered. Please read the instructions in "
ST_IOP_ERR2="for manual installation."
ST_IOP_ERR3="OpenOffice >= 1.9 is required for OpenOffice PDF Plugin to run properly. Skipping registration of PDF Plugin."
ST_IOP_ERR4="OpenOffice binary soffice could not located in the specified directory."
ST_IOP_INFO_01="Please specify the directory where OpenOffice is installed: "
ST_IOP_INFO_02="Do you want to install the OpenOffice Plugin ?"
ST_IAP_ERR1="Adobe PDF Plugin could not be registered. Please follow the instructions in "
ST_IAP_INFO_01="Do you want to install the Adobe PDF plugin ?"
ST_IFE_INFO_01="Do you want to install the firefox extension ?"
ST_IFE_INFO_02="Please specify the path for Firefox executable : "
ST_IFE_ERR_01="Firefox exe not found or does not have executable permissions."
ST_IDI_INFO_01="Do you want to install the Distiller ?"
ST_MIME_INFO_01="Please login again for changes to MIME types and icons to take effect."
true
}

setLangENU

MkTemp()
{
    if [ -z "$mkTempCount" ]; then
        mkTempCount="0"
    fi
 
    TmpFile="/tmp/acrobat.$$.$mkTempCount"
 
    while [ -f "$TmpFile" ]; do
        mkTempCount=`expr $mkTempCount + 1`
        TmpFile="/tmp/acrobat.$$.$mkTempCount"
    done
 
    touch "$TmpFile" && chmod 644 "$TmpFile" && echo "$TmpFile"
}

readlink()
{
    OLDPWD="`/bin/pwd`"
    lfile="$1"

    while [ -h "$lfile" -a -f "$lfile" ]; do
        CWD="`dirname "$lfile"`"
        if [ "`expr "${CWD}" : "\.\."`" = "2" ]; then
            CWD="`/bin/pwd`/$CWD"
        fi
        lfile="`basename "$lfile"`"
        cd "$CWD"
        lfile="`/bin/ls -l "$lfile"|sed 's/^.*-> *\(.*\) *$/\1/'`"
    done

    if [ -f "$lfile" ]; then
        CWD="`dirname "$lfile"`"
        lfile="`basename "$lfile"`"
        if [ "`expr "${CWD}" : "\.\."`" = "2" ]; then
            CWD="`/bin/pwd`/$CWD"
        fi
        cd "$CWD"
        echo `/bin/pwd`/$lfile
        cd "$OLDPWD"
        return 0
    fi

    cd "$OLDPWD"
    return 1
}


ver=7.0.9
cwd="`/bin/pwd 2> /dev/null`"

if [ -h "$0" ]; then
 ScriptVariable=`readlink $0`
 ScriptDirectory=`dirname "$ScriptVariable"`
else
 ScriptDirectory=`dirname "$0"`
 cd "$ScriptDirectory"
 ScriptDirectory="`/bin/pwd 2> /dev/null`"
 cd "$cwd"
fi
install_dir=`dirname "$ScriptDirectory"`/Reader


#
# Prepend a colon separated environment variable
# $1 string to be prepended
# $2 environment variable
#
prepend()
{
  if [ -z "$2" -o "$2" = "$1" ] ; then
    echo "$1"
  else
    first="`expr "$2" : '\([^:]*\):'`"
    if [ "$first" = "$1" ] ; then
      echo "$2"
    else
      echo "${1}:${2}"
    fi
  fi
}


#
# Tests the version file in an installation directory.
#
test_install_dir()
{
	if [ "`cat "$1"/AcroVersion 2>/dev/null`" = "$ver" ] ; then
		return 0
	else
		return 1
	fi
}


#
# Check a given file in given path
#
check_file_in_named_path()
{
    if [ -x "$2/$1" ] ; then
	return 1
    fi
        
    return 0
}


#
# Check a given file in $PATH
#

check_file_in_path()
{
    OLD_IFS=$IFS
    IFS=":"
	
    if [ -n "$PATH" ] ; then
	for i in $PATH; do
	    if [ -d "$i" ] ; then
		check_file_in_named_path "$1" "$i"
		if [ $? -eq 1 ]; then
		    IFS=$OLD_IFS
		    return 1
		fi
	    fi
	done
    fi
    
    IFS=$OLD_IFS
    return 0
}

IsUserAffirmative()
{
    read userResp
        if [ "$userResp" ] ; then
            case "$userResp" in
                y|Y|[yY][eE][sS]) return 0 ;;
            esac
        fi
        return 1
}

InstallCertificate()
{
#$1 is install_dir
#$2 is URL
#$3 is port
    RETVAL=0
    INSTALL_DIR=$1
    LOGFILE=`MkTemp /tmp/ssl_logXXXXXX`
    CERTNAME=`MkTemp /tmp/certi.cerXXXXXX`
    CERTDATA=`MkTemp /tmp/certDataXXXXXX`

    CertificateInstallDirectory="$HOME/.adobe/Acrobat/`echo $ver | cut -c1-3`/Cert"
	
    check_file_in_path openssl
    if [ $? -ne 1 ]
    then
      echo "Unable to find openssl, please make sure the openssl binary is in the PATH"
      exit 1
    fi

    echo "Fetching certificate from website...."
    echo "QUIT"  | openssl s_client -connect $2:$3 >$LOGFILE

    echo "Processing ...."


    beginCert=`cat $LOGFILE |grep -n "BEGIN CERTIFICATE---" |cut -f1 -d":"`
    endCert=`cat $LOGFILE |grep -n "END CERTIFICATE---" |cut -f1 -d":"`

    head -$endCert $LOGFILE | tail -`expr $endCert - $beginCert + 1` >$CERTNAME

    openssl x509 -inform PEM -in $CERTNAME -text -out $CERTDATA
    HASH=`openssl x509 -hash -noout -in $CERTNAME`

    echo "The website presented the following Certificate"
    echo
    echo

    more $CERTDATA

    echo "Do you want to accept and install it (y/n)?"

    if IsUserAffirmative
        then
            if [ ! -d "$CertificateInstallDirectory" ]
            then
              mkdir -p "$CertificateInstallDirectory"  
              if [ $? -ne 0 ]
              then
                echo $$ST_ER_DIR
                exit 1
              fi
            fi
          
            cp $CERTNAME "$CertificateInstallDirectory"/${HASH}.0
            if [ $? = "0" ]
                then
                    echo "Certificate successfuly installed."
            else
                echo "There was a problem installing the certificate"
                RETVAL=1
            fi
    else
        echo "Not installing the certtificate."
        RETVAL=2
    fi


    rm -f $CERTNAME
    rm -f $CERTDATA
    rm -f $LOGFILE
    return $RETVAL
}

#  Function : get_gtk_file_ver($1)
#  $1 : name of the gtk-lib file
#  Return value : 0 if version >= 2.4 else 1
#  Side Effects : echo the gtk-version
#  Aim : To find the version of gtk-lib file and echo it

get_gtk_file_ver()  
{
   	if [ -f "$1" ]; then
    	if [ -h "$1" ]; then
	    	ifile=`readlink $1`
		    if [ $? -eq 1 ]; then
   				return 1
    		fi
        fi

   		mfile=`basename $ifile`
    	echo $mfile | grep -q "libgtk-x11-\([0-9]*\).0.so.0.\([0-9]*\).\([0-9]*\)" 2>/dev/null

   		if [ $? -ne 0 ]; then
           return 1 
        fi

   		echo $mfile| sed 's/libgtk-x11-\([0-9]*\).0.so.0.\([0-9]\)00.\([0-9]*\)\|\(.*\)/\1\2\3/g'
        return 0
    fi

    return 1
}


#  Function : check_gtk_ver_and_set_lib_path($1)
#  $1 : minimum base version of the gtk required.
#  Return Value : 0 if LD_LIBRARY_PATH is set properly else 1
#  Side Effects : LD_LIBRARY_PATH is modified
#  Aim : To find out the correct gtk libraries and LD_LIBRARY_PATH to include the directory at the start which contain gtk-libs >= 2.4

check_gtk_ver_and_set_lib_path()
{
    if [ -z "$LD_LIBRARY_PATH" ]; then
        LD_LIBRARY_PATH=/lib:/usr/lib
    else
        LD_LIBRARY_PATH="$LD_LIBRARY_PATH":/lib:/usr/lib
    fi

    OLD_IFS="$IFS"
    IFS=':'

    for idir in $LD_LIBRARY_PATH
    do
        if [ -z "$idir" ]; then
            continue
        fi

	    ifile="$idir"/libgtk-x11-2.0.so

		base_version="$1"
        version=`get_gtk_file_ver "$ifile"`

        if [ $? -ne 0 ]; then
            continue
        fi

        len_version=`expr length $version`
        base_version=`expr substr "${base_version}0000000000" 1 $len_version`
        len_base_version=`expr length $base_version`

        while [ $len_version -gt $len_base_version ]; do
            base_version=`expr substr "${base_version}0000000000" 1 $len_version`
            len_base_version=`expr length $base_version`
        done

    	if [ $version -ge $base_version ]; then
	   		export LD_LIBRARY_PATH="$idir":"$LD_LIBRARY_PATH"
            IFS="$OLD_IFS"
            OLD_IFS=""
		    return 0
    	fi
    done

    IFS="$OLD_IFS"
    OLD_IFS=""

    # This checks for libs in cache /etc/ld.so.cache
    for ifile in `/sbin/ldconfig -p|grep "libgtk-x11-2.0.so$"|sed 's/.*[ \t]*=>[ \t]*\(.*\)/\1/g' 2>/dev/null`; do
        version=`get_gtk_file_ver "$ifile"`

    	while [ ${#version} -gt ${#base_version} ]; do
	   		base_version="${base_version}0"
	    done

        if [ $version -ge $base_version ]; then
            export LD_LIBRARY_PATH="`dirname "$ifile"`":"$LD_LIBRARY_PATH"
            return 0
        fi
    done

    return 1
}


#
# Get the current working directory.
# Try to avoid automounter directories by checking
# if $HOME or $PWD is the same directory as pwd,
# and removing the automount directory component.
#
if [ -z "$cwd" -o ! -d "$cwd" ] ; then
  echo "$ST_ER_AR01"
  exit 1
fi

if [ "$HOME" -a -d "$HOME" ] && [ "`cd / ; cd "$HOME" ; /bin/pwd`" = "$cwd" ] ; then
  cwd="$HOME"
elif [ "$PWD" -a -d "$PWD" ] && [ "`cd / ; cd "$PWD" ; /bin/pwd`" = "$cwd" ] ; then
  cwd="$PWD"
fi


PWD="$cwd"
export PWD


#
# Setup ACRO_ARG0 to this script
#
arg0="$0"
if [ "$arg0" ] ; then
  case "$arg0" in
     /*) ;;
    ./*) arg0="$cwd/`expr "$arg0" : '\./\(.*\)'`" ;;
      *) arg0="$cwd/$arg0" ;;
  esac

  ACRO_ARG0="$arg0"
  export ACRO_ARG0
fi


#
# Try to find the installation directory
#
if ( test_install_dir "$install_dir" ) ; then
  ACRO_INSTALL_DIR="$install_dir"
  export ACRO_INSTALL_DIR
  
else
  script="$arg0"
  while [ "$script" ] ; do
    install_dir="`dirname "$script"`"
    if ( test_install_dir "$install_dir/Reader" ) ; then
      ACRO_INSTALL_DIR="$install_dir/Reader"
      export ACRO_INSTALL_DIR
      break
    fi

    install_dir="`dirname "$install_dir"`"
    if ( test_install_dir "$install_dir/Reader" ) ; then
      ACRO_INSTALL_DIR="$install_dir/Reader"
      export ACRO_INSTALL_DIR
      break
    fi

    if [ -h "$script" ] ; then
      new_script=`readlink "$script"`
      if [ "$new_script" -a "`expr "$new_script" : '/.*'`" = 0 ] ; then
        new_script="`dirname "$script"`/$new_script"
      fi
      script="$new_script"
    else
      break
    fi
  done

  if ( test_install_dir "$ACRO_INSTALL_DIR" ) ; then
    :
  elif ( test_install_dir "$ACRO_HOME" ) ; then
    ACRO_INSTALL_DIR="$ACRO_HOME"
    export ACRO_INSTALL_DIR
  else
    echo "$ST_ER_AR02"
    exit 1
  fi
fi


#
# setup the configuration from uname
#
os_name=`uname -s`
os_release=`uname -r`

case "$os_name" in
  SunOS)
    case "$os_release" in
      4.1.3*|4.1.4*|4.1C)
        ACRO_CONFIG=sparcsun
        export ACRO_CONFIG
        ;;
      5.*)
        machine_type=`uname -p`
        case "$machine_type" in
          sparc)
            ACRO_CONFIG=sparcsolaris
            export ACRO_CONFIG
            ;;
          intel|i386)
            ACRO_CONFIG=intelsolaris
            export ACRO_CONFIG
            ;;
          ppc)
            ACRO_CONFIG=ppcsolaris
            export ACRO_CONFIG
            ;;
        esac
        ;;
    esac
    ;;
  Linux)
    ACRO_CONFIG=intellinux
    export ACRO_CONFIG
    ;;
  AIX)
    ACRO_CONFIG=rs6000aix
    export ACRO_CONFIG
    ;;
  HP-UX)
    ACRO_CONFIG=hppahpux
    export ACRO_CONFIG
esac

if [ -z "$ACRO_CONFIG" ] ; then
   echo "$ST_INFO_AR01 $os_name $ST_VERSION $os_release $ST_INFO_AR02"
   echo "$ST_INFO_AR03"
   echo "$ST_INFO_AR04"

  if [ -d "$ACRO_INSTALL_DIR"/sparcsolaris ] ; then
    echo "  SPARC/Solaris version 2.x"
  fi
  if [ -d "$ACRO_INSTALL_DIR"/intellinux ] ; then
    echo "  Intel/Linux"
  fi
  exit 1
fi

# Check the version of gtk and update the LD_LIBRARY_PATH if required.

if [ "`uname -s`" = "Linux" ]; then
	MIN_GTK_VERSION="240"
	check_gtk_ver_and_set_lib_path  "$MIN_GTK_VERSION"  ### returns 0 if found gtk >= 2.4
fi

#
# Setup configuration specific environment variables
#
case "$ACRO_CONFIG" in
  sparcsolaris)
    LD_LIBRARY_PATH="`prepend "$ACRO_INSTALL_DIR/$ACRO_CONFIG/lib:$ACRO_INSTALL_DIR/$ACRO_CONFIG/sidecars" "$LD_LIBRARY_PATH"`"
    export LD_LIBRARY_PATH
    ;;
  intellinux)
    LD_LIBRARY_PATH="`prepend "$ACRO_INSTALL_DIR/$ACRO_CONFIG/lib:$ACRO_INSTALL_DIR/$ACRO_CONFIG/sidecars" "$LD_LIBRARY_PATH"`"
    export LD_LIBRARY_PATH
    ;;
  rs6000aix)
    LIBPATH="`prepend "$ACRO_INSTALL_DIR/$ACRO_CONFIG/lib:$ACRO_INSTALL_DIR/$ACRO_CONFIG/sidecars:/opt/freeware/lib:" "$LIBPATH"`"
    export LIBPATH
	;;
  hppahpux)
    SHLIB_PATH="`prepend "$ACRO_INSTALL_DIR/$ACRO_CONFIG/lib:$ACRO_INSTALL_DIR/$ACRO_CONFIG/sidecars:/opt/graphics/OpenGL/lib" "$SHLIB_PATH"`"
	LD_PRELOAD=/opt/graphics/OpenGL/lib/libGL.sl
	export SHLIB_PATH
	export LD_PRELOAD
    ;;
esac

DefaultPSRESPATH="$HOME/psres:$HOME/fonts:/usr/psres"
if [ -z "$PSRESOURCEPATH" ] ; then
  PSRESOURCEPATH="$DefaultPSRESPATH"
else
  PSRESOURCEPATH="$PSRESOURCEPATH":"$DefaultPSRESPATH"
fi
case "$PSRESOURCEPATH" in
  ::*|*::*|*::)
    ;;
  *)
    PSRESOURCEPATH="$PSRESOURCEPATH"::
    ;;
esac
export PSRESOURCEPATH

directory="`basename \"$ACRO_INSTALL_DIR\"`"

if [ "$directory" = "Reader" ]; then
	cmd="acroread"
    	prod="Adobe Reader"
else
	if [ "$directory" = "Acrobat" ]; then
		cmd="acroexch"
    		prod="Adobe Acrobat"
	fi
fi

#
# Set the command.  Process any debug flags and exec.
#
ACRO_EXEC_CMD="$ACRO_INSTALL_DIR/$ACRO_CONFIG/bin/$cmd"
export ACRO_EXEC_CMD

ACRO_RES_DIR=$ACRO_INSTALL_DIR/../Resource
export ACRO_RES_DIR

ACRO_LANG=$ST_LANG
export ACRO_LANG

# Adobe Reader/Acrobat uses gconftool-2 to check whether accessibility support is enabled. Please refer to the Readme file to work around this.
check_file_in_path gconftool-2
if [ $? -eq 0 ]
then
	# gconftool-2 is not there on system, turn off AT support
	ACRO_AT_ACTIVE="false"
	export ACRO_AT_ACTIVE
else
	ACRO_AT_ACTIVE=`gconftool-2 -g /desktop/gnome/interface/accessibility 2>/dev/null`
	export ACRO_AT_ACTIVE
fi

if [ "$ACRO_AT_ACTIVE" = "true" ]; then
	GTK_MODULES=gail:atk-bridge
	export GTK_MODULES
fi

if [ "$1" = "-installCertificate" ] 
then
    InstallCertificate $ACRO_INSTALL_DIR $2 $3
    exit $?
fi

if [ "$1" = "-DEBUG" ] ; then
  ACRODEBUG=1
  ACRO_CRASHLOG=1
  export ACRODEBUG ACRO_CRASHLOG

  if [ "`ulimit -c 2>/dev/null`" = "0" ]
  then
    ulimit -c 1000000 >/dev/null 2>&1
  fi

  if [ $# = 1 ] ; then
    export ACRO_EXEC_CMD
    exec "$SHELL"
  else
    shift
    exec ${1+"$@"} "$ACRO_EXEC_CMD"
  fi
fi

if [ -f "$ACRO_EXEC_CMD" ] ; then
  exec "$ACRO_EXEC_CMD" ${1+"$@"}
else
  echo "$ST_ER_AR03 $ACRO_EXEC_CMD"
  echo "  $prod $ST_INFO_AR05 \"$ACRO_CONFIG\"."
  exit 1
fi
