# This is the default value for CHOWN
# It will redefined later in this script for those ports
# which have it conditionally defined in ss_install.h
CHOWN=/bin/chown
CHGRP=/bin/chgrp
GROUPS=/usr/bin/groups
# Group file
GROUP="dba"
GROUP_LOC="/etc/group"
PASSWD_LOC="/etc/passwd"
#
# Define variables to be used in this script
#
# oratab location
ORATAB=/etc/oratab
#
# 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
# Information to run this script.
echo ""
echo "*************************************************************************"
echo "Following conditions should be met to run this script successfully."
echo "1. Needs root permission to run this script."
echo "2. Need to set ORACLE_OWNER enviornment variable to the user
who"
echo " installs oracle product."
echo "3. This ORACLE_OWNER should be part of group \"dba\"."
echo ""
echo "If any of these conditions are not met, please re-run after satisfying"
echo "these conditions."
echo "*************************************************************************"
DEFLT="Y";
echo $N "Is it OK to continue (Y/N)? [${DEFLT}]: $C"
RDVAR=$DEFLT
read RDVAR
case $RDVAR in
"") RDVAR=$DEFLT;;
*) ;;
esac
ANSWER=$RDVAR
case $ANSWER in
Y|y) ;;
*) echo "Exiting oratab.sh script..."
exit 0 ;;
esac
#
# Make sure effective uid is $ROOT.
#
> /tmp/fil$$
INAME=`/bin/ls -l /tmp/fil$$ | awk '{print $3}'`
rm -f /tmp/fil$$
case "$INAME" in
root) ;;
*) echo ""
echo "You must be logged in as root to run oratab.sh. Exiting..."
echo ""
exit 1 ;;
esac
##endif /* ! SLPR_MLS */
case $ORACLE_OWNER in
"") echo "ORACLE_OWNER is not set."
echo "Set and export ORACLE_OWNER,
then restart oratab.sh execution."
exit 1 ;;
esac
#
# Last chance for the user to confirm these values.
#
DEFLT="Y";
echo ""
echo "The ORACLE_OWNER is set as: $ORACLE_OWNER"
echo $N "Are these settings correct (Y/N)? [${DEFLT}]: $C"
RDVAR=$DEFLT
read RDVAR
case $RDVAR in
"") RDVAR=$DEFLT;;
*) ;;
esac
ANSWER=$RDVAR
case $ANSWER in
Y|y) ;;
*) echo "Exiting oratab.sh script.
Please set these environment
variables to the desired values"
exit 0 ;;
esac
#
# Check for oracle uid in /etc/passwd; retrieve home directory &
group id
#
echo ""
echo "Checking for \"$ORACLE_OWNER\" user id..." | tee -a $LOG
PW_ENTRY=`grep "^${ORACLE_OWNER}:" /etc/passwd 2> /dev/null`
case $PW_ENTRY in
"") PW_ENTRY=`(ypmatch $ORACLE_OWNER passwd.byname)
2>/dev/null` ;;
esac
case $PW_ENTRY in
"") PW_ENTRY=`(nismatch $ORACLE_OWNER passwd.org_dir)
2>/dev/null` ;;
esac
case $PW_ENTRY in
"") echo "Cannot find password file entry for \"$ORACLE_OWNER\"
user id."
echo "Exiting install script."
exit 1 ;;
esac
# Checking the group requirements.
# Using /bin/groups to get the set of groups of which ORACLE_OWNER
is
# a member. This fixes bug 630120 where oratab.sh was not looking
in
# the password file for group membership.
ALL_GROUPS=`${GROUPS} ${ORACLE_OWNER}`
OWNER_IN_GROUP=false
for group in ${ALL_GROUPS}
do
if [ "$group" = "${GROUP}" ] ; then
OWNER_IN_GROUP=true
fi
done
if [ "${OWNER_IN_GROUP}" = "false" ] ; then
echo ""
echo "The user \"${ORACLE_OWNER}\" should be in \"${GROUP}\"
group."
echo "Please add user \"${ORACLE_OWNER}\" to group \"${GROUP}\"
and re-run the oratab.sh script."
exit 1
fi
#
# Make sure an oratab file exists on this system
#
oratab_exists=true
if [ ! -s ${ORATAB} ] ; then
echo ""
echo "Creating ${ORATAB} file..."
cat <<!>> ${ORATAB}
#
# This file is used by ORACLE utilities. It is created
by root.sh
# and updated by the Oracle8 and SQL*Net install procedures.
#
# 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 field
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 # [ ! -s ${ORATAB} ]
#
touch ${ORATAB}
$CHOWN ${ORACLE_OWNER} ${ORATAB}
$CHGRP ${GROUP} ${ORATAB}
chmod 664 ${ORATAB}
exit 0