This repository has been archived by the owner on Nov 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreateCentralInventory.sh
executable file
·73 lines (68 loc) · 1.64 KB
/
createCentralInventory.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/sh
# Create Central Inventory
output=`id`
UserID=`echo $output | cut -f1 -d ' ' | cut -f2 -d '=' | cut -f1 -d '('`
if [ "$UserID" != "0" ]; then
echo "This script must be executed as root"
exit 1
fi
if [ $# -ne 2 ]
then
echo "Error in $0 - Invalid Argument Count"
echo "Syntax: $0 inventory_location group_name"
exit
fi
echo "Setting the inventory to $1"
echo "Setting the group name to $2"
INVDIR=/etc
PLATFORMID=`uname -a | awk '{{print $1}}'`
if [ "$PLATFORMID" = "Linux" ]
then
INVDIR=/etc
fi
if [ "$PLATFORMID" = "SunOS" ]
then
INVDIR=/var/opt/oracle
fi
if [ "$PLATFORMID" = "HP-UX" ];
then
INVDIR=/var/opt/oracle
fi
if [ "$PLATFORMID" = "AIX" ]
then
INVDIR=/etc
fi
echo "Creating inventory pointer file in $INVDIR directory"
if [ -d $INVDIR ]; then
chmod 755 $INVDIR;
else
mkdir -p $INVDIR;
fi
INVPTR=${INVDIR}/oraInst.loc
INVLOC=$1
GRP=$2
PTRDIR="`dirname $INVPTR`";
# 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
echo "Changing permissions of $1 to 770.";
chmod -R g+rw,o-rwx $1;
if [ $? != 0 ]; then
echo "OUI-35086:WARNING: chmod of $1 to 770 failed!";
fi
echo "Changing groupname of $1 to $2.";
chgrp -R $2 $1;
if [ $? != 0 ]; then
echo "OUI-10057:WARNING: chgrp of $1 to $2 failed!";
fi
echo "The execution of the script is complete"