:
# Copyright (c) 1988, 2003, Oracle Corporation.  All rights reserved.  
#
# NAME
#   pupbld
#
# DESCRIPTION
#   Script to install the SQL*Plus PRODUCT_USER_PROFILE tables.  These
#   tables allow SQL*Plus to disable commands per user.  The tables
#   are used only by SQL*Plus and do not affect other client tools
#   that access the database.  Refer to the SQL*Plus manual for table
#   usage information.
#
#   This script should be run on every database that SQL*Plus connects
#   to, even if the tables are not used to restrict commands.
#
# USAGE
#   pupbld
#

# Script to load
PUPBLD=$ORACLE_HOME/sqlplus/admin/pupbld

# Display abort message on interupt.
trap 'echo "^G^G Product user profile 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 profile installation."
      exit 1 ;;
esac

if [ $# -eq 0 ]; then

  case $SYSTEM_PASS in
    "") echo "SYSTEM_PASS environment variable not set."
        echo "Installing Product User Profile 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 2 ]; then

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

else

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

fi

echo ""
echo "Installing product user profile tables..."
echo ""
$ORACLE_HOME/bin/sqlplus "$SYSTEM_PASS" <<!
        START $PUPBLD
        EXIT
!
echo "Product user profile table installation finished."
echo ""

exit 0
