Create / Drop RCU using Shell script

rcucreation.sh


#!/bin/sh


###################################################################################
#  @author - Loguprasanth                               #
###################################################################################

source ${PWD}/rcu.properties

echo " ";

#Convert to UPPERCASE

RCU_Action=$(echo "$operation" | tr [:lower:] [:upper:])  #Convert to UpperCase

UC_domain=$(echo "$domain" | tr [:lower:] [:upper:])  #Convert to UpperCase

##LOG DETAILS
c_logvar1=" `date` <createRepository>  RCU Operation : $operation  Database URL : $connectString"
c_logvar2=" `date` <createRepository>  Database Type : $databaseType  Database User : $dbUser Database Role : $dbRole "
c_logvar3=" `date` <createRepository>  Schema Name : $schemaPrefix  Domain to be used for the Prefix : $UC_domain  Database Profile : $SOA_PROFILE_TYPE  Healthcare Integration : $HEALTHCARE_INTEGRATION"

c_logvar4_soa=" `date` <createRepository>  List of components : $SOAcomponentList"
c_logvar4_osb=" `date` <createRepository>  List of components : $OSBcomponentList"
c_logvar4_bam=" `date` <createRepository>  List of components : $BAMcomponentList"

d_logvar1=" `date` <dropRepository>  RCU Operation : $operation  Database URL : $connectString"
d_logvar2=" `date` <dropRepository>  Database Type : $databaseType  Database User : $dbUser Database Role : $dbRole "
d_logvar3=" `date` <dropRepository>  Schema Name : $schemaPrefix  Domain to be used for the Prefix : $UC_domain "

d_logvar4_soa=" `date`  <dropRepository>  List of components : $SOAcomponentList"
d_logvar4_osb=" `date` <dropRepository>  List of components : $OSBcomponentList"
d_logvar4_bam=" `date` <dropRepository>  List of components : $BAMcomponentList"

error_creation=" `date` <ERROR - RCU CREATION> Check your Database Connections and Components details"
error_drop=" `date` <ERROR - RCU DROP> Check your Database Connections and Components details"


##### ------ CREATEREPOSITORY - SOA

if  [ "$RCU_Action" == CREATEREPOSITORY ] && [ "$UC_domain" == SOA ] ; then

        echo -e "\e[32mMessage: The specified SOA Schema ($schemaPrefix) Started to Create...\e[97m"


$ORACLE_HOME/oracle_common/bin/rcu -honorOMF true -silent -createRepository -databaseType $databaseType -connectString $connectString -dbUser $dbUser -dbRole $dbRole -schemaPrefix $schemaPrefix -useSamePasswordForAllSchemaUsers true -selectDependentsForComponents true -variables SOA_PROFILE_TYPE=$SOA_PROFILE_TYPE,HEALTHCARE_INTEGRATION=$HEALTHCARE_INTEGRATION $SOAcomponentList -f <${PWD}/passwordfile.txt

if [ $? -eq 0 ]
then
echo -e "\e[32mSUCCESSFUL RCU CREATION\e[97m"
rm ${PWD}/passwordfile.txt
echo $c_logvar1 >> rcu.log; echo $c_logvar2 >> rcu.log ; echo $c_logvar3 >> rcu.log; echo $c_logvar4_soa >> rcu.log ;

else
echo -e "\e[31mUNSUCCESSFUL RCU CREATION\e[97m"
rm ${PWD}/passwordfile.txt
    echo $error_creation >> rcu.log ; echo $c_logvar1 >> rcu.log; echo $c_logvar2 >> rcu.log ; echo $c_logvar3 >> rcu.log;
    echo $c_logvar4_soa >> rcu.log ;

exit 1
fi

#### ------ CREATEREPOSITORY - OSB

elif  [ "$RCU_Action" == CREATEREPOSITORY ] && [ "$UC_domain" == OSB ] ; then

       echo -e "\e[32mMessage: The specified OSB Schema ($schemaPrefix) Started to Create...\e[97m"

