#!/bin/sh
#
# $Header
# $Copyright
#
#
# root.sh
#
# This script is intended to be run by root. The script contains
# all the product installation actions that require root privileges.
#
# IMPORTANT NOTES - READ BEFORE RUNNING SCRIPT
#
# (1) ORACLE_HOME and ORACLE_OWNER can be defined in user's
# environment to override default values defined in this script.
#
# (2) The environment variable LBIN (defined within the script) points to
# the default local bin area. Three executables will be moved there as
# part of this script execution.
#
# (3) Define (if desired) LOG variable to name of log file.
#
AWK=/bin/awk
CAT=/bin/cat
CHOWN=/bin/chown
CHMOD=/bin/chmod
CP=/bin/cp
ECHO=/bin/echo
$ECHO "" > $LOG
fi
#
# Display abort message on interrupt.
#
trap '$ECHO "Oracle9 root.sh execution aborted!"|tee -a $LOG;exit' 1 2 3 15
#
# Enter log message
#
$ECHO "Running Oracle9 root.sh script..."|tee -a $LOG
#
# Default values set by Installer
#
ORACLE_HOME=/eo/OraHome1
ORACLE_OWNER=oracle
#
# check for root
#
RUID=`/usr/bin/id|$AWK -F\( '{print $2}'|$AWK -F\) '{print $1}'`
if [ ${RUID} != "root" ];then
$ECHO "You must be logged in as root to run root.sh."| $TEE -a $LOG
$ECHO "Log in as root and restart root.sh execution."| $TEE -a $LOG
exit 1
fi
#
# Determine how to suppress newline with $ECHO command.
#
case ${N}$C in
"") if $ECHO "\c"| $GREP c >/dev/null 2>&1;then
N='-n'
else
C='\c'
fi;;
esac
#
$ECHO "\nThe following environment variables are set as:"| $TEE -a $LOG
$ECHO " ORACLE_OWNER= $ORACLE_OWNER"| $TEE -a $LOG
$ECHO " ORACLE_HOME= $ORACLE_HOME"| $TEE -a $LOG
#
# Get name of local bin directory
#
$ECHO ""
$ECHO $N "Enter the full pathname of the local bin directory: $C"
DEFLT=${LBIN}; . $ORACLE_HOME/install/utl/read.sh; LBIN=$RDVAR
if [ ! -d $LBIN ];then
$ECHO "Creating ${LBIN} directory..."| $TEE -a $LOG
$MKDIR -p ${LBIN} 2>&1| $TEE -a $LOG
$CHMOD 777 ${LBIN} 2>&1| $TEE -a $LOG
fi
#
# Move files to LBIN, and set permissions
#
DBHOME=$ORACLE_HOME/bin/dbhome
ORAENV=$ORACLE_HOME/bin/oraenv
CORAENV=$ORACLE_HOME/bin/coraenv
FILES="$DBHOME $ORAENV $CORAENV"
for f in $FILES ; do
if [ -f $f ] ; then
$CHMOD 755 $f 2>&1 2>> $LOG
short_f=`$ECHO $f | $SED 's;.*/;;'`
lbin_f=$LBIN/$short_f
if [ -f $lbin_f ] ; then
$ECHO $n "The file \"$short_f\" already exists in $LBIN. Overwrite it? (y/n) $C"
DEFLT='n'; . $ORACLE_HOME/install/utl/read.sh; OVERWRITE=$RDVAR
else
OVERWRITE='y';
fi
if [ "$OVERWRITE" = "y" ]; then
$CP $f $LBIN 2>&1 2>> $LOG
$CHOWN $ORACLE_OWNER $LBIN/`$ECHO $f | $AWK -F/ '{print $NF}'` 2>&1 2>> $LOG
$ECHO " Copying $short_f to $LBIN ..."
fi
fi
done
$ECHO ""
#
# Make sure an oratab file exists on this system
#
if [ ! -s ${ORATAB} ];then
$ECHO "\nCreating ${ORATAB} file..."| $TEE -a $LOG
if [ ! -d ${ORATABLOC} ];then
$MKDIR -p ${ORATABLOC}
fi
$CAT <<!>> ${ORATAB}
#
# This file is used by ORACLE utilities. It is created by root.sh
# and updated by the Database Configuration Assistant when creating
# a database.
# A colon, ':', is used as the field terminator. A new line terminates
# the entry. Lines beginning with a pound sign, '#', are comments.
#
# Entries are of the form:
# \$ORACLE_SID:\$ORACLE_HOME:<N|Y>:
#
# The first and second fields are the system identifier and home
# directory of the database respectively. The third filed indicates
# to the dbstart utility that the database should , "Y", or should not,
# "N", be brought up at system boot time.
#
# Multiple entries with the same \$ORACLE_SID are not allowed.
#
#
!
fi
$CHOWN $ORACLE_OWNER ${ORATAB}
$CHMOD 664 ${ORATAB}
#
# If there is an old entry with no sid and same oracle home,
# that entry will be marked as a comment.
#
FOUND_OLD=`$GREP "^*:${ORACLE_HOME}:" ${ORATAB}`
if [ -n "${FOUND_OLD}" ];then
$SED -e "s?^*:$ORACLE_HOME:?# *:$ORACLE_HOME:?" $ORATAB > $TMPORATB
$CAT $TMPORATB > $ORATAB
$RM -f $TMPORATB 2>/dev/null
fi
#
# Add generic *:$ORACLE_HOME:N to oratab
#
$ECHO "Adding entry to ${ORATAB} file..."| $TEE -a $LOG
$CAT <<!>> ${ORATAB}
*:$ORACLE_HOME:N
!
$ECHO "Entries will be added to the ${ORATAB} file as needed by"| $TEE -a $LOG
$ECHO "Database Configuration Assistant when a database is created"| $TEE -a $LOG
#
# Change mode to remove group write permission on Oracle home
#
$CHMOD -R g-w $ORACLE_HOME
$ECHO "Finished running generic part of root.sh script."| $TEE -a $LOG
$ECHO "Now product-specific root actions will be performed."| $TEE -a $LOG