#!/bin/csh -f
set fullscrname="$0"
set scrname="$fullscrname:t"
set scrdir="$fullscrname:h"

if ($scrname == $scrdir) then
    set scrdir = `pwd`
endif

########################################################################
#                                                                      #
# PTC installation/configuration script                                #
#                                                                      #
# Title - cfg_pdmora                                                   #
#                                                                      #
# Function - Configure an ORACLE datebase to run with Pro/PDM          #
#                                                                      #
# Inputs - DF_CMD                                                      #
#          DF_CMD                                                      #
#          DF_FCOL                                                     #
#          PS_CMD                                                      #
#          PRO_LOAD_DIR                                                #
#                                                                      #
# Modifications                                                        #
#                                                                      #
# 03-15-94  $$1  James Created                                         #
# 03-21-94  $$2  James Set ORACLE_{HOME,SID}                           #
# 03-29-94  $$3  James Fixed RE
# 04-10-94  $$4  James non-dba pdmserver changes.
# 05-01-94  $$5  James Ask for initial tb size.
# 07-19-94  $$6  James ORAPWDCHK
# 09-28-94  $$7  sfc   Identify Oracle version number
# 09-30-94  $$8  sfc   Added ORAPWDCHK for Oracle V7
# 10-06-94  $$9  James Fixed syntax error and commented echo of ORAPWDCHK
# 10-14-94  $$10 sfc   Fixed syntax error
# 10-21-94  $$11 James/RB    Ask if installer has auto log priv.
# 11-03-94  $$12 James Standalone mode.
# 01-04-95  $$13 sfc   Allowed users to define tablespace file location#
# 01-13-95  $$14 James Look for ../../pdm/pdmtools/sql directory.
# 04-05-95  $$14 sfc   Oracle user's password will not display on the screen
# 04-19-95  $$15 sfc   Added default password option, removed unnecessary msg.
# 01-18-96  $$16 sfc   Changed some misleading messages. 
#                      Find sql scripts in the $PRO_LOAD_DIR/pdm/pdmtools/sql.
########################################################################

if ( ! ($?PRO_LOAD_DIR && $?DF_CMD && $?DF_FCOL && $?PS_CMD && $?PDMUSER && $?CNFG_STATFILE && $?ORAPWDCHK && $?ORAUSER)) then
   echo ""
   echo "Pro/PDM script to configure an ORACLE database."
   echo "-----------------------------------------------"
   echo ""
endif


########################################################################

if (! $?PRO_LOAD_DIR) then
   setenv PRO_LOAD_DIR "__unset__"
endif

if (! $?DF_CMD) then
   setenv DF_CMD "__unset__"
endif

if (! $?DF_FCOL) then
   setenv DF_FCOL "__unset__"
endif

if (! $?PS_CMD) then
   setenv PS_CMD "__unset__"
endif

if (! $?PDMUSER) then
   unset valid_ans
   while (! $?valid_ans)
      echo ""
      echo "What is the UNIX username of the Pro/PDM Server owner."
      echo -n "?: "
      set ans="$<"
      if ("$ans" == "") continue
      set valid_ans
   end
   setenv PDMUSER "$ans"
endif

if (! $?CNFG_STATFILE) then
   setenv CNFG_STATFILE "/dev/null"
endif

if (! $?ORAPWDCHK) then
   unset valid_ans
   while (! $?valid_ans)
      echo ""
      echo "DO you want the Pro/PDM server process owner '$PDMUSER'"
      echo "to use an automatic login account to connect Oracle?"
      echo "(i.e. should user '$PDMUSER' be able to login to Oracle"
      echo "without a password)" 
      echo -n "(y/n) ?: "
      set ans="$<"
      if ("$ans" == "") continue
      if ("$ans" =~ [Yy]* || "$ans" =~ [Nn]* ) set valid_ans
   end
   if ("$ans" =~ [Yy]*) then
      setenv ORAPWDCHK 0
   else
      setenv ORAPWDCHK 1
   endif
endif


if (! $?ORAUSER) then
   setenv ORAUSER "__unset__"
endif

########################################################################

echo "started" > $CNFG_STATFILE

if ("$ORAPWDCHK" != "0") setenv ORAPWDCHK 1
#echo $ORAPWDCHK