$ORACLE_HOME/oracle_common/bin/rcu -honorOMF true -silent -createRepository -databaseType $databaseType -connectString $connectString -dbUser $dbUser -dbRole $dbRole -schemaPrefix $schemaPrefix -useSamePasswordForAllSchemaUsers true -selectDependentsForComponents true -variables SOA_PROFILE_TYPE=$SOA_PROFILE_TYPE,HEALTHCARE_INTEGRATION=$HEALTHCARE_INTEGRATION $OSBcomponentList -f <${PWD}/passwordfile.txt


if [ $? -eq 0 ]
then
echo -e "\e[32mSUCCESSFUL RCU CREATION\e[97m"
rm ${PWD}/passwordfile.txt
echo $c_logvar1 >> rcu.log; echo $c_logvar2 >> rcu.log ; echo $c_logvar3 >> rcu.log; echo $c_logvar4_osb >> rcu.log ;

else
echo -e "\e[31mUNSUCCESSFUL RCU CREATION\e[97m"
rm ${PWD}/passwordfile.txt

echo $error_creation >> rcu.log ; echo $c_logvar1 >> rcu.log; echo $c_logvar2 >> rcu.log ; echo $c_logvar3 >> rcu.log;
echo $c_logvar4_osb >> rcu.log ;
exit 1
fi

 #### ------ CREATEREPOSITORY - BAM

 elif  [ "$RCU_Action" == CREATEREPOSITORY ] && [ "$UC_domain" == BAM ] ; then

          echo -e "\e[32mMessage: The specified BAM Schema ($schemaPrefix) Started to Create...\e[97m"

  $ORACLE_HOME/oracle_common/bin/rcu -honorOMF true -silent -createRepository -databaseType $databaseType -connectString $connectString -dbUser $dbUser -dbRole $dbRole -schemaPrefix $schemaPrefix -useSamePasswordForAllSchemaUsers true -selectDependentsForComponents true -variables SOA_PROFILE_TYPE=$SOA_PROFILE_TYPE,HEALTHCARE_INTEGRATION=$HEALTHCARE_INTEGRATION $BAMcomponentList -f <${PWD}/passwordfile.txt


if [ $? -eq 0 ]
then
echo -e "\e[32mSUCCESSFUL RCU CREATION\e[97m"
rm ${PWD}/passwordfile.txt
echo $c_logvar1 >> rcu.log; echo $c_logvar2 >> rcu.log ; echo $c_logvar3 >> rcu.log; echo $c_logvar4_bam >> rcu.log ;

else
echo -e "\e[31mUNSUCCESSFUL RCU CREATION\e[97m"
rm ${PWD}/passwordfile.txt
    echo $error_creation >> rcu.log ; echo $c_logvar1 >> rcu.log; echo $c_logvar2 >> rcu.log ; echo $c_logvar3 >> rcu.log;
    echo $c_logvar4_bam >> rcu.log ;
exit 1
fi


##### ------ DROPREPOSITORY - SOA

elif [ "$RCU_Action" == DROPREPOSITORY ] && [ "$UC_domain" == SOA ]; then

        echo -e "\e[33m<WARNING> The specified prefix ($schemaPrefix) Ready to Remove From Following DB (host:port:serviceName) - $connectString Prefix : $schemaPrefix ...\e[97m"


        $ORACLE_HOME/oracle_common/bin/rcu -silent -dropRepository -databaseType $databaseType -connectString $connectString -dbUser $dbUser -dbRole $dbRole -schemaPrefix $schemaPrefix $SOAcomponentList -f <${PWD}/passwordfile.txt



if [ $? -eq 0 ]
then
echo -e "\e[32mSUCCESSFUL RCU DROP\e[97m"
rm ${PWD}/passwordfile.txt

echo $d_logvar1 >> rcu.log; echo $d_logvar2 >> rcu.log ; echo $d_logvar3 >> rcu.log; echo $d_logvar4_soa >> rcu.log ;

