#!/bin/sh
#


setLangITA()
{
ST_LANG="ITA"
ST_LANG_SMALL="ita"
ST_READER_RPM_NAME="AdobeReader_ita"
ST_EXCHANGE_RPM_NAME="AdobeAcrobat_ita"
ST_COMMENT_WORD="Commento"
ST_DESCRIPTION_WORD="Descrizione"
ST_COMMENT_RPM="Avvia Adobe Reader 7.0"
ST_DES_RPM="Adobe Reader per Linux. Un'applicazione mediante la quale  possibile visualizzare, esplorare e stampare documenti PDF."
ST_DES_TAG01="Mediante Adobe Reader sar possibile leggere documenti in formato PDF."
ST_DES_TAG02="Adobe Reader consente inoltre di effettuare ricerche nei file PDF,"
ST_DES_TAG03="cercare file PDF su Internet e collaborare alla revisione dei documenti."
ST_DES_TAG04="Per i dettagli, visitare il sito www.adobe.com."
ST_THE_FILE="Il file"
ST_FOR="for"
ST_YES="s"
ST_NO="no"
ST_OR="oppure"
ST_SMALL_Y="s"
ST_SMALL_N="n"
ST_CAPS_Y="S"
ST_CAPS_N="N"
ST_ACCEPT_CAPS="ACCETTA"
ST_DECLINE_CAPS="RIFIUTA"
ST_ACCEPT="accetta"
ST_DECLINE="rifiuta"
ST_VERSION="versione"
ST_STATEMENT_ACCEPT_DECLINE="Digitare \\\"accetta\\\" per accettare i termini e le condizioni dell'accordo di licenza; digitare \\\"rifiuta\\\" per uscire. "
ST_RESTATEMENT_ACCEPT_DECLINE="Risposta non valida. Le due scelte possibili sono \\\"accetta\\\" o \\\"rifiuta\\\". Riprovare?"
ST_ER_INVALID_RESP1="ERRORE: risposta non valida. Previsto:"
ST_ER_INVALID_RESP2="ERRORE: risposta non valida. Riprovare."
ST_ER_INVALID_RESP3="...Riprovare?"
ST_ER_NO_LIC_FILE="ERRORE: impossibile trovare il file di licenza. L'operazione viene interrotta."
ST_TO_ACCEPT="Per accettare i termini e le condizioni di questo Accordo di licenza, immettere"
ST_TO_DECLINE="Per rifiutare i termini e le condizioni di questo Accordo di licenza, immettere"
ST_REQ0101="Digitare"
ST_REQ0102="per accettare i termini e le condizioni di questo Accordo di licenza;"
ST_REQ0103="Digitare"
ST_REQ0104="per uscire. "
ST_ER_LIC_NOT_ACCP="Accordo di licenza non accettato. L'installazione verr interrotta."
ST_FREE_SPACE_INFO01="Questa installazione richiede"
ST_FREE_SPACE_INFO02="MB di spazio libero su disco."
ST_DONE_WORD="Fatto"
ST_ER_INSTALLING01="ERRORE durante l'installazione del file "
ST_ER_INSTALLING02="nome prodotto non valido"
ST_RES_INST_DIR="Immettere la directory di installazione per Adobe Reader"
ST_ER_SAME_FILE_NAME_AS_DIR="esiste, ma non  una directory. Specificare una posizione diversa."
ST_DIR_INFO01="La directory"
ST_DIR_INFO02="non esiste."
ST_QUES_CREAT_DIR="Crearla adesso? [s] "
ST_ER_EXIT="Uscita dall'installazione in corso..."
ST_ER_DIR="ERRORE: impossibile creare la directory "
ST_ER_WRITE="ERRORE: impossibile scrivere nella directory "
ST_ER_NO_LIBCURL01="Impossibile individuare libcurl.so. Alcune funzioni di Adobe Reader potrebbero non essere disponibili"
ST_ER_NO_LIBCURL02="Si consiglia di installare la versione curl"
ST_ER_NO_LIBCURL03="o qualsiasi versione successiva alla versione "
ST_WARN_NO_LIBSSL01="AVVISO: la versione di libssl.so presente nel computer non  compatibile con libssl.so.0.9.6."
ST_WARN_NO_LIBSSL02="Installare libssl.so.0.9.6."
ST_WARN_LD_LIB01="esiste nella directory"
ST_WARN_LD_LIB02="ma questa directory non  inclusa in LD_LIBRARY_PATH."
ST_WARN_LD_LIB03="Includere la directory"
ST_WARN_LD_LIB04="in LD_LIBRARY_PATH"
ST_WARN_LD_LIB05="esiste nella directory"
ST_ER_NO_CONFIG="ERRORE: non  stata trovata alcuna configurazione. L'operazione viene interrotta."
ST_WARN_NO_CONFIG="AVVISO: la configurazione scelta non verr eseguita sulla piattaforma corrente"
ST_QUE_CONT="Proseguire con l'installazione?"
ST_INFO_DEF_CONFIG1="Installa configurazione predefinita"
ST_INFO_DEF_CONFIG2="Sono disponibili per l'installazione le configurazioni seguenti:"
ST_QUE_CONFIG="Immettere il numero della configurazione da installare: "
ST_EXIT_INFO="Esci dall'installazione Acrobat"
ST_PLAT_INDEP_FILES="Installazione dei file indipendenti dalla piattaforma in corso... "
ST_PLAT_DEP_FILES="Installazione dei file dipendenti dalla piattaforma in corso... "
ST_RPM_CAN_NOT_DEL="non pu essere eliminata perch contiene altri file non installati mediante rpm"
ST_WEL_ALK="Benvenuti all'installazione del kit Lingua asiatica."
ST_INFO_ALK01="Questa installazione non funziona se in precedenza non"
ST_INFO_ALK02=" stato installato Adobe Reader versione 7.0 per Unix."
ST_INFO_ALK03="Se Adobe Reader versione 7.0 non  gi stato installato nel"
ST_INFO_ALK04="sistema, procedere all'installazione prima di installare il kit Lingua asiatica."
ST_ER_ALK01="ERRORE: la directory deve essere un percorso assoluto"
ST_ER_ALK02="ERRORE: la directory "
ST_ER_ALK03="non esiste."
ST_ER_ALK04="ERRORE: il file AcroVersion non esiste."
ST_ER_ALK05="ERRORE: versione di Acrobat errata:"
ST_ER_ALK06="ERRORE: impossibile trovare la distribuzione. L'operazione viene interrotta."
ST_IF_ALK07="Immettere il percorso in cui installare Adobe Reader"
ST_INFO_ALK_CMPLT="Installazione completata."
ST_WEL_HLK="Benvenuti all'installazione del pacchetto lingue estese."
ST_INFO_HLK04="sistema, procedere all'installazione prima di installare il pacchetto lingue estese."
ST_INFO_HLK05="Installazione dei file del pacchetto lingue estese in corso... "
ST_WEL_CLK="Benvenuti all'installazione del pacchetto font Europa centrale."
ST_INFO_CLK04="sistema, procedere all'installazione prima di installare il pacchetto font Europa centrale."
ST_INFO_CLK05="Installazione dei file del pacchetto font Europa centrale in corso... "
ST_ER_AR01="ERRORE: impossibile determinare la directory corrente."
ST_ER_AR02="ERRORE: impossibile trovare la directory di installazione."
ST_ER_AR03="ERRORE: impossibile trovare"
ST_INFO_AR01="Il sistema operativo "
ST_INFO_AR02="non  installato."
ST_INFO_AR03="Provare a effettuare l'esecuzione su una piattaforma installata e a connettersi allo schermo."
ST_INFO_AR04="Le piattaforme installate comprendono:"
ST_INFO_AR05="non installata per questa configurazione,"
ST_IBP_MISC_03="Mozilla"
ST_IBP_MISC_04="Firefox"
ST_IBP_MISC_05="Netscape"
ST_IBP_MISC_06="Esci"
ST_IBP_INFO_01="Verr installato il plug-in del browser per acroread."
ST_IBP_INFO_02="Esegui installazione globale"
ST_IBP_INFO_03="Esegui installazione specifica per l'utente"
ST_IBP_INFO_04="Specificare la scelta desiderata"
ST_IBP_INFO_05="Installare un altro browser ?"
ST_IBP_INFO_06="Specificare la directory di installazione per Adobe Reader 7.0"
ST_IBP_INFO_07="Specificare la directory di installazione del browser"
ST_IBP_INFO_08="Il plug-in  gi installato. Sovrascriverlo?"
ST_IBP_INFO_09="Installazione annullata."
ST_IBP_INFO_10="Installazione completata."
ST_IBP_INFO_11="Il plug-in verr abilitato per Mozilla, Firefox e Netscape."
ST_IBP_INFO_12="Se si riscontrano problemi nel funzionamento dell'installazione con il browser in uso, copiare il seguente file nella cartella dei plug-in del browser:"
ST_IBP_INFO_13="Percorso di Acroread specificato"
ST_IBP_INFO_14="Premere <Invio> per continuare"
ST_IBP_INFO_15="In caso di problemi, consultare la documentazione fornita con il browser per l'aggiunta di nuovi plug-in."
ST_IBP_INFO_16="Installazione del plug-in"
ST_IBP_INFO_17="Eseguire l'installazione automatica?"
ST_IBP_INFO_18="Installazione automatica completata."
ST_IBP_INFO_19="Eseguire l'installazione manuale?"
ST_IBP_INFO_20="Installare il plug-in del browser?"
ST_IBP_INFO_21="Impossibile eseguire l'installazione del  plug-in del browser."
ST_IBP_INFO_22_1="Eseguire"
ST_IBP_INFO_22_2="per installare il plug-in del browser."
ST_IBP_INFO_23=" stato aggiunto."
ST_IBP_INFO_24="Si sta tentando di installare il plug-in per il browser"
ST_IBP_INFO_25="Installazione non riuscita"
ST_IBP_ERR_01="Impossibile trovare il file di plug-in del browser"
ST_IBP_ERR_02="Impossibile trovare la cartella di plug-in del browser"
ST_IBP_ERR_03="Impossibile trovare la cartella del browser"
ST_IBP_ERR_04="Impossibile rimuovere la versione precedente del plug-in in"
ST_IBP_ERR_05_1="Impossibile copiare il file di plug-in"
ST_IBP_ERR_05_2="in"
ST_IBP_ERR_06="Impossibile creare la directory"
ST_IBP_ERR_07="Impossibile trovare lo script di installazione dei plug-in del browser."
ST_IBP_ERR_08="esiste gi come file speciale e non pu essere sovrascritto."
ST_IBP_ERR_09="Impossibile interrogare la variabile HOME dall'ambiente. Impossibile trovare la directory home."
ST_IBP_ERR_10="Impossibile trovare la cartella di installazione"
ST_IBP_ERR_11="ERRORE INTERNO ..... Nessun nome di sistema operativo corrispondente."
ST_SEP_INFO_01="Specificare la directory di installazione per Adobe Reader 7.0"
ST_SEP_INFO_02="ERRORE INTERNO ..... Nessun nome OS corrispondente."
ST_SEP_INFO_03="Impossibile trovare i file appropriati nel percorso di installazione."
ST_SEP_INFO_04="Reimpostazione vecchi contesti"
ST_SEP_INFO_05="Impostazione nuovi contesti per i file di libreria"
ST_SEP_INFO_06="I file di libreria verranno aggiornati per renderli compatibili con SELinux."
ST_SEP_INFO_07="Impossibile trovare la cartella di installazione."
ST_SEP_INFO_08="Impostazione dei contesti completata.  possibile controllare il registro in"
ST_SEP_INFO_09="Comando non riuscito"
ST_SEP_INFO_10="Impossibile completare la patch correttamente.  possibile controllare il registro in"
ST_IOP_ERR1="Impossibile registrare il plug-in PDF OpenOffice. Leggere le istruzioni in"
ST_IOP_ERR2="per l'installazione manuale."
ST_IOP_ERR3=" necessario disporre di OpenOffice >= 1.9 perch il plug-in PDF OpenOffice funzioni correttamente. Registrazione del plug-in PDF saltata."
ST_IOP_ERR4="Impossibile individuare il binario di OpenOffice 'soffice' nella directory specificata."
ST_IOP_INFO_01="Specificare la directory in cui  installato OpenOffice:"
ST_IOP_INFO_02="Installare il plug-in OpenOffice?"
ST_IAP_ERR1="Impossibile registrare il plug-in Adobe PDF. Eseguire le istruzioni in"
ST_IAP_INFO_01="Installare il plug-in Adobe PDF?"
ST_IFE_INFO_01="Installare l'estensione Firefox?"
ST_IFE_INFO_02="Specificare il percorso dell'eseguibile Firefox: "
ST_IFE_ERR_01="Firefox exe non trovato o autorizzazioni sull'eseguibile non disponibili."
ST_IDI_INFO_01="Installare Distiller?"
ST_MIME_INFO_01="Accedere di nuovo per far s che le modifiche ai tipi e alle icone MIME diventino effettive."
true
}

setLangITA

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.8
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