unset info_only
if ("$1" != "") then
   if ("$1" != "info") then
      echo "Usage:  $scrname [info]"
      goto EXIT_ERROR
   endif
   set info_only
endif

# local inits
set gen_tmpfile="/tmp/$scrname.$$"

# Ask for ORACLE info
# 1. is effectively: grant DBA to OPS$user identified by userpassword

if ($?info_only) then
   while(1)
      echo ""
      echo "Prerequsite ORACLE preparations are as follows:"
      echo ""
      echo "1 - Do you know:"
      echo ""
      echo "EITHER:"
      echo "    A UNIX username/password which has automatic login"
      echo "    privilege and database administrator (DBA) access to Oracle."
      echo "    ex:  oracle/<password>"
      echo ""
      echo "OR:"
      echo "    A UNIX username/password which has write-access to ORACLE_HOME"
      echo "    AND any ORACLE DBA oracle_username/oracle_password."
      echo ""
      echo "2 - Do you know the ORACLE_HOME directory, ORACLE_SID and db initialization"
      echo "    filename."
      echo "    ex:  /usr/oracle, oracle  and /usr/oracle/dbs/initoracle.ora"
      echo ""
      echo "3 - Do you know initially how large the index and data tablespace files"
      echo "    should be created (the default is 10 Mb)."
      echo ""
if ($ORAPWDCHK) then
      echo "4 - Have you granted all the necessary privileges to user '$PDMUSER'."
      echo ""
endif
      echo -n "Have the above preparations been made (y/n) ?: "
      set ans="$<"
      if ("$ans" =~ [Nn]* || "$ans" =~ [Yy]*) break
   end
   if ("$ans" =~ [Nn]*) then
      goto EXIT_ERROR
   else
      goto EXIT_SUCCESS
   endif
endif


if ("$ORAUSER" == "__unset__") then
   set ask_prompt="Do you have automatic login privilege."
else
   set ask_prompt="Does $ORAUSER have automatic login privilege."
endif
echo ""
unset valid_ans
while (! $?valid_ans)
   echo ""
   echo "$ask_prompt"
   echo -n "(y/n) ? "
   set ans="$<"
   if ("$ans" =~ [Yy]* || "$ans" =~ [Nn]* ) set valid_ans
end

set oracle_username=""  
set oracle_passwd=""  
if ("$ans" =~ [Nn]*) then 
   echo ""
   while ("$oracle_username" == "") 
      echo -n "Enter the ORACLE username ?: "
      set oracle_username="$<" 
   end
   while ("$oracle_passwd" == "") 
      echo -n "Enter ${oracle_username}'s password ?: "
      stty -echo              # turn echo off
      set oracle_passwd="$<" 
      stty echo               # turn echo on
   end
   echo ""
endif
set conline="connect $oracle_username/$oracle_passwd;"


# Check the environment variables : ORACLE_HOME 

if ($?ORACLE_HOME) then
   set def="$ORACLE_HOME"
else
   set def=`echo ~oracle`
   if ("$def" != "") then
      if (! -d "$def") set def=""
   endif
endif

set orahome=""
echo ""
while ("$orahome" == "") 
   echo "Enter the Oracle Home directory (ORACLE_HOME)"
   echo -n "[$def] ?: "
   set orahome="$<"
   if ("$orahome" == "") set orahome="$def"
   if (! -d "$orahome") then
      echo "ERROR:  $orahome - no such directory."
      echo ""
      set orahome=""
   endif
end


# Check the environment variables :  ORACLE_SID

if ($?ORACLE_SID) then
   set def="$ORACLE_SID"
else if (-e $orahome/.cshrc) then
   set def=`grep ORACLE_SID $orahome/.cshrc | awk '{print $3}'`
else
   set def=""
endif

echo ""
set orasid=""
while ("$orasid" == "") 
   echo "Enter the Oracle system identifier (ORACLE_SID)"
   echo -n "[$def] ?: "
   set orasid="$<"
   if ("$orasid" == "") set orasid="$def"
end


# Check the initialization file 

if (-e $orahome/dbs/init$orasid.ora) then
   set def="$orahome/dbs/init$orasid.ora"
else
   set def=""
endif

