:
#
# Copyright (c) 1988, 1998 Oracle Corporation.  All rights reserved.
#
# NAME
#   helpins
#
# DESCRIPTION
#   Script to install SQL*Plus HELP system
#
# NOTES
#   If you want to load the English language data file ("helpus.sql"),
#   and the SYSTEM schema's password is "manager" then execute these
#   commands at the operating system prompt:
#
#        ./helpins system manager us
#
#   This assumes you have set your default environment (e.g
#   ORACLE_HOME, ORACLE_SID) to connect to the correct database.
#
#   The first argument should always be SYSTEM
#
#   The third argument to this script specifies the language for the
#   HELP system.  The available language files are in
#   $ORACLE_HOME/admin/help.


#
#  Display abort message on interupt
#
trap 'echo "^G^G help Installation Aborted!"; exit' 1 2 3 15

#
#  Allow verification/trace to be turned on and off.
#  When verification is off, the default case, invoke sqlplus with the
#  -silent option.
case "$ORACLE_TRACE" in
    "T")        set -x ;;
     *)        SILENT="-s" ;;
esac

#
#  If LOG is not set, then send output to /dev/null.
#
case $LOG in
    "") LOG=/dev/null ;;
esac

#
#  Check to make sure that required variables are set.
#  If they are not, prompt user to set them and restart install
#

case $ORACLE_HOME in
    "") echo "ORACLE_HOME not set."
        echo "Set and export ORACLE_HOME, then restart help installation." | tee -a $LOG
        exit 1 ;;
esac


if [ $# -eq 0 ]; then

  case $SYSTEM_PASS in
    "") echo "SYSTEM_PASS environment variable not set."
        echo "Loading HELP to SYSTEM schema"
        PASSWD=""
        while [ -z "$PASSWD" ]
        do
            echo "Enter SYSTEM passwd: "
            read PASSWD
        done
        SYSTEM_PASS="system/$PASSWD";;
  esac

  HELPLANG="us"

elif [ $# -eq 3 ]; then

  SYSTEM_PASS="$1"/"$2";
  export SYSTEM_PASS
  HELPLANG="$3"

else

  echo "Usage: $0 system <system_password> <language>" >&1
  exit 1

fi

#  Default to US if we can't find the specified language file

HELPDIR=$ORACLE_HOME/sqlplus/admin/help
HELPFILE=$HELPDIR/helpbld.sql
HELPDATA=$HELPDIR/help${HELPLANG}.sql

[ ! -f "$HELPDATA" ] &&
    { echo "Help file $HELPDATA not found" | tee -a $LOG;
      HELPDATA=$HELPDIR/helpus.sql;
      echo "Using $HELPDATA" | tee -a $LOG;
 }

[ ! -f "$HELPDATA" ] &&
    { echo "Help file $HELPDATA not found" | tee -a $LOG;
      exit 1 ; }

#
#  Load the HELP system
#

$ORACLE_HOME/bin/sqlplus $SILENT "$SYSTEM_PASS" @"$HELPFILE" "$HELPDATA"

exit $?
