Find Oracle too beautiful again orainstRoot. sh

Source: Internet
Author: User

Find Oracle too beautiful again orainstRoot. sh
When we install the database software, we will execute orainstRoot. sh. Today, let's take a closer look at what this script is.
The platform is RedHat 6.4 x64, and the database version is 11.2.0.4.2
The following is the script content.
[Oracle @ rh64 ~] $ Cd/u01/app/oraInventory/
[Oracle @ rh64 oraInventory] $ ls-ltr
Total 24
Drwxrwx --- 2 oracle oinstall 4096 Oct 30 2013 ContentsXML
-Rwxrwx --- 1 oracle oinstall 1620 Oct 30 2013 orainstRoot. sh
-Rw ---- 1 oracle oinstall 56 Oct 30 2013 oraInst. loc
Drwxrwx --- 3 oracle oinstall 4096 May 14 backup
Drwxrwx --- 2 oracle oinstall 4096 May 14 logs
Drwxrwx --- 2 oracle oinstall 4096 May 15 oui
[Oracle @ rh64 oraInventory] $ cat orainstRoot. sh
#! /Bin/sh
AWK =/bin/awk
CHMOD =/bin/chmod
CHGRP =/bin/chgrp
CP =/bin/cp
ECHO =/bin/echo
MKDIR =/bin/mkdir
RUID = '/usr/bin/id | $ AWK-F \ (' {print $1} '| $ AWK-F \ =' {print $2 }''
If [$ {RUID }! = "0"]; then
$ ECHO "This script must be executed as root"
Exit 1
Fi
----- >>> Here, the permission is verified first to see if it is executed by the root user. If not, exit.
If [-d "/etc"]; then
$ CHMOD 755/etc;
Else
$ MKDIR-p/etc;
Fi
If [-f "/u01/app/oraInventory/oraInst. loc"]; then
$ CP/u01/app/oraInventory/oraInst. loc/etc/oraInst. loc;
$ CHMOD 644/etc/oraInst. loc
Else
INVPTR =/etc/oraInst. loc
INVLOC =/u01/app/oraInventory
GRP = oinstall
PTRDIR = "'dirname $ INVPTR '";
----- >>> If the Central Inventory exists, that is, the preceding oraInst. loc, it will copy a copy to/etc/, as the Central Inventory Pointer File, you can know from the name,
This is the Pointed File of Central Inventory.
# Create the software inventory location pointer file
If [! -D "$ PTRDIR"]; then
$ MKDIR-p $ PTRDIR;
Fi
$ ECHO "Creating the Oracle inventory pointer file ($ INVPTR )";
$ ECHO inventory_loc = $ INVLOC> $ INVPTR
$ ECHO inst_group = $ GRP >>$ INVPTR
Chmod 644 $ INVPTR
# Create the inventory directory if it doesn't exist
If [! -D "$ INVLOC"]; then
$ ECHO "Creating the Oracle inventory directory ($ INVLOC )";
$ MKDIR-p $ INVLOC;
Fi
Fi
----- >>>> If it does not exist, it will be created one by one and the permission needs to be modified
$ ECHO "Changing permissions of/u01/app/oraInventory.
Adding read, write permissions for group.
Removing read, write, execute permissions for world.
";
$ CHMOD-R g + rw, o-rwx/u01/app/oraInventory;
----- >>>> For this directory, the Group must have read and write permissions, and the group must have read and write permissions.
If [$? ! = 0]; then
$ ECHO "OUI-35086: WARNING: chmod of/u01/app/oraInventory
Adding read, write permissions for group.
, Removing read, write, execute permissions for world.
Failed! ";
Fi
$ ECHO "Changing groupname of/u01/app/oraInventory to oinstall .";
$ CHGRP-R oinstall/u01/app/oraInventory;
----- >>> Note that the group here is oinstall
If [$? ! = 0]; then
$ ECHO "OUI-10057: WARNING: chgrp of/u01/app/oraInventory to oinstall failed! ";
Fi
$ ECHO "The execution of the script is complete ."
[Oracle @ rh64 oraInventory] $

As shown above, this script is nothing more than creating oraInst. loc, and then modifying the permission for this product directory. Note that the Group permission is read/write, the host is 777, And the oraInventory group is oinstall
Nothing else. You only need to know what to do. If you have learned it, you will have nothing to do. If you have reported an error and re-checked it, you will be OK.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.