#!/bin/sh
#
# Copyright (c) 1996-2005, Adobe Systems Incorporated
# All Rights Reserved
#

#Used to specify the start directory for finding acroread

setLangPTB()
{
ST_LANG="PTB"
ST_LANG_SMALL="ptb"
ST_READER_RPM_NAME="AdobeReader_ptb"
ST_EXCHANGE_RPM_NAME="AdobeAcrobat_ptb"
ST_COMMENT_WORD="Comentrio"
ST_DESCRIPTION_WORD="Descrio"
ST_COMMENT_RPM="Iniciar o Adobe Reader 7.0"
ST_DES_RPM="Com o aplicativo Adobe Reader para Linux,  possvel visualizar, navegar e imprimir documentos PDF."
ST_DES_TAG01="Com o aplicativo Adobe Reader,  possvel ler documentos no formato PDF."
ST_DES_TAG02="Com o Adobe Reader, tambm  possvel pesquisar em arquivos PDF,"
ST_DES_TAG03="pesquisar arquivos PDF na Internet e participar de revises colaborativas de documentos."
ST_DES_TAG04="Para obter detalhes, visite o site www.brasil.adobe.com."
ST_THE_FILE="O arquivo"
ST_FOR="for"
ST_YES="sim"
ST_NO="no"
ST_OR="ou"
ST_SMALL_Y="s"
ST_SMALL_N="n"
ST_CAPS_Y="S"
ST_CAPS_N="N"
ST_ACCEPT_CAPS="ACEITAR"
ST_DECLINE_CAPS="RECUSAR"
ST_ACCEPT="aceitar"
ST_DECLINE="recusar"
ST_VERSION="verso"
ST_STATEMENT_ACCEPT_DECLINE="Digite \\\"aceitar\\\" para aceitar os termos e condies do contrato de licena; Digite \\\"recusar\\\" para sair. "
ST_RESTATEMENT_ACCEPT_DECLINE="Resposta invlida. A resposta esperada era \\\"aceitar\\\" ou \\\"recusar\\\" ... tentar novamente ?"
ST_ER_INVALID_RESP1="ERRO: Resposta invlida. A resposta esperada era"
ST_ER_INVALID_RESP2="ERRO: Resposta invlida ... tente novamente"
ST_ER_INVALID_RESP3=".. tentar novamente?"
ST_ER_NO_LIC_FILE="ERROR: No foi possvel localizar o arquivo de licena ... interrompendo"
ST_TO_ACCEPT="Para aceitar os termos e as condies deste contrato, digite"
ST_TO_DECLINE="Para recusar os termos e as condies deste contrato, digite"
ST_REQ0101="Digite"
ST_REQ0102="para aceitar os termos e as condies do contrato de licena;"
ST_REQ0103="Digite"
ST_REQ0104="para sair."
ST_ER_LIC_NOT_ACCP="O Contrato de licena no foi aceito ... Interrompendo a instalao"
ST_FREE_SPACE_INFO01="Esta instalao requer"
ST_FREE_SPACE_INFO02="MB de espao livre em disco."
ST_DONE_WORD="Concludo"
ST_ER_INSTALLING01="ERRO ao instalar"
ST_ER_INSTALLING02="nome de produto invlido"
ST_RES_INST_DIR="Digite o diretrio de instalao do Adobe Reader"
ST_ER_SAME_FILE_NAME_AS_DIR="existe, mas no  um diretrio. Especifique um local diferente."
ST_DIR_INFO01="O diretrio"
ST_DIR_INFO02="no existe."
ST_QUES_CREAT_DIR="Deseja cri-lo agora? [s]"
ST_ER_EXIT="Saindo da instalao..."
ST_ER_DIR="ERRO: No foi possvel criar o diretrio"
ST_ER_WRITE="ERRO: No foi possvel gravar no diretrio"
ST_ER_NO_LIBCURL01="No foi possvel localizar libcurl.so. Parte da funcionalidade do Adobe Reader pode no estar disponvel."
ST_ER_NO_LIBCURL02="Convm instalar curl verso"
ST_ER_NO_LIBCURL03="ou qualquer verso posterior a"
ST_WARN_NO_LIBSSL01="AVISO: A verso libssl.so no seu computador no  compatvel com libssl.so.0.9.6."
ST_WARN_NO_LIBSSL02="Instale libssl.so.0.9.6."
ST_WARN_LD_LIB01="existe no diretrio"
ST_WARN_LD_LIB02=", mas esse diretrio no est includo em LD_LIBRARY_PATH."
ST_WARN_LD_LIB03="Inclua o diretrio"
ST_WARN_LD_LIB04="em LD_LIBRARY_PATH"
ST_WARN_LD_LIB05="existe no diretrio"
ST_ER_NO_CONFIG="ERRO: Nenhuma configurao foi encontrada ... interrompendo"
ST_WARN_NO_CONFIG="AVISO: A configurao escolhida no pode ser executada na plataforma atual"
ST_QUE_CONT="Continuar a instalao?"
ST_INFO_DEF_CONFIG1="Instalar configurao padro"
ST_INFO_DEF_CONFIG2="As configuraes a seguir esto disponveis para instalao:"
ST_QUE_CONFIG="Digite o nmero da configurao a ser instalada:"
ST_EXIT_INFO="Sair da instalao do Acrobat"
ST_PLAT_INDEP_FILES="Instalando arquivos independentes da plataforma ..."
ST_PLAT_DEP_FILES="Instalando arquivos dependentes da plataforma ..."
ST_RPM_CAN_NOT_DEL="no puderam ser excludos, pois existem alguns arquivos extras que no foram instalados por rpm"
ST_WEL_ALK="Bem-vindo  instalao do Kit para idiomas asiticos."
ST_INFO_ALK01="Esta instalao no funcionar se o"
ST_INFO_ALK02="Unix Adobe Reader verso 7.0 no for instalado antes."
ST_INFO_ALK03="Se o Adobe Reader verso 7.0 ainda no estiver instalado no"
ST_INFO_ALK04="sistema, execute essa instalao antes de instalar o Kit para idiomas asiticos."
ST_ER_ALK01="ERRO: O diretrio deve ser um caminho absoluto"
ST_ER_ALK02="ERRO: O diretrio"
ST_ER_ALK03="no existe."
ST_ER_ALK04="ERRO: O arquivo AcroVersion no existe."
ST_ER_ALK05="ERRO: Verso incorreta do Acrobat:"
ST_ER_ALK06="ERRO: No foi possvel localizar a distribuio ... interrompendo"
ST_IF_ALK07="Digite o local em que o Adobe Reader foi instalado"
ST_INFO_ALK_CMPLT="Instalao concluda."
ST_WEL_HLK="Bem-vindo  instalao do Pacote Suplementar para Idiomas."
ST_INFO_HLK04="sistema, execute essa instalao antes de instalar o Pacote Suplementar para Idiomas."
ST_INFO_HLK05="Instalando Arquivos do Pacote Suplementar para Idiomas... "
ST_WEL_CLK="Bem-vindo  instalao do Pacote de Fontes para a Europa Central."
ST_INFO_CLK04="sistema, execute essa instalao antes de instalar o Pacote de Fontes para a Europa Central."
ST_INFO_CLK05="Instalando Arquivos do Pacote de Fontes para a Europa Central... "
ST_ER_AR01="ERRO: No foi possvel determinar o diretrio atual."
ST_ER_AR02="ERRO: No foi possvel localizar o diretrio de instalao."
ST_ER_AR03="ERRO: No foi possvel localizar"
ST_INFO_AR01="O SO nomeado"
ST_INFO_AR02="no est instalado no momento."
ST_INFO_AR03="Tente executar em uma plataforma instalada e conectar ao monitor."
ST_INFO_AR04="A(s) plataforma(s) instalada(s) inclui(em):"
ST_INFO_AR05="no instalada para esta configurao,"
ST_IBP_MISC_03="Mozilla"
ST_IBP_MISC_04="Firefox"
ST_IBP_MISC_05="Netscape"
ST_IBP_MISC_06="Sair"
ST_IBP_INFO_01="Isso instalar o plug-in do navegador para o acroread."
ST_IBP_INFO_02="Executar instalao global"
ST_IBP_INFO_03="Executar instalao especfica ao usurio"
ST_IBP_INFO_04="Insira sua escolha"
ST_IBP_INFO_05="Deseja instalar outro navegador?"
ST_IBP_INFO_06="Digite o diretrio de instalao do Adobe Reader 7.0"
ST_IBP_INFO_07="Digite o diretrio de instalao do navegador"
ST_IBP_INFO_08="Parece que o plug-in j est instalado. Tem certeza de que deseja substitu-lo ?"
ST_IBP_INFO_09="Instalao cancelada."
ST_IBP_INFO_10="Instalao satisfatria."
ST_IBP_INFO_11="Isso ativar o plug-in para Mozilla, Firefox e Netscape."
ST_IBP_INFO_12="Se tiver problemas para fazer com que a instalao funcione no seu navegador, copie o seguinte arquivo para a pasta de plug-ins do navegador:"
ST_IBP_INFO_13="Caminho do Acroread especificado"
ST_IBP_INFO_14="Pressione <Enter> para continuar"
ST_IBP_INFO_15="Se tiver dificuldades, consulte a documentao fornecida com o navegador para a adio de novos plug-ins."
ST_IBP_INFO_16="Instalando o plug-in em"
ST_IBP_INFO_17="Deseja executar a instalao automtica?"
ST_IBP_INFO_18="Instalao automtica finalizada."
ST_IBP_INFO_19="Deseja executar a instalao manual?"
ST_IBP_INFO_20="Deseja instalar o plug-in do navegador?"
ST_IBP_INFO_21="A instalao do plug-in do navegador foi ignorada."
ST_IBP_INFO_22_1="Executar"
ST_IBP_INFO_22_2="para instalar o plug-in do navegador."
ST_IBP_INFO_23="foi adicionado."
ST_IBP_INFO_24="Tentando instalar o plug-in para o navegador"
ST_IBP_INFO_25="Falha na instalao"
ST_IBP_ERR_01="No foi possvel localizar o arquivo de plug-in do navegador"
ST_IBP_ERR_02="No foi possvel localizar a pasta de plug-ins do navegador"
ST_IBP_ERR_03="No foi possvel localizar a pasta do navegador"
ST_IBP_ERR_04="No foi possvel remover a verso anterior do plug-in em"
ST_IBP_ERR_05_1="No foi possvel copiar o arquivo de plug-in"
ST_IBP_ERR_05_2="para"
ST_IBP_ERR_06="No foi possvel criar o diretrio"
ST_IBP_ERR_07="No foi possvel localizar o script de instalao do plug-in do navegador."
ST_IBP_ERR_08="j existe como arquivo especial e no pde ser substitudo."
ST_IBP_ERR_09="No foi possvel consultar a varivel HOME do ambiente. No foi possvel localizar seu diretrio home."
ST_IBP_ERR_10="No foi possvel localizar a pasta de instalao"
ST_IBP_ERR_11="ERRO INTERNO... Nenhum nome de SO correspondente."
ST_SEP_INFO_01="Digite o diretrio de instalao do Adobe Reader 7.0"
ST_SEP_INFO_02="ERRO INTERNO..... Nenhum nome OS correspondente."
ST_SEP_INFO_03="No foi possvel localizar os arquivos apropriados no caminho de instalao."
ST_SEP_INFO_04="Redefinindo contextos antigos"
ST_SEP_INFO_05="Configurando novos contextos para arquivos da biblioteca"
ST_SEP_INFO_06="Ser feita uma tentativa de atualizar os arquivos da biblioteca para torn-los compatveis a SELinux."
ST_SEP_INFO_07="No foi possvel localizar a pasta de instalao."
ST_SEP_INFO_08="Configurao dos contextos finalizada.  possvel verificar o log em "
ST_SEP_INFO_09="Falha no comando"
ST_SEP_INFO_10="A correo pode no ter sido concluda corretamente.  possvel verificar o log em"
ST_IOP_ERR1="O OpenOffice PDF Plugin no pde ser registrado. Leia as instrues em  "
ST_IOP_ERR2="para instalao manual."
ST_IOP_ERR3="O OpenOffice >= 1.9  necessrio para que o OpenOffice PDF Plugin seja executado adequadamente. Ignorando registro do PDF Plugin."
ST_IOP_ERR4="O arquivo soffice binrio do OpenOffice no pde ser localizado no diretrio especificado."
ST_IOP_INFO_01="Especifique o diretrio onde o OpenOffice est instalado:"
ST_IOP_INFO_02="Deseja instalar o OpenOffice Plugin ?"
ST_IAP_ERR1="O Adobe PDF Plug-in no pde ser registrado. Siga as instrues em "
ST_IAP_INFO_01="Deseja instalar o Adobe PDF Plugin ?"
ST_IFE_INFO_01="Deseja instalar a extenso firefox ?"
ST_IFE_INFO_02="Especifique o caminho para o executvel Firefox : "
ST_IFE_ERR_01="Firefox exe no foi encontrado ou no tem permisses de execuo."
ST_IDI_INFO_01="Deseja instalar o Distiller ?"
ST_MIME_INFO_01="Efetue o login novamente para que as alteraes nos cones e nos tipos MIME sejam efetivadas."
true
}

