OraMatt: YABAOracle

Yet Another Blog About Oracle

, ,

Import and Update Plug-ins with emcli – OEMCC 12c

Here’s a quick script to import downloaded plug-ins, if you are running in an off-line mode, into your OEMCC 12c system.

Tested with 12.1.0.3



#!/bin/bash
   #===============================================================================================================
   #                                                                                                                                              
   #         FILE: emcli_install_plugins.sh
   #
   #        USAGE: run it...requires a directory where the plugins are staged
   #
   #  DESCRIPTION:
   #      OPTIONS:  
   # REQUIREMENTS: 
   #       AUTHOR: Matt D - mattdee@gmail.com
   #      CREATED: 08.13.2013
   #      VERSION: 2.0
   #      EUL    :   THIS CODE IS OFFERED ON AN “AS-IS” BASIS AND NO WARRANTY, EITHER EXPRESSED OR IMPLIED, IS GIVEN. 
   #           THE AUTHOR EXPRESSLY DISCLAIMS ALL WARRANTIES OF ANY KIND, WHETHER EXPRESS OR IMPLIED.
   #           YOU ASSUME ALL RISK ASSOCIATED WITH THE QUALITY, PERFORMANCE, INSTALLATION AND USE OF THE SOFTWARE INCLUDING, 
   #           BUT NOT LIMITED TO, THE RISKS OF PROGRAM ERRORS, DAMAGE TO EQUIPMENT, LOSS OF DATA OR SOFTWARE PROGRAMS, 
   #           OR UNAVAILABILITY OR INTERRUPTION OF OPERATIONS. 
   #           YOU ARE SOLELY RESPONSIBLE FOR DETERMINING THE APPROPRIATENESS OF USE THE SOFTWARE AND ASSUME ALL RISKS ASSOCIATED WITH ITS USE.
   #
   #
   #
   #
   #
   #
   #===============================================================================================================




# Set the run timestamp
export RUNTIME=`date +%m_%d_%y_%H%M`
export RUNLOG=/tmp/emcli_install_plugins.${RUNTIME}.log


function test_oem_home()
{
 if test "${OEM_HOME+set}" != set 
 	then
        echo "OEM_HOME is not set"
        echo "Please enter the path to your OEM_HOME"
        read OEM_HOME      
    else
        echo "---------------------------------------"
        echo "OEM_HOME is set to ${OEM_HOME}"
    fi

	export PATH=$PATH:$OEM_HOME/bin
	# Test to make sure emcli is in the path
	if [ -z `which emcli` ]
   		then echo "emcli is not in path."
   			echo "Exiting!"
   			exit 1
		else echo "Found it"
	fi

}


function import_plugins()
{
	test_oem_home
	# Ask for the directory containing the plugin files
	echo "Please enter the path to the plugin files"
	read  PLUGINDIR

	if [ -d $PLUGINDIR ]
		then
			# Import the Plugins
			echo "Please enter SYSMAN's password"
			read SYSMANPASS
			echo "Attempting to import plugsin at ${RUNTIME}"     						| tee >>$RUNLOG
			echo "##########################################"     						| tee >>$RUNLOG
			emcli logout; emcli login -username=sysman -password=${SYSMANPASS}  		| tee >>$RUNLOG
			emcli sync                                            						| tee >>$RUNLOG

				for i in $PLUGINDIR/*
				do 
				   emcli import_update -omslocal -file=$i             					| tee >>$RUNLOG
				done
		else 
		   echo "You did not enter a valid directory location"
		   echo "Quitting"
		   exit 1
	fi


}


function active_plugins()
{
	test_oem_home
	#Ask for the sys password for the OEM DB
	echo "Please enter the password for sys user: "
	read SYSPASS


	# Get a list of plugins on the server to active & active
	emcli list_plugins_on_server | tee >/tmp/pluginlist  
		for i in `sed 's/\ oracle./\:oracle./g' /tmp/pluginlist | cut -d: -f2- | awk '{print $1":"$2}' | grep oracle`
		do 
		   emcli deploy_plugin_on_server -sys_password=${SYSPASS} -plugin="${i}"       | tee >>$RUNLOG
		done
}


function plugin_status()
{
	test_oem_home
	for i in `sed 's/\ oracle./\:oracle./g' /tmp/pluginlist | cut -d: -f2- | awk '{print $1}'`
	do
		emcli get_plugin_deployment_status -plugin_id="${i}"							| tee >>$RUNLOG				
	done

}


function Do_All()
{
	import_plugins
	active_plugins
	plugin_status

}

function QUIT()
{
	exit 1
}

function show_runlog()
{
	echo "Here's the log for this seesion: "
	echo "#########################################################"
     more ${RUNLOG}
}


function start_up()
{
    clear screen
    echo "#########################################################"
    echo "# This will import & active plugins on the OEM Server   #"
    echo "#########################################################"
 
    echo
    echo
    echo
 
    echo "################################################"
    echo "#                                              #"
    echo "#          What would you like to do ?         #"
    echo "#                                              #"
    echo "#          1 ==   Import Plugins               #"
    echo "#                                              #"
    echo "#          2 ==   Active Plugins               #"
    echo "#                                              #"
    echo "#          3 ==   Check Plugins Status         #"
    echo "#                                              #"
    echo "#          4 ==   Do EVERYTHING                #"
    echo "#                                              #"
    echo "#          5 ==   QUIT!                        #"
    echo "#                                              #"
    echo "################################################"
    echo
    echo "Please enter in your choice:> "
    read whatwhat
     
}
 


 function work_time()
{
start_up
case $whatwhat in
    1) import_plugins
        ;;  
    2) active_plugins
        ;;  
    3) plugin_status
        ;;
    4) Do_All
        ;;
    5) QUIT
        ;;
esac
}



# Let's go to work
#clear screen
work_time
show_runlog




2 responses to “Import and Update Plug-ins with emcli – OEMCC 12c”

  1. cheney wa Avatar

    Your style is very unique compared to other people I have read stuff from.
    Many thanks for posting when you’ve got the opportunity,
    Guess I’ll just book mark this page.

  2. venu Avatar

    awesome note.. thanks for sharing !

Leave a comment

Navigation

About

I’m Matt and I do Oracle things.