else
echo -e "\e[35mNOACTION SCHEMA_PREFIX NOT PRESENT\e[97m"
echo -e "\e[32m OR \e[97m"
echo -e "\e[31mUNSUCCESSFUL ORACLE_HOME NOT PRESENT\e[97m"
rm ${PWD}/passwordfile.txt
echo $error_drop >>rcu.log $d_logvar1 >> rcu.log; echo $d_logvar2 >> rcu.log ; echo $d_logvar3 >> rcu.log;
echo $d_logvar4_soa >> rcu.log ;
exit 1
fi

##### ------ DROPREPOSITORY - OSB

elif [ "$RCU_Action" == DROPREPOSITORY ] && [ "$UC_domain" == OSB ]; then

         echo -e "\e[33m<WARNING> The specified prefix ($schemaPrefix) Permanently Remove From Following DB (host:port:serviceName) - $connectString Prefix : $schemaPrefix\e[97m"

  $ORACLE_HOME/oracle_common/bin/rcu -silent -dropRepository -databaseType $databaseType -connectString $connectString -dbUser $dbUser -dbRole $dbRole -schemaPrefix $schemaPrefix $OSBcomponentList -f <${PWD}/passwordfile.txt

if [ $? -eq 0 ]
then
echo -e "\e[32mSUCCESSFUL RCU DROP\e[97m"
rm ${PWD}/passwordfile.txt
echo $d_logvar1 >> rcu.log; echo $d_logvar2 >> rcu.log ; echo $d_logvar3 >> rcu.log; echo $d_logvar4_osb >> rcu.log ;
else
echo -e "\e[35mNOACTION SCHEMA_PREFIX NOT PRESENT\e[97m"
echo -e "\e[32m OR \e[97m"
echo -e "\e[31mUNSUCCESSFUL ORACLE_HOME NOT PRESENT\e[97m"
rm ${PWD}/passwordfile.txt
echo $error_drop >>rcu.log $d_logvar1 >> rcu.log; echo $d_logvar2 >> rcu.log ; echo $d_logvar3 >> rcu.log;
echo $d_logvar4_osb >> rcu.log ;
exit 1
fi

##### ------ DROPREPOSITORY - BAM

elif [ "$RCU_Action" == DROPREPOSITORY ] && [ "$UC_domain" == BAM ]; then

         echo -e "\e[33m<WARNING> The specified prefix ($schemaPrefix) Permanently Remove From Following DB (host:port:serviceName) - $connectString Prefix : $schemaPrefix\e[97m"

$ORACLE_HOME/oracle_common/bin/rcu -silent -dropRepository -databaseType $databaseType -connectString $connectString -dbUser $dbUser -dbRole $dbRole -schemaPrefix $schemaPrefix $BAMcomponentList -f <${PWD}/passwordfile.txt

if [ $? -eq 0 ]
then
echo -e "\e[32mSUCCESSFUL RCU DROP\e[97m"
rm ${PWD}/passwordfile.txt
echo $d_logvar1 >> rcu.log; echo $d_logvar2 >> rcu.log ; echo $d_logvar3 >> rcu.log; echo $d_logvar4_bam >> rcu.log ;
else
echo -e "\e[35mNOACTION SCHEMA_PREFIX NOT PRESENT\e[97m"
echo -e "\e[32m OR \e[97m"
echo -e "\e[31mUNSUCCESSFUL ORACLE_HOME NOT PRESENT\e[97m"
rm ${PWD}/passwordfile.txt
echo $error_drop >>rcu.log $d_logvar1 >> rcu.log; echo $d_logvar2 >> rcu.log ; echo $d_logvar3 >> rcu.log;
echo $d_logvar4_bam >> rcu.log ;
exit 1
fi

##### ------ ERROR - CREATEREPOSITORY / DROPREPOSITORY

else
 
         echo -e "\e[31mError in progress\e[97m"

echo -e "\e[33m<WARNING>Kindly check DOMAIN NAME\OPERATION \e[97m"

         echo `date` "<ERROR> *Invalid RCU OPERATION or Invalid Domain *   RCU Operation : $operation  Domain to be used for the Prefix : $UC_domain   Database URL : $connectString"  >> rcu.log

