Skip to content

Instantly share code, notes, and snippets.

@mtcoffee
Created August 27, 2016 17:55
Show Gist options
  • Save mtcoffee/b982517c76f85d6eaead7b0ce019f8ad to your computer and use it in GitHub Desktop.
Save mtcoffee/b982517c76f85d6eaead7b0ce019f8ad to your computer and use it in GitHub Desktop.
CreateAPPServerDomain
#!/bin/bash
#This script will quickly create a new Linux/Unix PeopleSoft appserver domain and perform some checks
#IMPORT INFORMATION
#1. YOU MUST SET THE PS_HOME PS_CFG_HOME PS_APP_HOME and PS_CUST_HOME VARIABLES BEFORE RUNNING THIS SCRIPT
#2. YOU MUST ALSO HAVE A CUSTOM TEMPLATE SAVED UNDER $PS_HOME/appserv/small_custom.cfx
# THE TEMPLATE CAN BE CREATED BY COPYING THE DELIVERED TEMPLATE $PS_HOME/appserv/prcs/small.cfx
#3. THE SECTION AFTER "POST DOMAIN CREATION CHECKS" IS OPTIONAL AND CAN BE EASILY CUSTOMIZED OR EXCLUDED.
#4. lsof is required for the port checks at bottom. Install with package manager. (sudo yum install lsof)
#Known to work with PeopleTools 8.54 and 8.55.
############################
##variables required for creation of appserver domain
ENVIRONMENT=dbname
NEW_DOMAIN=mydomain
ADDTOPATH="."
DBPASS=peop1e
DBUSER=people
OPRIDPASS=PS
OPRIDUSER=PS
PORT_JRAD=9100
PORT_JSL=9000
PORT_WSL=7000
PUBSUB=Yes
WSL=No
DOM_CONN_PWD=_____
#Check if variables are set and point to valid paths
PATHSTOCHECK=(PS_HOME PS_CFG_HOME PS_APP_HOME PS_CUST_HOME)
for i in ${PATHSTOCHECK[*]}; do
if [ -n "${!i}" ] && [ -d "${!i}" ]; then
echo "$i path ${!i} does exist"
else
echo "########################################"
echo "$i path ${!i} does not exist or variable is not set This needs to be corrected first."; exit 1
fi
done;
#Check for custom cfx file
if test -f "$PS_HOME/appserv/small_custom.cfx"; then
echo "$PS_HOME/appserv/small_custom.cfx found and will be used as template for the new domain"
else
echo "########################################"
echo "$PS_HOME/appserv/small_custom.cfx not found. This needs to be corrected first."; exit 1
fi
#Confirm domain name not already in use
if test ! -d "$PS_CFG_HOME/appserv/$NEW_DOMAIN"; then
echo "$PS_CFG_HOME/appserv/$NEW_DOMAIN not already in use and will be the path/name for the new domain"
else
echo "########################################"
echo "$PS_CFG_HOME/appserv/$NEW_DOMAIN already exists. Either rename the existing domain or change the name to be used."; exit 1
fi
#Show version of PeopleTools Home that domain will be created for.
echo "########################################"
grep -i "productversion" "$PS_HOME/peopletools.properties"
echo "The new domain will be created for PeopleTools version shown above".
echo "In 10 seconds the create will start. Type CTRL-C to stop this job."
sleep 10s
echo ""
echo "CREATING NEW APPLICATION SERVER DOMAIN $NEW_DOMAIN FOR DATABASE $ENVIRONMENT"
#Example of command http://docs.oracle.com/cd/E58500_01/pt854pbh1/eng/pt/tsvt/task_UsingthePSADMINCommand-LineInterface-c07e70.html
#psadmin -c create -d domain -t template -s s_set [-p p_set] (settings list->) DBNAME%DBTYPE%OPR_ID%OPR_PSWD%DOMAIN_ID%ADD_TO_PATH%DB_CNCT_ID%DB_CNCT_PSWD%SERVER_NAME%DOM_CONN_PWD%{ENCRYPT|NOENCRYPT} [-env env_set] [-s silent] to create appserver
psadmin -c create -d $NEW_DOMAIN -t small_custom -s $ENVIRONMENT%ORACLE%$OPRIDUSER%$OPRIDPASS%$NEW_DOMAIN%$ADDTOPATH%$DBUSER%$DBPASS%_____%$DOM_CONN_PWD%ENCRYPT -p $PORT_WSL%$PORT_JSL%$PORT_JRAD
echo ""
echo "########################################"
echo "CONFIGURING NEW APPLICATION SERVER DOMAIN $NEW_DOMAIN WITH SELECTED FEATURES"
psadmin -c configure -d $NEW_DOMAIN -u {PUBSUB}=$PUBSUB%{QUICKSRV}=N%{QUERYSRV}=N%{JOLT}=Yes%{JRAD}=N%{WSL}=$WSL%{DBGSRV}=N%{RENSRV}=No%{MCF}=No%{PPM}=N%{ANALYTICSRV}=No%{DOMAIN_GW}=N%{SERVER_EVENTS}=No
##################POST DOMAIN CREATION CHECKS########################
#Checking configuration after the domain creation
echo ""
echo "########################################"
echo "NOW RUNNING POST DOMAIN CREATION CHECK"
#Checking cfg variables
cfg_variables=(
"DbFlags=8"
"Allow Dynamic Changes=Y"
#Full line required is RCCBL PRDBIN=%PS_CUST_HOME%\cblbin%PS_COBOLTYPE%:%PS_APP_HOME%\cblbin%PS_COBOLTYPE%:%PS_HOME%\cblbin%PS_COBOLTYPE% but we'll just test for the custom variable
"RCCBL PRDBIN=%PS_CUST_HOME%"
"Add to CLASSPATH=%PS_CUST_HOME%/class"
#SMTPSender is modified to work with grep and wildcards
"SMTPSender=.*\domain.com"
)
for i in "${cfg_variables[@]}"; do
echo "Checking" $i
if grep -iq "$i" "$PS_CFG_HOME/appserv/$NEW_DOMAIN/psappsrv.cfg" ; then
echo "CFG value $i is set as expected"
else
echo "##################################"
echo "Domain has been created but CFG value $i needs fixing. IT IS RECOMENDED TO UPDATE THE CFX TEMPLATE FILE, DELETE THIS DOMAIN AND RE-CREATE IT."
echo "##################################"
fi
done;
#Checking environment variables
env_variables=(
"COBPATH=%PS_CUST_HOME%/cblbin:%PS_APP_HOME%/cblbin:%PS_HOME%/cblbin"
)
for i in "${env_variables[@]}"; do
echo "Checking" $i
if grep -iq "$i" "$PS_CFG_HOME/appserv/$NEW_DOMAIN/psappsrv.env" ; then
echo "Variable $i is set as expected"
else
echo "##################################"
echo "Domain has been created but variable $i needs fixing. THIS CAN BE SET IN THE UBX FILE, DO NOT UPDATE THE ENV FILE AS IT WILL GET OVERWRITTEN."
echo "##################################"
fi
done;
#Check status of ports selected
port_list=(
"$PORT_JSL"
"$PORT_WSL"
"$PORT_JRAD"
)
echo ""
echo "#######Checking if WSL/JSL/JRAD ports are already in use############"
for i in "${port_list[@]}"; do
if ! /usr/sbin/lsof -Pi :$i -sTCP:LISTEN -t >/dev/null ; then
echo "TCP "$i" is free, good."
else
echo "TCP "$i" is occupied. PLEASE CHANGE THIS PORT BEFORE STARTING THE APPSERVER OR...."
echo "IF YOU ARE REPLACING AN APPSERVER BE SURE TO SHUT THE OLD ONE DOWN FIRST."
fi
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment