又一次发现Oracle太美之root.sh

假设你运行下下面命令基本上会在Oracle软件文件夹下会发现两个root.sh的脚本
[oracle@rh64 Templates]$ find /u01/ -name root.sh |xargs ls -ltr
-rwxrwx--- 1 oracle oinstall  10 May 14 02:37 /u01/app/db11g/product/11.2.0/dbhome_1/inventory/Templates/root.sh
-rwxr-x--- 1 oracle oinstall 512 May 14 02:47 /u01/app/db11g/product/11.2.0/dbhome_1/root.sh


第一个脚本里面没啥东西。我们今天主要来研究下第二个root.sh是干啥用的。也就是我们安装软件后须要执行的这个root.sh的主要作用。
[oracle@rh64 ~]$ cat /u01/app/db11g/product/11.2.0/dbhome_1/root.sh
#!/bin/sh
. /u01/app/db11g/product/11.2.0/dbhome_1/install/utl/rootmacro.sh "$@"
. /u01/app/db11g/product/11.2.0/dbhome_1/install/utl/rootinstall.sh
/u01/app/db11g/product/11.2.0/dbhome_1/install/unix/rootadd.sh


#
# Root Actions related to network
#
/u01/app/db11g/product/11.2.0/dbhome_1/network/install/sqlnet/setowner.sh 


#
# Invoke standalone rootadd_rdbms.sh
#
/u01/app/db11g/product/11.2.0/dbhome_1/rdbms/install/rootadd_rdbms.sh


/u01/app/db11g/product/11.2.0/dbhome_1/rdbms/install/rootadd_filemap.sh 
[oracle@rh64 ~]$ 
能够看到上面脚本里面包括了6个小的脚本,我们一一来分析下看看这个root.sh里面的脚本都是干啥的。


1.第一个脚本
[oracle@rh64 ~]$ cat /u01/app/db11g/product/11.2.0/dbhome_1/install/utl/rootmacro.sh
#!/bin/sh
#
# $Id: rootmacro.sbs /st_buildtools_11.2.0/2 2012/11/06 02:43:45 rmallego Exp $
# Copyright (c) 2004, 2012, 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.
#
-------->>>上面明白说明执行脚本之前ORACLE_HOME,ORACLE_OWNER一定要设置
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=/etc
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=false


#
# Default values set by Installer
#


ORACLE_HOME=/u01/app/db11g/product/11.2.0/dbhome_1
ORACLE_OWNER=oracle
OSDBA_GROUP=oinstall
MAKE=/usr/bin/make


#
# 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


#
# 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


#
# Silent variable is set based on :
# if OUI_SILENT is true or if SILEN
posted on 2017-06-21 08:46  ljbguanli  阅读(404)  评论(0编辑  收藏  举报