fi

* * *

rcu.properties



#############################################################################################################################
########     USER DEFINED OPTIONS                 #########
#############################################################################################################################

#RCU Operation - createRepository, generateScript, dataLoad, dropRepository
# Choose the RCU operation based on requirements
operation=createRepository
#operation=dropRepository

#Enter the database connection details in the supported format. Database Connect String. This can be specified in the following format - For Oracle Database: host:port:SID OR host:port/service , For SQLServer, IBM DB2, MySQL and JavaDB Database: Server name/host:port:databaseName. For RAC database, specify VIP name or one of the Node name as Host name.For SCAN enabled RAC database, specify SCAN host as Host name.
connectString=example.amazonaws.com:1725:DVEIS1

##Set ORACLE_HOME##
ORACLE_HOME=/u01/oracle/products/fmw

#Prefix to be used for the schema. This is optional for non-prefixable components.
schemaPrefix=SOA3

#Domain (SOA, OSB, BAM) to be used for the components.
domain=soa

#List of components separated by comma. Remove the components which are not needed.

SOAcomponentList="-component MDS -component IAU -component IAU_APPEND -component IAU_VIEWER -component OPSS -component UCSUMS -component WLS -component STB -component ESS -component SOAINFRA"

OSBcomponentList="-component MDS -component IAU -component IAU_APPEND -component IAU_VIEWER -component OPSS -component UCSUMS -component WLS -component STB -component ESS -component SOAINFRA"

BAMcomponentList="-component MDS -component IAU -component IAU_APPEND -component IAU_VIEWER -component OPSS -component UCSUMS -component WLS -component STB -component ESS -component SOAINFRA"

#Database Type - [ORACLE|SQLSERVER|IBMDB2|EBR|MYSQL] - default is ORACLE
databaseType=ORACLE

#Database User
dbUser=awsdeis1
#dbUser=Test

#Database Role - sysdba or Normal
#dbRole=sysdba
dbRole=Normal

#Variable required for component SOAINFRA. Database Profile
SOA_PROFILE_TYPE=LARGE


#true | false - default is false. RCU will create datafiles using Oracle-Managed Files (OMF) naming format if value set to true.
honorOMF=true

#Variable required for component SOAINFRA. Healthcare Integration
HEALTHCARE_INTEGRATION=NO

#Specify whether dependent components of the given componentList have to be selected. true | false - default is false
#selectDependentsForComponents=false
selectDependentsForComponents=true

#If below property is set to true, then all the schemas specified will be set to the same password.
useSamePasswordForAllSchemaUsers=true




#############################################################################################################################
########     BELOW OPTIONS CAN BE CUSTOMIZED BASED ON OUR REQUIREMENTS #########
#############################################################################################################################


#This allows user to skip cleanup on failure. yes | no. Default is no.
#skipCleanupOnFailure=no

#This allows user to skip dropping of table spaces during cleanup on failure. yes | no. Default is no.
#skipTableSpaceDropOnFailure=no

#Yes | No - default is Yes. This is applicable only for database type - SQLSERVER.
#unicodeSupport=no

#Location of ComponentInfo xml file - optional.
#compInfoXMLLocation=

#Location of Storage xml file - optional
#storageXMLLocation=

#Tablespace name for the component. Tablespace should already exist if this option is used.
#tablespace=

#Temp tablespace name for the component. Temp Tablespace should already exist if this option is used.
#tempTablespace=

#Absolute path of Wallet directory. If wallet is not provided, passwords will be prompted.
#walletDir=

#true | false - default is false. RCU will create encrypted tablespace if TDE is enabled in the database.
#encryptTablespace=false


#This is applicable only for database type - EBR
#edition=

* * *

NOTE:


rcu.log


Log file will generate automatically (specified location)


passwordfile.txt 


database_password
component1_schema_password

No comments:

Post a Comment