echo ""
set orainitfile=""
while ("$orainitfile" == "") 
   echo "Enter the Oracle Database Initialization filename"
   echo -n "[$def] ?: "
   set orainitfile="$<"
   if ("$orainitfile" == "") set orainitfile="$def"
   if (-e "$orainitfile") then
      set dbfile_sid=`grep db_name $orainitfile | awk -F\= '{print $2}'`
      if ("$dbfile_sid" != "" && "$dbfile_sid" != "$orasid") then
         echo ""
         echo "WARNING:  db_name entry in $orainitfile ($dbfile_sid)"
         echo "          is different than your ORACLE_SID ($orasid)"
         echo ""
      endif
   else
      echo "ERROR:  $orainitfile - no such file."
      echo ""
      set orainitfile=""
   endif
end


# allowed users to define the tablespace files location 

echo ""
set oracle_tbsp = ""
set def="$ORACLE_HOME/PTC_PDM"
echo "Please enter the full path of the tablespace files directory : "
echo -n "[$def] ?: "
set oracle_tbsp = "$<"
if ("$oracle_tbsp" == "") set oracle_tbsp = $def

# check PTC_PDM dir(default tablespace files directory) exists / try to create it.
if ("$oracle_tbsp" == "$def") then
 if (! -d $oracle_tbsp) then
    mkdir $oracle_tbsp >& /dev/null
    if ($status != 0) then
       echo " "
       echo "ERROR:  $oracle_tbsp - no such directory."
       echo "        As the owner of $orahome type:"
       echo "        mkdir $oracle_tbsp"
       echo "        then retry."
       goto EXIT_ERROR
    endif
 endif
endif


# Check the tablespace files directory exists/try to create it. 
if (! -d $oracle_tbsp) then
   unset valid_ans
   while (! $?valid_ans)
      echo ""
      echo "Warning : The directory $oracle_tbsp does not exist."
      echo "          Would you like to create the tablespace files directory:"
      echo -n "          $oracle_tbsp  (y/n)? "
      set ans="$<"
      if ("$ans" =~ [Yy]* || "$ans" =~ [Nn]* ) set valid_ans
   end

   if ("$ans" =~ [Nn]*) then
      echo ""
      echo "ERROR : You have to define the full path of tablespace files directory."
      echo ""
      goto EXIT_ERROR
   endif

   if ("$ans" =~ [Yy]*) then
       mkdir $oracle_tbsp >& /dev/null
       if ($status != 0) then
           echo ""
           echo "ERROR:  Cannot create $oracle_tbsp "
           echo "        Please check the read/write priviledges,"
           echo "        then retry."
           goto EXIT_ERROR
       endif
   endif
endif

if (! $?ORACLE_TBSP) then
   setenv ORACLE_TBSP  $oracle_tbsp
endif

if (-e $orahome/.cshrc) then
  if (`grep 'ORACLE_TBSP' $orahome/.cshrc | wc -l` == 0) then
    echo "setenv ORACLE_TBSP $oracle_tbsp" >> $orahome/.cshrc
    source $orahome/.cshrc
  endif
endif
#       end of defining tablespace files directory                 - 


echo ""
set def="10"
unset valid_tbsize
while(! $?valid_tbsize)
   echo "How big should the index and data tablespace files be initially (in Mb)"
   echo -n "[$def] ?: "
   set tbsize="$<"
   if ("$tbsize" == "") set tbsize="$def"
   if (`echo "$tbsize" | egrep -c '^[0-9]+$'` == 0 || $tbsize <= 0) then
      echo "ERROR:  $tbsize - must be a number > 0 (in Mb)."
      echo ""
   else if ("$tbsize" < "10") then
      unset valid_ans
      while(! $?valid_ans)
         echo -n "This is less than the default (10) are you sure (y/n) ?: "
         set ans="$<"
         if ("$ans" =~ [Yy]* || "$ans" =~ [Nn]*) set valid_ans
         echo ""
      end
      if ("$ans" =~ [Yy]*) set valid_tbsize
   else
      set valid_tbsize
   endif
end


echo ""
echo "Creating the oracle user account ..."
echo ""
 
# local inits
if ("$PRO_LOAD_DIR" == "__unset__") then
   if (-d $scrdir/../../pdm/pdmtools/sql) then
      set sqlscrdir="$scrdir/../../pdm/pdmtools/sql"
   else
      set sqlscrdir="$cwd"
   endif
else
   set sqlscrdir="$PRO_LOAD_DIR/pdm/pdmtools/sql"
endif

