:
#
# Copyright (c) 1988, 2003, Oracle Corporation.  All rights reserved.  
#
# NAME
#   helpins
#
# DESCRIPTION
#   Script to install the SQL*Plus HELP system
#
# USAGE
#   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

#  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."
        exit 1 ;;
esac

if [ $# -eq 0 ]; then

  case $SYSTEM_PASS in
    "") echo "SYSTEM_PASS environment variable not set."
        echo "Installing HELP into the 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"
      HELPDATA=$HELPDIR/helpus.sql;
      echo "Using $HELPDATA"
 }

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

#
#  Load the HELP system
#

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

exit $?