setLangPTB
#Used to specify the start directory for finding acroread
SCRIPT_PATH=

#Contains the install directory path for acroread
ACROREAD_DIR=

#Contains the complete path of the browser plugin
NPPDF_FILE=

#Maintains whether we need to continue with the installation and repeat it for more browsers
INSTALL_MORE="y"


#This function gets the complete path of this script.
GetScriptPath()
{
	CURRENT_PATH=`pwd`
	SCRIPT_PATH=`dirname "$0"`
	COMPLETE_PATH="${SCRIPT_PATH}/../"
	cd "$COMPLETE_PATH"
	SCRIPT_PATH=`pwd`
	cd "$CURRENT_PATH"
}


#This function installs the plugin for a specific installation of the browser.
#If the installation is successful, then whenever the browser (specified in the browser install path) is run, for any user, it will have the plugin enabled.
#The way to achieve this is to look for the 'plugins' folder in the browser install path (specified by the user), and copy our plugin file to this location.
#If the plugin already exists, we prompt the user whether to overwrite or not, and proceed accordingly.
#This mechanism has been tested for Mozilla and Firefox. In both these browsers, the app searches for extensions/plugins in the 'plugins' folder.
InstallBrowserGlobal()
{
    if [ -z "$NPPDF_FILE" ]
	then
	return 1
    fi

    #Fetch the browser location
    if [ $# -eq 0 ]
	then
	BROWSER_DIR=""
	while [ -z "$BROWSER_DIR" ]
	  do
	  printf "$ST_IBP_INFO_07 - \n"
	  read BROWSER_DIR
	done
    else
	BROWSER_DIR=$1
    fi
	
    #Check existence of browser folder
    if [ ! -d "$BROWSER_DIR" ]
	then
	echo "$ST_IBP_ERR_03 ${BROWSER_DIR}"
	return 1
    fi

    #Check existence of 'plugin' folder in the browser folder
    BROWSER_PLUGIN_DIR="${BROWSER_DIR}/plugins"
    if [ ! -d "$BROWSER_PLUGIN_DIR" ]
	then
	echo "$ST_IBP_ERR_02 ${BROWSER_PLUGIN_DIR}"
	return 1
    fi

    #Check whether plugin already exists
    if [ "$OSNAME" = "HP-UX" ]
        then
	BROWSER_PLUGIN_FILE="${BROWSER_PLUGIN_DIR}/nppdf.sl"
    else
	BROWSER_PLUGIN_FILE="${BROWSER_PLUGIN_DIR}/nppdf.so"
    fi

    if [ -f "$BROWSER_PLUGIN_FILE" ] || [ -h "$BROWSER_PLUGIN_FILE" ]
	then
	while :
	  do
	  printf "$ST_IBP_INFO_08 [$ST_SMALL_Y/$ST_SMALL_N] \n"
	  read USER_CHOICE
	  
	  if [ "$USER_CHOICE" = "$ST_SMALL_Y" ] || [ "$USER_CHOICE" = "$ST_CAPS_Y" ] || [ -z "$USER_CHOICE" ]
	      then
	      rm -f "$BROWSER_PLUGIN_FILE"
	      if [ $? -ne 0 ]
		  then
		  echo "$ST_IBP_ERR_04 ${BROWSER_PLUGIN_DIR}"
		  return 1
	      fi
	      break
	  elif [ "$USER_CHOICE" = "$ST_SMALL_N" ] || [ "$USER_CHOICE" = "$ST_CAPS_N" ]
	      then
	      echo "$ST_IBP_INFO_09"
	      return 0
	      break
	  fi
	done
    elif [ -b "$BROWSER_PLUGIN_FILE" ] || [ -c "$BROWSER_PLUGIN_FILE" ] || [ -d "$BROWSER_PLUGIN_FILE" ]
	then
	echo "$BROWSER_PLUGIN_FILE $ST_IBP_ERR_08"
	return 1
    fi
    
    #Copy the browser plugin file to the correct location
    cp "$NPPDF_FILE" "$BROWSER_PLUGIN_FILE"
    if [ $? -ne 0 ]
	then
	echo "$ST_IBP_ERR_05_1 ${NPPDF_FILE} $ST_IBP_ERR_05_2 ${BROWSER_PLUGIN_FILE}"
	return 1
    else
	echo "$ST_IBP_INFO_10 ${BROWSER_PLUGIN_FILE}"
	return 0
    fi
}


#This function installs the plugin for the current user only.
#If the installation is successful, then whenever Mozilla or Firefox is run, from anywhere, it will have the plugin enabled.
#The way to achieve this is to copy our plugin file in the .mozilla/plugins folder in the users' home directory.
#If the folder does not exist, we create it, and if the plugin already exists, we prompt the user whether to overwrite or not, and proceed accordingly.
#This mechanism has been tested for Mozilla and Firefox. In both these browsers, the app searches for extensions/plugins in ~/.mozilla/plugins folder.
InstallBrowserUser()
{
    if [ -z "$NPPDF_FILE" ]
	then
	return 1
    fi
    
    if [ -d "$HOME" ]
	then
	USER_DIR="$HOME"
    else
	echo "$ST_IBP_ERR_09"
	return 1
    fi

    #Create the .mozilla & plugins folders if required
    BROWSER_DIR="$USER_DIR/.mozilla"
    if [ ! -d "$BROWSER_DIR" ]
	then
	mkdir "$BROWSER_DIR"
	if [ $? -ne 0 ]
	    then
	    echo "$ST_IBP_ERR_06 ${BROWSER_DIR}"
	    return 1
	fi
    fi
    
    BROWSER_PLUGIN_DIR="${BROWSER_DIR}/plugins"
    if [ ! -d "$BROWSER_PLUGIN_DIR" ]
	then
	mkdir "$BROWSER_PLUGIN_DIR"
	if [ $? -ne 0 ]
	    then
	    echo "$ST_IBP_ERR_06 ${BROWSER_PLUGIN_DIR}"
	    return 1
	fi
    fi
    
    #Check whether the plugin already exists
    if [ "$OSNAME" = "HP-UX" ]
        then
	BROWSER_PLUGIN_FILE="${BROWSER_PLUGIN_DIR}/nppdf.sl"
    else
	BROWSER_PLUGIN_FILE="${BROWSER_PLUGIN_DIR}/nppdf.so"
    fi

    if [ -f "$BROWSER_PLUGIN_FILE" ] || [ -h "$BROWSER_PLUGIN_FILE" ]
	then
	while :
	  do
	  printf "$ST_IBP_INFO_08 [$ST_SMALL_Y/$ST_SMALL_N] \n"
	  read USER_CHOICE
	  
	  if [ "$USER_CHOICE" = "$ST_SMALL_Y" ] || [ "$USER_CHOICE" = "$ST_CAPS_Y" ] || [ -z "$USER_CHOICE" ]
	      then
	      rm -f "$BROWSER_PLUGIN_FILE"
	      if [ $? -ne 0 ]
		  then
		  echo "$ST_IBP_ERR_04 ${BROWSER_PLUGIN_DIR}"
		  return 1
	      fi
	      break
	  elif [ "$USER_CHOICE" = "$ST_SMALL_N" ] || [ "$USER_CHOICE" = "$ST_CAPS_N" ]
	      then
	      echo "$ST_IBP_INFO_09"
	      return 0
	      break
	  fi
	done
    elif [ -b "$BROWSER_PLUGIN_FILE" ] || [ -c "$BROWSER_PLUGIN_FILE" ] || [ -d "$BROWSER_PLUGIN_FILE" ]
	then
	echo "$BROWSER_PLUGIN_FILE $ST_IBP_ERR_08"
	return 1
    fi
    
    #Copy the browser plugin file to the correct location
    cp "$NPPDF_FILE" "$BROWSER_PLUGIN_FILE"
    if [ $? -ne 0 ]
	then
	echo "$ST_IBP_ERR_05_1 ${NPPDF_FILE} $ST_IBP_ERR_05_2 ${BROWSER_PLUGIN_FILE}"
	return 1
    fi
    
    echo "$ST_IBP_INFO_10"
    echo "${BROWSER_PLUGIN_FILE} $ST_IBP_INFO_23"
    echo "$ST_IBP_INFO_11"
}


#
# Check a given file in given path
# 1 imples file exists and 0 implies file does not exist
#
check_file_in_named_path()
{
    if [ -x "$2/$1" ]
	then
 	return 1
    fi
    
    return 0
}


#
# Check a given file in $PATH
# 1 imples file exists and 0 implies file does not exist
#
check_file_in_path()
{
    OLD_IFS=$IFS
    IFS=":"
    FOUND_PATH=""

    if [ -n "$PATH" ]
	then
 	for i in $PATH
	  do
	  if [ -d "$i" ]
	      then
	      check_file_in_named_path "$1" "$i"
	      if [ $? -eq 1 ]
		  then
		  FOUND_PATH="${i}/$1"
		  IFS=$OLD_IFS
		  return 1
	      fi
	  fi
 	done
    fi
    
    IFS=$OLD_IFS
    return 0
}


GetAbsoluteFile()
{
    if [ -h "$1" ]
	then
	CURRENT_PATH=`pwd`
	cd `dirname $1`
	COMPLETE_PATH=`ls -l $1 | awk '{ print $NF }'`
	COMPLETE_PATH_DIR=`dirname $COMPLETE_PATH`
	COMPLETE_PATH_FILE=`basename $COMPLETE_PATH`
	cd $COMPLETE_PATH_DIR
	COMPLETE_PATH_DIR=`pwd`
	cd "$CURRENT_PATH"
	GetAbsoluteFile ${COMPLETE_PATH_DIR}/${COMPLETE_PATH_FILE}
    else
	echo "$1"
	return 0
    fi
}


AutoInstallBrowser()
{
    echo "$ST_IBP_INFO_24 - $1"
    check_file_in_path $1
    if [ $? -eq 1 ]
	then
	FOUND_PATH=`GetAbsoluteFile $FOUND_PATH`
	echo "$ST_IBP_INFO_16 $FOUND_PATH"
	InstallBrowserGlobal `dirname $FOUND_PATH`
	if [ $? -eq 0 ]
	    then
	    return 0
	else
	    echo "$ST_IBP_INFO_25"
	    return 1
	fi
    else
	echo "$ST_IBP_INFO_25"
	return 1
    fi
}


AutoInstall()
{
    AUTO_INSTALL_SUCCESS=0

    while :
      do
      printf "$ST_IBP_INFO_17 [$ST_SMALL_Y/$ST_SMALL_N] \n"
      read USER_CHOICE
      
      if [ "$USER_CHOICE" = "$ST_SMALL_Y" ] || [ "$USER_CHOICE" = "$ST_CAPS_Y" ] || [ -z "$USER_CHOICE" ]
	  then
	  break
      elif [ "$USER_CHOICE" = "$ST_SMALL_N" ] || [ "$USER_CHOICE" = "$ST_CAPS_N" ]
	  then
	  return 0
	  break
      fi
    done
    
    echo ""
    echo ""
    AutoInstallBrowser "firefox"
    if [ $? -eq 0 ]
	then
	AUTO_INSTALL_SUCCESS=1
    fi

    echo ""
    echo ""
    AutoInstallBrowser "mozilla"
    if [ $? -eq 0 ]
	then
	AUTO_INSTALL_SUCCESS=1
    fi

    echo ""
    echo ""
    if [ $AUTO_INSTALL_SUCCESS -eq 1 ]
	then
	echo "$ST_IBP_INFO_18"
	return 0
    else
	return 0
    fi
}


#This function fetches the installation path if not specified and validates the existance of the plugin file.
GetAcroreadInfo()
{
    #Prompt the user for acroread's installation path if not specified on the command prompt
    if [ -z "$1" ]
	then
	GetScriptPath
	printf "$ST_IBP_INFO_06 [${SCRIPT_PATH}] \n"
	read ACROREAD_DIR
	if [ -z "$ACROREAD_DIR" ]
	    then
	    ACROREAD_DIR="$SCRIPT_PATH"
	fi
    else
	ACROREAD_DIR="$1"
    fi

    OSNAME=`uname -s`
    if [ "$OSNAME" = "Linux" ]
	then
	CONFIG_FOLDER="intellinux"
    elif [ "$OSNAME" = "SunOS" ]
	then
	CONFIG_FOLDER="sparcsolaris"
    elif [ "$OSNAME" = "AIX" ]
        then
	CONFIG_FOLDER="rs6000aix"
    elif [ "$OSNAME" = "HP-UX" ]
        then
	CONFIG_FOLDER="hppahpux"
    else
	echo "$ST_IBP_ERR_11"
	return 1
    fi

    #Check for the plugin file
    if [ "$OSNAME" = "HP-UX" ]
        then
	NPPDF_FILE="${ACROREAD_DIR}/Browser/${CONFIG_FOLDER}/nppdf.sl"
    else
	NPPDF_FILE="${ACROREAD_DIR}/Browser/${CONFIG_FOLDER}/nppdf.so"
    fi

    if [ ! -f "$NPPDF_FILE" ]
	then
	echo "$ST_IBP_ERR_01 ${NPPDF_FILE}"
	return 1
    fi
}


Init()
{
    clear
    echo "$ST_IBP_INFO_01"
    echo ""
    GetAcroreadInfo "$1"
    if [ $? -ne 0 ]
	then
	return 1
    fi

    if [ ! -d "$ACROREAD_DIR" ]
	then
	echo "$ST_IBP_ERR_10 - $ACROREAD_DIR"
	return 1
    fi

    AutoInstall
    if [ $? -eq 1 ]
	then
	return 0
    fi

    while :
      do
      printf "$ST_IBP_INFO_19 [$ST_SMALL_Y/$ST_SMALL_N] \n"
      read USER_CHOICE
      
      if [ "$USER_CHOICE" = "$ST_SMALL_Y" ] || [ "$USER_CHOICE" = "$ST_CAPS_Y" ] || [ -z "$USER_CHOICE" ]
	  then
	  break
      elif [ "$USER_CHOICE" = "$ST_SMALL_N" ] || [ "$USER_CHOICE" = "$ST_CAPS_N" ]
	  then
	  return 0
	  break
      fi
    done

    while :
      do
      clear
      echo "$ST_IBP_INFO_13 - $ACROREAD_DIR"
      echo ""
      echo "1. $ST_IBP_INFO_02"
      echo "2. $ST_IBP_INFO_03 ($ST_IBP_MISC_03/$ST_IBP_MISC_04/$ST_IBP_MISC_05)"
      echo "3. $ST_IBP_MISC_06"
      printf "$ST_IBP_INFO_04 [1/2/3] \n"
      read INSTALL_CHOICE
    
      if [ -n "$INSTALL_CHOICE" ]
	  then
	  if [ $INSTALL_CHOICE -eq 1 ]
	      then
	      echo ""
	      echo ""
	      InstallBrowserGlobal
	      printf "$ST_IBP_INFO_14 ... \n"
	      read DUMMY
	  elif [ $INSTALL_CHOICE -eq 2 ]
	      then
	      echo ""
	      echo ""
	      InstallBrowserUser
	      printf "$ST_IBP_INFO_14 ... \n"
	      read DUMMY
	  elif [ $INSTALL_CHOICE -eq 3 ]
	      then
	      return 0
	  fi
      fi
    done

    return 0
}

EndingMessage()
{
    echo ""
    echo ""
    echo "$ST_IBP_INFO_12"
    echo "${NPPDF_FILE}"
    echo ""
    echo "$ST_IBP_INFO_15"
}

trap 'EndingMessage; exit 0' 2
Init "$1"
EndingMessage