set ptcoradir="$orahome/PTC_PDM"
set reqd_kb=`echo "2*$tbsize*1024 + 100" | bc`
set oraprocess="ora_pmon_$orasid"
set sql_start_cmd="startup pfile=$orainitfile"

# Set ORACLE env. variables
setenv ORACLE_HOME "$orahome"
setenv ORACLE_SID "$orasid"
setenv ORACLE_TBSP "$oracle_tbsp"


#Check if the installer has Oracle login privilege.

set sqldba_cmd="$orahome/bin/sqldba"
set get_login="/tmp/login_ok.$$"
echo "$conline" > $get_login.sql
echo "exit" >> $get_login.sql
$sqldba_cmd @$get_login.sql  >> $get_login.sql
if (`cat $get_login.sql | grep 'logon denied' | wc -l` != 0) then
    echo ""
    echo "ERROR: Logon denied, please make sure you have the automatic login privilege"
    echo "       or the valid Oracle login format username/password."
    echo ""
    goto EXIT_ERROR
endif
rm -f $get_login.sql >& /dev/null


# check write access to init file
touch $orainitfile >& /dev/null
if ($status != 0) then
   echo ""
   echo "ERROR:  $orainitfile - no write access."
   echo "        As the owner of $orainitfile type:"
   echo "        chmod g+rw $orainitfile"
   echo "        then retry."
   goto EXIT_ERROR
endif


# use sqldba/grep to identify the Oracle version

set tmpfile="/tmp/version.txt"
echo "$conline" > $gen_tmpfile.sql
cat $sqlscrdir/find_version.sql >> $gen_tmpfile.sql
$sqldba_cmd @$gen_tmpfile.sql >& $tmpfile
if (`grep '7.*' $tmpfile |wc -l` != 0) then
   set  ORAC_VERSION = "7"
else
   set  ORAC_VERSION = "6"
endif
rm -f $tmpfile $gen_tmpfile.sql >& /dev/null


# Check the user status. If already existing, issue an error message. 

set orauser = `echo $PDMUSER | tr '[a-z]' '[A-Z]'`
echo "$conline" > $gen_tmpfile.sql

if ($ORAPWDCHK) then
   echo "select username from all_users where username = '$orauser'" >> $gen_tmpfile.sql
else
   echo "select username from all_users where username like 'OPS%$orauser'" >> $gen_tmpfile.sql
endif

set get_query="/tmp/query_out.$$"
$sqldba_cmd @$gen_tmpfile.sql  >& $get_query 
set numrows=`cat $get_query | grep 'row selected' | awk '{print $1}'`
rm -f $get_query >& /dev/null

if ($ORAPWDCHK) then
  set password = "PTC"  #default password
  if ("$numrows" > 0) then
    echo "Sorry, user '$PDMUSER' already exists in the Oracle server"
    echo ""
    goto EXIT_ERROR
  else
    echo "'$PDMUSER' is a new user in the Oracle server."
    unset valid_ans
      while (! $?valid_ans)
         echo ""
         echo -n "Do you want to accept PTC as the new user($PDMUSER)'s default password (y/n)? "
         set ans="$<"
         if ("$ans" =~ [Yy]* || "$ans" =~ [Nn]* ) set valid_ans
      end

    if ("$ans" =~ [Nn]*) then
           while ("$password" == "" || "$password" == "PTC")
                 echo ""
                 echo "Please set the new user($PDMUSER)'s password. "
                 echo -n "$PDMUSER's Password: "
                 set  password="$<"
                 if ("$password" == "PTC") echo "Please don't set PTC as the default password."
           end
    endif
 endif
else  #auto login priviledge check 
  if ("$numrows" > 0) then
    echo "Sorry, '$PDMUSER' with automatic login privilege already exists in the Oracle server"
    echo ""
    goto EXIT_ERROR
  else
    echo "'$PDMUSER' with automatic login privilege is a new user in the Oracle server."
  endif
endif
 

# CHECK ORACLE IS RUNNING

if ("$PS_CMD" != "__unset__") then
   if (`$PS_CMD | grep -v grep | egrep " $oraprocess *"$ | wc -l` == 0) then
      echo ""
      echo "starting ORACLE ..."
      echo "$sql_start_cmd" > $gen_tmpfile
      if ($ORAC_VERSION == "6") then
         $sqldba_cmd @$gen_tmpfile >& /dev/null
      else
         $sqldba_cmd @/$sqlscrdir/startdb.sql.V7 >& /dev/null 
      endif 
      rm -f $gen_tmpfile
      if (`$PS_CMD | grep -v grep | egrep " $oraprocess *"$ | wc -l` == 0) then
         echo ""
         echo "ERROR:  could not start oracle"
         goto EXIT_ERROR
      endif
   endif
