Grid Control Agent 11gR1 Silent Install
Background & Overview
This script will install a Grid Control Agent version 11gR1 onto a server in silent mode. The script along with the additional_response.tmpl file must be placed on the server where the agent is being installed and must be in the same directory as the Grid Control Agent software. i.e. linux_x64.
A link to the additional_response.tmpl file can be found below.
Required Files
Script
#!/bin/ksh
############################################################################
#
# Script : install_agent.ksh
#
# Date : 15th July 2011
#
# Author : Mark Ramsay
#
# Description : Performs a silent install of the 11gR1 Grid
# Control Agent.
#
# Usage: For help run: ./install_agent.ksh -h
#
# Assumptions: The software is located in the <working directory>/linux_x64.
# MyOracle support notifications are not going to be used.
# The optional variables have been given some default values in this script.
# The additional_agent.tmpl is located in the same directory as this script.
# The domain of the proxy server is dmz.
# The production server hostnames begin with prod or end with prod and are 10 characters in length.
# The parameters SDS_std_loc and SDS_dmz_domain have been checked and varified.
#
# Exit Codes :
#
# Exit 98 - Software not located on the server
# Exit 97 - Invalid option
# Exit 96 - Proxy server not used. User initiated exit.
# Exit 95 - OMS and install server type mismatch. User initiated exit.
# Exit 94 - Non standard install location. User initiated exit.
# Exit 93 - User initiated exit at parameter display.
# Exit 92 - Edit of additional_agent.rsp failure.
# Exit 91 - Location for runInstaller not found.
# Exit 90 - Script working directory not found.
# Exit 89 - Agent failed to shutdown cleanly.
# Exit 88 - Script root.sh failed during execution.
# Exit 87 - Agent failed to start cleanly.
# Exit 86 - Invalid script option.
# Exit 85 - Option requires an argument.
# Exit 84 - The runInstaller command has failed.
#
#
# Parameters : None.
#
# History :
#
# Date Name Reason
# ---- ---- ------
# dd/mm/yy <Initials> <Description>
#
############################################################################
#
# Create any functions
#
errcheck() {
SDS_error=$?
if [[ $SDS_error = 0 && $SDS_usrerr = 0 ]]
then return
fi
case $1 in
98) echo "Error 98 - Software not located on the server."
exit 98;;
97) echo "Error 97 - Invalid option."
exit 97;;
96) echo "Error 96 - Proxy server not used. User initiated exit."
exit 96;;
95) echo "Error 95 - OMS and Install server type mismatch. User initiated exit."
exit 95;;
94) echo "Error 94 - Non standard install location. User initiated exit."
exit 94;;
93) echo "Error 93 - User initiated exit at parameter display."
exit 93;;
92) echo "Error 92 - Edit of additional_agent.rsp failure."
exit 92;;
91) echo "Error 91 - Location for runInstaller not found."
exit 91;;
90) echo "Error 90 - Script working directory not found."
exit 90;;
89) echo "Error 89 - Agent failed to shutdown cleanly."
exit 89;;
88) echo "Error 88 - Script root.sh failed during execution."
exit 88;;
87) echo "Error 87 - Agent failed to start cleanly."
exit 87;;
86) echo "$SDS_scriptname: invalid option -- Try -h for help"
exit 86;;
85) echo "$SDS_scriptname: option -$OPTARG requires an argument. Try -h for help."
exit 85;;
84) echo "Error 84 - The runInstaller command has failed."
exit 84;;
*) echo "Error 99 - Unknown Error"
exit 99;;
esac
exit 100
}
#
#Clear screen if tty
#
if [ -t -eq 0 ]; then clear; fi
#
# Set internal script parameters
#
SDS_scriptname=`basename $0`
SDS_pauseshort=1
SDS_pauselong=2
SDS_server=`hostname`
SDS_workingdir=`pwd`
SDS_software_loc=$SDS_workingdir/linux_x64
SDS_rsp_file_loc=$SDS_software_loc/response
SDS_runinstaller_loc=$SDS_software_loc/agent
SDS_error=0
SDS_usrerr=0
SDS_nosudo=FALSE
SDS_std_loc=/u01/app/oracle
SDS_dmz_domain=dmz
#
# Set optional parameters default values
#
PROXY_HOST=update_default_params_in_script
PROXY_PORT=update_default_params_in_script
AGENT_BASE_LOCATION=update_default_params_in_script
OMS_PORT=update_default_params_in_script
#
# Perform getopts loops
#
while getopts ":i:p:s:t:a:o:r:w:hdn" opt;
do
case $opt in
i) PROXY_ID=$OPTARG;;
p) PROXY_PWD=$OPTARG;;
s) PROXY_HOST=$OPTARG;;
t) PROXY_PORT=$OPTARG;;
a) AGENT_BASE_LOCATION=$OPTARG;;
o) OMS_HOST=$OPTARG;;
r) OMS_PORT=$OPTARG;;
w) AGENT_REGISTRATION_PASSWORD=$OPTARG;;
d) set -x;;
n) SDS_nosudo=TRUE;;
h) echo "Command line options for $SDS_scriptname"
echo ""
echo "Mandatory Parameters"
echo "-i <proxy user id>"
echo "-p <proxy password>"
echo "-o <oms host>"
echo "-w <agent registration password>"
echo ""
echo "Optional Parameters"
echo "-s <proxy host> -- Default: $PROXY_HOST"
echo "-t <proxy port> -- Default: $PROXY_PORT"
echo "-a <agent base location> -- Default: $AGENT_BASE_LOCATION"
echo "-r <oms port> -- Default: $OMS_PORT"
echo ""
echo "Misc"
echo "-d -- Switch debug on"
echo "-n -- Use if SUDO root is not available"
echo ""
exit 0;;
\?) SDS_usrerr=86
errcheck 86;;
:) SDS_usrerr=85
errcheck 85;;
esac
done
#
# Check software exists in the location specified by SDS_software_loc.
#
SDS_dummy=`ls -la $SDS_rsp_file_loc 2> /dev/null`
errcheck 98
#
# Check that mandatory parameters are set.
#
echo -e "Checking mandatory parameters are set........................ \c"
sleep $SDS_pauseshort
: ${PROXY_ID:?"Mandatory parameter -i not specified. Try -h for help"}
: ${PROXY_PWD:?"Mandatory parameter -p not specified. Try -h for help"}
: ${OMS_HOST:?"Mandatory parameter -o not specified. Try -h for help"}
: ${AGENT_REGISTRATION_PASSWORD:?"Mandatory parameter -w not specified. Try -h for help"}
echo "Passed."
sleep $SDS_pauselong
#
# Check for unusual values
#
echo ""
echo "Checking for unusual parameter settings..."
sleep $SDS_pauselong
echo ""
echo -e "Checking the domain of the proxy server...................... \c"
sleep $SDS_pauseshort
SDS_proxydomain=`echo $PROXY_HOST |awk -F\. '{print $2}'`
if [[ $SDS_proxydomain != "$SDS_dmz_domain" ]]
then echo "Failed."
sleep $SDS_pauseshort
echo ""
echo "The proxy specified does not appear to be in the DMZ domain of $SDS_dmz_domain"
echo ""
echo "Proxy: $PROXY_HOST"
echo "Domanin: $SDS_proxydomain"
echo ""
echo -e "Are you sure you want to use this proxy?(n) \c"
read yn
if [[ $yn = "y" || $yn = "Y" || $yn = "yes" || $yn = "YES" ]]
then echo "Reply equal to: $yn"
echo ""
echo ""
else echo "Reply equal to: $yn"
echo "Exiting..."
SDS_usrerr=96
errcheck 96
fi
else echo "Passed."
fi
sleep $SDS_pauseshort
echo -e "Checking oms server type matches the install server type..... \c"
sleep $SDS_pauseshort
SDS_servertype1=`echo $SDS_server |cut -c 1-4`
SDS_servertype2=`echo $SDS_server |cut -c 7-10`
SDS_server1=`echo $OMS_HOST |cut -c 1-4`
if [[ $SDS_servertype1 = "prod" || $SDS_servertype2 = "prod" ]]
then SDS_servertype='prod'
else SDS_servertype='dev'
fi
if [[ $SDS_server1 = "prod" ]]
then SDS_omstype='prod'
else SDS_omstype='dev'
fi
if [[ $SDS_servertype != $SDS_omstype ]]
then echo "Failed."
sleep $SDS_pauseshort
echo ""
echo "The OMS server specified appears to be a $SDS_omstype server,"
echo "but the install server appears not to be a $SDS_omstype server."
echo ""
echo "OMS Server: $OMS_HOST"
echo "Install Server: $SDS_server"
echo ""
echo -e "Are you sure you want to continue?(n) \c"
read yn
if [[ $yn = "y" || $yn = "Y" || $yn = "yes" || $yn = "YES" ]]
then echo "Reply equal to: $yn"
echo ""
echo ""
else echo "Reply equal to: $yn"
echo "Exiting..."
SDS_usrerr=95
errcheck 95
fi
else echo "Passed."
fi
sleep $SDS_pauseshort
echo -e "Checking the agent base location is set to the standard...... \c"
sleep $SDS_pauseshort
if [[ $AGENT_BASE_LOCATION != "$SDS_std_loc" ]]
then echo "Failed."
sleep $SDS_pauseshort
echo ""
echo "Agent base location set to $AGENT_BASE_LOCATION. The agent will be installed in..."
echo ""
echo "$AGENT_BASE_LOCATION/agent11g"
echo ""
echo "This is not the standard location for a Grid Control Agent."
echo ""
echo -e "Are you sure you want to install your agent here?(n) \c"
read yn
if [[ $yn = "y" || $yn = "Y" || $yn = "yes" || $yn = "YES" ]]
then echo "Reply equal to: $yn"
else echo "Reply equal to: $yn"
echo "Exiting..."
SDS_usrerr=94
errcheck 94
fi
else echo "Passed."
fi
echo ""
sleep $SDS_pauseshort
echo "Parameter checks complete."
echo ""
sleep $SDS_pauselong
#
# Display all set parameters before execution
#
echo ""
echo "Listing install parameters..."
sleep $SDS_pauselong
echo ""
echo "PROXY DETAILS"
sleep $SDS_pauselong
echo "Proxy host set to.................... $PROXY_HOST"
echo "Proxy port set to.................... $PROXY_PORT"
echo "Proxy id............................. $PROXY_ID"
echo "Proxy password set to................ $PROXY_PWD"
echo ""
sleep $SDS_pauselong
echo "OMS DETAILS"
sleep $SDS_pauseshort
echo "OMS host set to...................... $OMS_HOST"
echo "OMS port set to...................... $OMS_PORT"
echo ""
sleep $SDS_pauseshort
echo "AGENT DETAILS"
sleep $SDS_pauseshort
echo "Agent base location set to........... $AGENT_BASE_LOCATION"
echo "Agent registration password set to... $AGENT_REGISTRATION_PASSWORD"
echo ""
sleep $SDS_pauseshort
echo "MISCELLANEOUS"
sleep $SDS_pauseshort
echo "SUDO root disabled....................$SDS_nosudo"
echo ""
echo ""
sleep $SDS_pauselong
echo -e "Okay to continue?(n) \c"
read yn
if [[ $yn = "y" || $yn = "Y" || $yn = "yes" || $yn = "YES" ]]
then echo "Reply equal to: $yn"
echo ""
echo ""
else echo "Reply equal to: $yn"
echo "Exiting..."
SDS_usrerr=93
errcheck 93
fi
#
# Substitute SDS_ tags in additional_agent.tmpl with parameters.
#
# Note: A '?' has been used as the sed delimiter as the usual '/'
# delimiter is used in the variable $AGENT_BASE_LOCATION
#
cat additional_agent.tmpl |sed -e 's?SDS_proxyid?'$PROXY_ID'?' |sed -e 's?SDS_proxypass?'$PROXY_PWD'?' |sed -e 's?SDS_proxyhost?'$PROXY_HOST'?' |sed -e 's?SDS_proxyport?'$PROXY_PORT'?'|sed -e 's?SDS_agentbase?'$AGENT_BASE_LOCATION'?'|sed -e 's?SDS_omshost?'$OMS_HOST'?'|sed -e 's?SDS_omsport?'$OMS_PORT'?'|sed -e 's?SDS_omspassword?'$AGENT_REGISTRATION_PASSWORD'?' >$SDS_rsp_file_loc/additional_agent.rsp
errcheck 92
#
# Change directory to the runInstaller location.
#
cd $SDS_runinstaller_loc
errcheck 91
#
# Run the installer.
#
./runInstaller -silent -waitforcompletion -responseFile $SDS_rsp_file_loc/additional_agent.rsp
errcheck 84
#
# Change back to script PWD.
#
cd $SDS_workingdir
errcheck 90
#
# Shutdown the agent after successful install.
#
$AGENT_BASE_LOCATION/agent11g/bin/emctl stop agent
errcheck 89
#
# Check to see if SUDO is available
#
if [[ $SDS_nosudo = "TRUE" ]]
then echo ""
sleep $SDS_pauselong
echo "INFO: -n flag detected - No sudo root available."
echo ""
sleep $SDS_pauselong
echo "Install exiting..."
echo ""
echo "Get a UNIX administrator to run the following script to complete the install..."
echo ""
echo " $AGENT_BASE_LOCATION/agent11g/root.sh"
echo ""
echo "Once the script has been run, restart the agent and you're good to go!!"
echo ""
exit
fi
#
# Run root.sh for the agent.
#
sudo $AGENT_BASE_LOCATION/agent11g/root.sh
errcheck 88
#
# Restart agent after root.sh
#
$AGENT_BASE_LOCATION/agent11g/bin/emctl start agent
errcheck 87
#
# Exit script
#
echo ""
sleep $SDS_pauselong
echo "AGENT INSTALLED OKAY."
sleep $SDS_pauselong
echo ""
echo "JOB COMPLETE."
exit 0