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

#Used to specify the start directory for finding acroread

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
#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