endif


# check if rollback exists and is large enough
unset add_roll
set outfile="/tmp/rollsegs.out"
set tmpfile="/tmp/rollsegs.lst"
echo "$conline" > $gen_tmpfile.sql
cat $sqlscrdir/checkroll.sql >> $gen_tmpfile.sql
$sqldba_cmd @$gen_tmpfile.sql >& $outfile
if (! -e $tmpfile) then
   echo ""
   echo "ERROR:  could not check rollbacks.  Check that DBA access privilege has been"
   echo "        granted to the installer. "
   echo ""
   echo "Oracle error message was:"
   cat $outfile
   rm -f $outfile $tmpfile >& /dev/null
   goto EXIT_ERROR
else
   if (`cat $outfile | grep 'logon denied' | wc -l` != 0) then
      echo ""
      echo "ERROR:  could not check rollbacks - check that DBA access or login"
      echo "        privilege has been granted to the installer."
      rm -f $outfile $tmpfile >& /dev/null
      goto EXIT_ERROR
   endif
   set numrows=`cat $tmpfile | grep 'rows selected' | awk '{print $1}'`
   if ("$numrows" == 0) set add_roll
endif
rm -f $outfile $tmpfile >& /dev/null

if ($?add_roll) then
   echo ""
   echo "WARNING:  After the install the ORACLE database must be shutdown"
   echo "          and restarted."
endif

# create PTC table space
# According to the Oracle Version, to run the different .sql script files
switch ( $ORAC_VERSION )
case "6" :
# create tablespace in Oracle Version 6
  if ($ORAPWDCHK) then
#  cat $sqlscrdir/setup_tbsp_user.sql | grep -v 'grant connect' | sed s/' identified by PTC'//g | sed s/'OPS$<PDMuser>'/$PDMUSER/g > $gen_tmpfile.sql
     echo "$conline" > $gen_tmpfile.sql.V6
     cat $sqlscrdir/setup_tbsp_user.sql | grep -v 'grant connect' | grep -v 'alter user' | sed s/' identified by PTC'//g | sed s/'OPS$<PDMuser>'/$PDMUSER/g >> $gen_tmpfile.sql.V6
  else
     echo "$conline" > $gen_tmpfile.sql
     cat $sqlscrdir/usersearch.sql >> $gen_tmpfile.sql
     $sqldba_cmd @$gen_tmpfile.sql >>& $gen_tmpfile.users
     if (`grep -i ^OPS\$$PDMUSER\  $gen_tmpfile.users | wc -l` == 0) then
        echo "$conline" > $gen_tmpfile.sql.V6
        cat $sqlscrdir/setup_tbsp_user.sql | sed s/'<PDMuser>'/$PDMUSER/g >> $gen_tmpfile.sql.V6
     else
        echo "$conline" > $gen_tmpfile.sql.V6
        cat $sqlscrdir/setup_tbsp_user.sql | sed s/'<PDMuser>'/$PDMUSER/g | sed s/' identified by PTC'//g | sed s/' identified by ptc'//g >> $gen_tmpfile.sql.V6
     endif
  endif
  rm -f $gen_tmpfile.users >& /dev/null
  breaksw

case "7":
# create tablespace in Oracle Version 7
 if ($ORAPWDCHK) then
  echo "$conline" > $gen_tmpfile.sql.V7
  cat $sqlscrdir/setup_tbsp_user.sql.V7 | sed s/'OPS$<PDMuser>'/$PDMUSER/g | sed s/'PTC'/$password/g >> $gen_tmpfile.sql.V7 
 else
  echo "$conline" > $gen_tmpfile.sql
  cat $sqlscrdir/usersearch.sql >> $gen_tmpfile.sql
  $sqldba_cmd @$gen_tmpfile.sql >>& $gen_tmpfile.users
  if (`grep -i ^OPS\$$PDMUSER\  $gen_tmpfile.users | wc -l` == 0) then
     echo "$conline" > $gen_tmpfile.sql.V7
     cat $sqlscrdir/setup_tbsp_user.sql.V7 | sed s/'<PDMuser>'/$PDMUSER/g >> $gen_tmpfile.sql.V7
  else
     echo "$conline" > $gen_tmpfile.sql.V7
     cat $sqlscrdir/setup_tbsp_user.sql.V7 | sed s/'<PDMuser>'/$PDMUSER/g | sed s/'by PTC'/'externally'/g >> $gen_tmpfile.sql.V7
  endif
 endif
 rm -f $gen_tmpfile.users >& /dev/null
 breaksw

