#!/bin/sh # # $Id: rootmacro.sbs /st_buildtools_11.2.0/1 2011/01/31 02:04:09 bkghosh Exp $ # Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. # # 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 CHGRP=/bin/chgrp CHOWN=/bin/chown CHMOD=/bin/chmod CP=/bin/cp DIFF=/usr/bin/diff ECHO=echo GREP=/bin/grep LBIN=/usr/local/bin MKDIR=/bin/mkdir ORATABLOC=%s_oratabloc% ORATAB=${ORATABLOC}/oratab RM=/bin/rm SED=/bin/sed UNAME=/bin/uname DATE=/bin/date TEE=/usr/bin/tee TMPORATB=/var/tmp/oratab$$ if [ `$UNAME` = "SunOS" ] then GREP=/usr/xpg4/bin/grep fi # Variable based on installation OUI_SILENT=%s_silent% # # Default values set by Installer # ORACLE_HOME=%ORACLE_HOME% ORACLE_OWNER=%OwnerId% OSDBA_GROUP=%OwnerGroup% MAKE=%oracle_install_UnixMakePath% # # conditional code execution starts. This set of code is invoked exactly once # regardless of number of scripts that source rootmacro.sh if [ "x$WAS_ROOTMACRO_CALL_MADE" = "x" ]; then WAS_ROOTMACRO_CALL_MADE=YES ; export WAS_ROOTMACRO_CALL_MADE LOG=${ORACLE_HOME}/install/root_`$UNAME -n`_`$DATE +%F_%H-%M-%S`.log ; export LOG # # Parse argument # while [ $# -gt 0 ] do case $1 in -silent) SILENT_F=1;; # silent is set to true -crshome) shift; CRSHOME=$1; export CRSHOME;; # CRSHOME is set -bindir) shift; LBIN=$1; export LBIN;; esac; shift done # # Silent variable is set based on : # if OUI_SILENT is true or if SILENT_F is 1 # if [ "${OUI_SILENT}" = "true" -o "$SILENT_F" ] then SILENT=1 else SILENT=0 fi if [ $SILENT -eq 1 ] then $ECHO "Check $LOG for the output of root script" exec > /dev/null 2>&1 fi # # If LOG is not set, then send output to /dev/null # if [ "x${LOG}" = "x" -o "${LOG}" = "" ];then LOG=/dev/null else $CP $LOG ${LOG}0 2>/dev/null $ECHO "" > $LOG fi # # check for valid crshome # if [ "$CRSHOME" -a ! -d "$CRSHOME" ]; then $ECHO "ERROR: CRS home $CRSHOME is not a valid directory." | $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 # # check for zero UID # RUID=`/usr/bin/id|$AWK -F\( '{print $1}'|$AWK -F= '{print $2}'` if [ $RUID -ne 0 ];then $ECHO "You must be logged in as user with UID as zero (e.g. root user) to run root configuration script."| $TEE -a $LOG $ECHO "Log in as user with UID as zero (e.g. root user) and restart root configuration script execution."| $TEE -a $LOG exit 1 fi # # Display abort message on interrupt. # trap '$ECHO "Oracle root script execution aborted!"| $TEE -a $LOG;exit' 1 2 3 15 # # Check for $LOG file existence and if it exists, change the ownership to oracle_owner:oracle_owner_group and permissions to 600 # if [ -f $LOG ];then $CHOWN $ORACLE_OWNER:$OSDBA_GROUP $LOG $CHMOD 600 $LOG fi fi #conditional code execution ends