default:
   echo "ERROR:  problem configuring Oracle DB....."
   goto EXIT_ERROR
endsw

cd /tmp
set tmpfile="/tmp/sqlout.txt"
if ($ORAC_VERSION == "7") then
   echo "$conline" > /tmp/create_tbsp.sql
   cat $sqlscrdir/create_tbsp.sql.V7 | sed s/"SIZE 10 M"/"SIZE $tbsize M"/g >> /tmp/create_tbsp.sql
   $sqldba_cmd @$gen_tmpfile.sql.V7 >& $tmpfile
else
   echo "$conline" > /tmp/create_tbsp.sql
   cat $sqlscrdir/create_tbsp.sql | sed s/"SIZE 10 M"/"SIZE $tbsize M"/g >> /tmp/create_tbsp.sql
   $sqldba_cmd @$gen_tmpfile.sql.V6 >& $tmpfile
endif

if (`grep -i 'already exists' $tmpfile | wc -l` == 0) then
   if (`grep -i 'statement processed' $tmpfile | wc -l` == 0) then
      echo ""
      echo "ERROR:  problem creating table space(or users) with insufficient privileges."
      echo ""
      echo "Oracle error message was:"
      cat $tmpfile
      rm -f $tmpfile /tmp/create_tbsp.sql >& /dev/null
      echo ""
      echo ""
      echo "*** Please make sure that you have sufficient privileges to create an Oracle user account. ***" 
      goto EXIT_ERROR
   endif
endif
rm -f $tmpfile $gen_tmpfile.sql.V*  /tmp/create_tbsp.sql* >& /dev/null


if ($?add_roll) then
   # Create roll
   set tmpfile="/tmp/sqlout.txt"
   echo "$conline" > $gen_tmpfile.sql
   cat $sqlscrdir/create_roll.sql >> $gen_tmpfile.sql
   $sqldba_cmd @$gen_tmpfile.sql >& $tmpfile
   if (`grep -i 'already exists' $tmpfile | wc -l` == 0) then
      if (`grep -i 'statement processed' $tmpfile | wc -l` == 0) then
         rm -f $tmpfile >& /dev/null
         echo ""
         echo "ERROR:  problem creating rollback segment."
         goto EXIT_ERROR
      endif
   endif
   rm -f $tmpfile >& /dev/null

   # Modify Initfile
   cp $orainitfile /tmp/$orainitfile:t.bak >& /dev/null
   set rbline=`grep '^ *rollback_segments' $orainitfile`

   if (`echo "$rbline" | grep PTC_FIRST_ROLL | wc -l` == 0) then
      if ("$rbline" == "") then
         set newrbline="rollback_segments=PTC_FIRST_ROLL"
      else
         set rbnames=`echo "$rbline" | awk -F\= '{print $2}'`
         set rbnames=`echo "$rbnames" | tr -d '(' |  tr -d ')'`
         set newrbline="rollback_segments=($rbnames,PTC_FIRST_ROLL)"
      endif
      cat $orainitfile | grep -v '^ *rollback_segments' > $gen_tmpfile
      echo "$newrbline" >> $gen_tmpfile
      cp $gen_tmpfile $orainitfile
      rm -f $gen_tmpfile >& /dev/null
   endif
endif

EXIT_SUCCESS:
if ($?add_roll) then
   set stat="roll"
else
   set stat="succ"
endif

echo "$stat" > $CNFG_STATFILE
rm -f $gen_tmpfile.sql >& /dev/null

echo ""
echo "The Oracle user account has been created successfully. "
echo ""
exit(0)

EXIT_ERROR:
echo "fail" > $CNFG_STATFILE
rm -f $gen_tmpfile.sql >& /dev/null
echo "Fail to create the Oracle user account."
echo ""
exit(1)
