#!/bin/bash
#ident "%W%"
printMessage() {
echo -e "\n************************************************************"
echo -e "$1"
echo -e "$1" >> ${LOG_DIR}/${LOG_FILE}
}
printMessage2() {
echo -e "$1"
echo -e "$1" >> ${LOG_DIR}/${LOG_FILE}
}
jumpToRootDir () {
cd $BUILD_DIR/riskciti/oprisk
}
jumpToPkgDir () {
cd $BUILD_DIR/riskciti/oprisk/pkg
}
jumpToBuildDir () {
cd $BUILD_DIR
}
cleanPackage() {
printMessage "Cleaning files/dirs not needed for packaging "
removeSVNDirectories
removeAbsoliteDirs
removeEmptyDirs
removeOtherMakeFile
}
removeOtherMakeFile() {
jumpToRootDir
}
removeEmptyDirs () {
printMessage2 "Removing empty directories "
}
removeAbsoliteDirs () {
printMessage2 "Removing directories we do not require under riskciti/oprisk"
jumpToRootDir
if [[ -d ./DB ]]
then
printMessage2 "removing DB"
\rm -fr ./DB
fi
if [[ -d ./env ]]
then
printMessage2 "removing env"
cp ./env/oprisk.xenv .
cp ./env/opr_setup.ksh .
\rm -fr ./env/*
mv ./opr_setup.ksh ./env/.
chmod +x ./env/opr_setup.ksh
fi
if [[ -f ./etc/tnsnames.txt ]]
then
\rm ./etc/tnsnames.txt
fi
if [[ -d ./pkg/common ]]
then
printMessage2 "removing pkg/common"
\rm -fr ./pkg/common
fi
if [[ -d ./pkg/edcs ]]
then
printMessage2 "removing pkg/edcs"
\rm -fr ./pkg/edcs
fi
if [[ -d ./pkg/rcsa ]]
then
printMessage2 "removing pkg/rcsa"
\rm -fr ./pkg/rcsa
fi
if [[ -d ./scripts ]]
then
printMessage2 "removing scripts"
\rm -fr ./scripts
fi
if [[ -d ./sminfoagent ]]
then
printMessage2 "removing sminfoagent"
\rm -fr ./sminfoagent
fi
if [[ -f ./user_projects/domains/opriskDomain/oprconfig ]]
then
\rm ./user_projects/domains/opriskDomain/oprconfig
fi
\rm user_projects/domains/opriskDomain/keystores/*.jks
if [[ -d ./tools ]]
then
printMessage2 "removing tools"
\rm -fr ./tools
fi
if [[ -d ./install ]]
then
printMessage2 "removing install"
\rm -fr ./install
fi
if [[ -d ./weblogic ]]
then
printMessage2 "removing weblogic"
\rm -fr ./weblogic
fi
if [[ -d ./src/Hierarchy/webcontent/WEB-INF/lib ]]
then
printMessage2 "removing src/Hierarchy/webcontent/WEB-INF/lib"
\rm -fr ./src/Hierarchy/webcontent/WEB-INF/lib
fi
if [[ -d ./src/lib ]]
then
printMessage2 "removing src/lib"
\rm -fr ./src/lib
fi
if [[ -d ./src/Hierarchy_Popup/compile_required_libs ]]
then
printMessage2 "removing src/Hierarchy_Popup/compile_required_libs"
\rm -fr ./src/Hierarchy_Popup/compile_required_libs
fi
if [[ -d ./src/LEO_WFL/WEB-INF/lib ]]
then
printMessage2 "removing src/LEO_WFL/WEB-INF/lib"
\rm -fr ./src/LEO_WFL/WEB-INF/lib
fi
if [[ -d ./src/LEO/WEB-INF/lib ]]
then
printMessage2 "removing src/LEO/WEB-INF/lib"
\rm -fr ./src/LEO/WEB-INF/lib
fi
if [[ -d ./LEO_WFL_POC ]]
then
printMessage2 "removing LEO_WFL_POC"
\rm -fr ./LEO_WFL_POC
fi
if [[ -d ./src/LEO/DDL ]]
then
printMessage2 "removing src/LEO/DDL"
\rm -fr ./src/LEO/DDL
fi
if [[ -f ./src/util/src/com/citigroup/oprisk/entitlement/url/Makefile ]]
then
\rm ./src/util/src/com/citigroup/oprisk/entitlement/url/Makefile
fi
if [[ -f ./src/Hierarchy_Popup/src/com/citi/oprisk/hierarchy/public/js/resources/images/gray/window/left-corners.pspimage ]]
then
\rm ./src/Hierarchy_Popup/src/com/citi/oprisk/hierarchy/public/js/resources/images/gray/window/left-corners.pspimage
fi
if [[ -f ./src/Hierarchy_Popup/src/com/citi/oprisk/hierarchy/public/js/resources/resources.jsb ]]
then
\rm ./src/Hierarchy_Popup/src/com/citi/oprisk/hierarchy/public/js/resources/resources.jsb
fi
if [[ -f ./src/LEO/gwtext/maker/src/public/EOLcity.json ]]
then
\rm ./src/LEO/gwtext/maker/src/public/EOLcity.json
fi
if [[ -f ./src/ama/webcontent/js/ext-2.0.2/resources/images/gray/window/left-corners.pspimage ]]
then
\rm ./src/ama/webcontent/js/ext-2.0.2/resources/images/gray/window/left-corners.pspimage
fi
if [[ -f ./entitlement/gwtext/entitlementinfo/public/js/resources/images/oprisk/delete_icon.png ]]
then
\rm ./entitlement/gwtext/entitlementinfo/public/js/resources/images/oprisk/delete_icon.png
fi
if [[ -f ./entitlement/gwtext/entitlementinfo/public/js/resources/images/oprisk/edit_icon.gif ]]
then
\rm ./entitlement/gwtext/entitlementinfo/public/js/resources/images/oprisk/edit_icon.gif
fi
if [[ -f ./src/fileupload/web/images/ico-hierarchy.gif.1 ]]
then
\rm ./src/fileupload/web/images/ico-hierarchy.gif.1
fi
if [[ -f ./src/fileupload/web/images/b_button-convert.gif.svntmp ]]
then
\rm ./src/fileupload/web/images/b_button-convert.gif.svntmp
fi
if [[ -f ./src/commonv2/eers/com/ssmb/oprisk/eers/Makefile ]]
then
\rm ./src/commonv2/eers/com/ssmb/oprisk/eers/Makefile
fi
find $BUILD_DIR/riskciti -name 'Thumbs.db' -exec \rm -fr {} \; -print
find $BUILD_DIR/riskciti/oprisk/src/LEO/test/sp -name '*.prc' -exec \rm -fr {} \; -print
find $BUILD_DIR/riskciti/oprisk/src/LEO/test/sp -name '*.sql' -exec \rm -fr {} \; -print
find $BUILD_DIR/riskciti/oprisk/src/fileupload/src/com/ssmb/oprisk -name 'Makefile' -exec \rm -fr {} \; -print
find $BUILD_DIR/riskciti/oprisk/src/rcsa/web -name 'Makefile' -exec \rm -fr {} \; -print
}
removeSVNDirectories () {
printMessage "Removing SVN directories"
find $BUILD_DIR/riskciti -name '.svn' -exec \rm -fr {} \; -print
if [ $DELETE_EXISTING_BUILD = "y" ]
then
find $BUILD_DIR -name '*.class' -exec \rm -fr {} \; -print
fi
printMessage2 "Removing other junk files "
find $BUILD_DIR -name '*.log' -exec \rm -f {} \; -print
find $BUILD_DIR -name '*.bak' -exec \rm -f {} \; -print
find $BUILD_DIR -name '*.ldift' -exec \rm -f {} \; -print
find $BUILD_DIR -name '*.xml1' -exec \rm -f {} \; -print
find $BUILD_DIR -name '*.xml_dev' -exec \rm -fr {} \; -print
find $BUILD_DIR -name '*.iws' -exec \rm -f {} \; -print
find $BUILD_DIR -name '*.ipr' -exec \rm -f {} \; -print
find $BUILD_DIR -name '*.iml' -exec \rm -f {} \; -print
find $BUILD_DIR -name '*.orig*' -exec \rm -f {} \; -print
find $BUILD_DIR -name '*.*~' -exec \rm -f {} \; -print
}
removeExistingBuildDir () {
ARCH_DIRNAME=$BUILD_DIR"_"$BUILD_DATE"."$$
if [ -d $BUILD_DIR ]
then
if [ "$1" = "" ]
then
getResponse "Build dir $BUILD_DIR exists. Would like to remove it? "
DELETE_EXISTING_BUILD=$RESPONSE
if [[ "$DELETE_EXISTING_BUILD" = [Nn]* ]]
then
getResponse "Build dir $BUILD_DIR exists. \nWould like to move it to name $ARCH_DIRNAME ? "
ARCHIVE_EXISTING_BUILD=$RESPONSE
fi
else
printMessage2 "Removing existing build directory: $BUILD_DIR "
DELETE_EXISTING_BUILD="y"
fi
if [[ $DELETE_EXISTING_BUILD = "y" ]]
then
\rm -fr $BUILD_DIR
elif [[ "$ARCHIVE_EXISTING_BUILD" = [Yy]* ]]
then
cd /tmp
printMessage2 "Moving directory to $ARCH_DIRNAME"
mv $BUILD_DIR $ARCH_DIRNAME
else
printMessage2 "Please make up your mind ..."
exit 1
fi
fi
}
removeOldTarFile() {
printMessage2 "Removing old tar files"
jumpToRootDir
if [[ -f $BUILD_DIR/riskciti/$PKG_NAME.tar ]]
then
printMessage "Removing existing tar file"
\rm -f $BUILD_DIR/riskciti/$PKG_NAME.tar
elif [[ -f $BUILD_DIR/riskciti/$PKG_NAME.tar.Z ]]
then
printMessage "Removing existing tar file"
\rm -f $BUILD_DIR/riskciti/$PKG_NAME.tar.Z
fi
}
removeTempFiles () {
printMessage "Removing temp files"
\rm -f /tmp/send_to_hermes*
\rm -f /tmp/tar_file_names*
}
makeLogDirectory() {
if [ ! -d $LOG_DIR ]
then
mkdir ${LOG_DIR}
fi
touch ${LOG_DIR}/${LOG_FILE}
printMessage "For status, please view log file ${LOG_DIR}/${LOG_FILE} "
}
makeBuildDirectory () {
removeExistingBuildDir "$*"
if [[ ! -d $BUILD_DIR ]]
then
printMessage "Creating build dir "
mkdir -p $BUILD_DIR
if [ $? -eq 1 ]
then
printMessage ""
printMessage "Error. Failed to create build dir $BUILD_DIR . exiting"
printMessage ":( "
exit 1
fi
fi
}
makeDDLBuildDirectory () {
if [[ ! -d $BUILD_DIR ]]
then
printMessage "Creating build dir "
mkdir -p $BUILD_DIR
if [ $? -eq 1 ]
then
printMessage ""
printMessage "Error. Failed to create build dir $BUILD_DIR . exiting"
printMessage ":( "
exit 1
fi
fi
}
createTarFile() {
printMessage "Taring package source tree "
if [[ "$SVN_TAG_NAME" = "" ]]
then
export PKG_NAME=$CURRUSER"_"$1"_NOTAG"
else
export PKG_NAME=$CURRUSER"_"$1"_"$SVN_TAG_NAME
fi
removeOldTarFile
tar -cvf $BUILD_DIR/riskciti/$PKG_NAME.tar .
}
runPkgAudit() {
if [[ "$SRC_AUDIT_CONFIRM" = [Yy]* ]]
then
printMessage2 "Performig package src audit with /xenv/scripts/bin/paudit_src_5"
/xenv/scripts/bin/paudit_src_5 $BUILD_DIR/riskciti/oprisk > $PADUIT_LOG
result=$?
printMessage2 "Paudit result $result"
if [ $result -ne 0 ]
then
printMessage "Error. paudit_sr failed. exiting. Look at the file $PADUIT_LOG for more info"
printMessage2 ":("
sendFailedAuditEmail
exit 1
fi
fi
if [[ -f $PADUIT_LOG ]]
then
\rm $PADUIT_LOG
fi
}
evaluateEnv() {
jumpToRootDir
sed -e 's?__DEPLOY_PKG_NAME__?'"$DEPLOY_PKG_NAME"'?g' ./rpm/SPECS/all-in-one.spec > ./rpm/SPECS/final_all-in-one.spec
rm -rf ./rpm/SPECS/all-in-one.spec
mv ./rpm/SPECS/final_all-in-one.spec ./rpm/SPECS/all-in-one.spec
sed -e 's?__DEPLOY_PKG_NAME__?'"$DEPLOY_PKG_NAME"'?g' ./scriptspkg/Makefile > ./scriptspkg/final_Makefile
rm -rf ./scriptspkg/Makefile
mv ./scriptspkg/final_Makefile ./scriptspkg/Makefile
}
runTestMake() {
if [[ "$BUILD_PKG_CONFIRM" = [Yy] ]]
then
printMessage "Building the package oprisk"
if [[ "$ENV_SET_FLAG" = "n" ]]
then
setXEnvironment
export ENV_SET_FLAG="y"
echo $ENV_SET_FLAG
fi
#chmod 755 $ROOT/rpm/scripts/request.sh
#sh $ROOT/rpm/scripts/request.sh $ROOT/target.env
#chmod 755 $ROOT/target.env
#cp $ROOT/target.env $ROOT/scriptspkg/newetc/target.env
#chmod 755 $ROOT/rpm/scripts/evaluateEnv.sh
#$ROOT/rpm/scripts/evaluateEnv.sh
#export CLASSPATH=$CLASSPATH:/xenv/oracleclient/X/11.1.0.7_RHAS64/jdbc/lib/ojdbc6.jar:/xenv/oracleclient/X/11.1.0.7_RHAS64/jlib/orai18n.jar:/xenv/WebsphereApplicationServer/X/7.0.0.21/WASHOME/dev/was_public.jar:/xenv/WebsphereApplicationServer/X/7.0.0.21/WASHOME/lib/j2ee.jar:/xenv/WebsphereApplicationServer/X/7.0.0.21/WASHOME/plugins/com.ibm.ws.runtime.jar:/xenv/WebsphereApplicationServer/X/7.0.0.21/WASHOME/runtimes/com.ibm.ws.sib.client.thin.jms_7.0.0.jar:/xenv/quartz/X/1.5.2/quartz-all-1.5.2.jar
make -f oprisk.mk package
if [ $? -gt 0 ]
then
printMessage " Error. make install failed "
printMessage2 ":("
exit 1
fi
jumpToRootDir
## move dstream one level up
mv *rpm* ../.
fi
}
sendTarFilesToHermes () {
removeTempFiles
if [[ "$SEND_TO_HERMES_CONFIRM" = "y" || "$SEND_TO_HERMES_CONFIRM" = "Y" ]]
then
printMessage "Sending tar file to HERMES "
pwd
cd ..
pwd
for i in `ls *.tar`
do
# send package to hermes
/xenv/scripts/bin/send_to_hermes $i >> $SENT_TO_HERMES_TEMP
if [ $? -eq 1 ]
then
printMessage "Error. failed to send file $i to hermes. exiting. "
printMessage ":("
exit 1
fi
done
printMessage2 "Sent following file(s) to Hermes:"
printMessage2 "`cat $SENT_TO_HERMES_TEMP | grep -v 'Sending' | grep -v 'New' | grep -v '-' | grep '.tar'`"
printMessage2 "Success. Go ahead and submit the job to Hermes"
printMessage2 ":)"
else
getTarFileNames
fi
}
setXEnvironment () {
printMessage "Setting / entering XENV "
jumpToRootDir
printMessage2 "Copying env file to `pwd`"
sed -e "s?exec \${XSH}??" /xenv/xenv.linux > /tmp/txenv
chmod +x /tmp/txenv
. /tmp/txenv -i $BUILD_DIR/riskciti/oprisk/oprisk.xenv .
}
setVariables() {
jumpToRootDir
. ./env/opr_setup.ksh
export ENV=./env/opr_setup.ksh
}
getSVNTree(){
TMPTREE=""
while [ -z "${TMPTREE}" ]
do
printMessage "Please specify SVN tree for this build:
Available options:
1 - branches
2 - tags
3 - trunk
Selected SVN tree(default:1 - branches):\c"
read TMPTREE
case "${TMPTREE:=branches}" in
"1" |"branches")
TMPTREE="branches" ;;
"2" |"tags")
TMPTREE="tags" ;;
"3" |"trunk")
TMPTREE="trunk" ;;
*)
printMessage2 "*** $TMPTREE: invalid response, please use the option letter or action keyword."
TMPTREE=""
;;
esac
done
printMessage2 "SVN tree set to: ${TMPTREE}"
export SVNTREE=$TMPTREE
}
getSvnTag(){
SVNTAG=""
while [ -z "${SVNTAG}" ]
do
printMessage "Please specify SVN tag/branch name for this build: \c"
read SVNTAG
echo
getResponse "Entered tag/branch name is: '$SVNTAG'. Would like to continue? "
r=$RESPONSE
if [[ "$r" = [Nn]* ]]
then
SVNTAG=""
else
break
fi
done
export SVN_TAG_NAME=$SVNTAG
}
checkFileOutFromSVN() {
jumpToBuildDir
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/xenv/svn-c/X/1.6.6l_64/lib:/xenv/svn-c/X/1.6.6l_64/lib:/xenv/svn-c/X/1.6.6l_64/lib/apr-util-1:/xenv/svn-c/X/1.6.6l_64/lib/engines:/xenv/svn-c/X/1.6.6l_64/lib/sasl2:/xenv/svn-c/X/1.6.6l_64/modules
export PATH=$PATH:/xenv/svn-c/X/1.6.6l_64/bin:/xenv/C/ia64/3.4.4/RH4.0AS_U2/usr/bin:/xenv/OS/ia64/RH4.0AS_U2/x86_64/bin:/xenv/OS/ia64/RH4.0AS_U2/x86_64/usr/bin
if [ "$SVN_TAG_NAME" != "" ]
then
printMessage "Checking out from $SVN_TAG_NAME"
svn co $SVNPREFIX$SVNROOT/$SVNTREE/$SVN_TAG_NAME riskciti/oprisk
else
svn co $SVNPREFIX$SVNROOT/trunk/oprisk_new_code_base/oprisk riskciti/oprisk
fi
if [ $? -eq 1 ]
then
printMessage "Error. Failed to checkout dir $BUILD_DIR . exiting"
printMessage2 ":("
exit 1
fi
printMessage "Checking out done ..."
}
checkDDLFileOutFromSVN() {
jumpToBuildDir
rm -rf *
if [[ ! -d $BUILD_DIR/OpRisk ]]
then
mkdir OpRisk
fi
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/xenv/svn-c/X/1.6.6l_64/lib:/xenv/svn-c/X/1.6.6l_64/lib:/xenv/svn-c/X/1.6.6l_64/lib/apr-util-1:/xenv/svn-c/X/1.6.6l_64/lib/engines:/xenv/svn-c/X/1.6.6l_64/lib/sasl2:/xenv/svn-c/X/1.6.6l_64/modules
export PATH=$PATH:/xenv/svn-c/X/1.6.6l_64/bin:/xenv/C/ia64/3.4.4/RH4.0AS_U2/usr/bin:/xenv/OS/ia64/RH4.0AS_U2/x86_64/bin:/xenv/OS/ia64/RH4.0AS_U2/x86_64/usr/bin
if [ "$SVN_TAG_NAME" != "" ]
then
printMessage "Checking out from $SVN_TAG_NAME"
svn co $SVNPREFIX$SVNROOT/$SVNTREE/$SVN_TAG_NAME/OpRisk $BUILD_DIR/OpRisk
if [ $? -ne 0 ]
then
printMessage "Error. Failed to checkout dir $BUILD_DIR . exiting"
printMessage2 ":("
exit 1
fi
fi
printMessage "Checking out done ..."
}
getResponse () {
msg=$1
RESPONSE=""
printMessage "$msg <y/n> "
while [ -z "${RESPONSE}" ]
do
read resp
if [[ ${resp} = [Yy]* ]]
then
RESPONSE="y"
break
elif [[ ${resp} = [Nn]* ]]
then
RESPONSE="n"
break
else
printMessage2 "Unknown response ${resp}. Setting to <n> "
RESPONSE="n"
break
fi
done
printMessage2 "$RESPONSE"
export RESPONSE
}
#************************************************************
#
#params: Email
#
#************************************************************
emailConfirmation(){
MAIL_FLAG=""
DEFAULT_MAIL_FLAG="n"
getResponse "Would you like receive an email notification? "
export MAIL_FLAG=$RESPONSE
MAIL_FLAG=${MAIL_FLAG:=${DEFAULT_MAIL_FLAG}}
if [ "$MAIL_FLAG" = "y" ]
then
MAIL_FLAG=""
DEFAULT_MAIL_FLAG="n"
if [[ -f $EMAIL_FILE ]]
then
printMessage2 "Follwing email address already stored in /tmp"
EMAIL_ADDR=`cat $EMAIL_FILE`
printMessage2 "Stored email address string = $EMAIL_ADDR"
EMAIL_ADDR_VALUE=$EMAIL_ADDR
printMessage2 "Would you like to change it [y /n] <default: n> : \c\n"
read MAIL_FLAG
MAIL_FLAG=${MAIL_FLAG:=${DEFAULT_MAIL_FLAG}}
if [ "$MAIL_FLAG" != "n" ]
then
DEFAULT_MAIL_FLAG=""
printMessage2 "Please enter updated email address... : \c\n"
read MAIL_FLAG
MAIL_FLAG=${MAIL_FLAG:=${DEFAULT_MAIL_FLAG}}
if [ "$MAIL_FLAG" != "" ]
then
EMAIL_ADDR_VALUE="$MAIL_FLAG"
touch $EMAIL_FILE
printMessage2 "$EMAIL_ADDR_VALUE" > $EMAIL_FILE
else
printMessage2 "EMail address is invalid... Setting email confirnmation to false"
fi
fi
else
DEFAULT_MAIL_FLAG=""
printMessage2 "Please enter your email address... : \c\n"
read MAIL_FLAG
MAIL_FLAG=${MAIL_FLAG:=${DEFAULT_MAIL_FLAG}}
if [ "$MAIL_FLAG" != "" ]
then
EMAIL_ADDR_VALUE="$MAIL_FLAG"
touch $EMAIL_FILE
printMessage2 "$EMAIL_ADDR_VALUE" > $EMAIL_FILE
fi
fi
fi
export EMAIL_ADDR_VALUE
echo $EMAIL_ADDR_VALUE
}
verifyEnteredParameters () {
generateSVNOptionsStatusMsg
getResponse "Here are entered options
$OPTIONS_STATUS_MSG
Would you like to continue? "
export OPTIONS_CONFIRM=$RESPONSE
}
sendStartedEmailNotification () {
if [[ "$EMAIL_ADDR_VALUE" != "" ]]
then
EMAIL_ADDR=`cat $EMAIL_FILE`
HEADER_PART=""
if [[ "$DEPLOY_PKG_NAME" = "all" ]]
then
HEADER_PART="packages oprisk3 - oprisk5"
else
HEADER_PART="$DEPLOY_PKG_NAME package"
fi
generateSVNOptionsStatusMsg
/bin/mail -s "[$CURRUSER@$CURRSERVER] Daily build is started for $HEADER_PART ($BUILD_IDN)" $EMAIL_ADDR_VALUE << EOF!
*** Build is started.
Started at: $START_TIMESTAMP
$OPTIONS_STATUS_MSG
Please review log file ${LOG_DIR}/${LOG_FILE}
for details
-------------------------
submit2Hermes@$CURRSERVER
--- __o
--- _-\<,_
--- (_)/ (_)
EOF!
fi
}
sendDDLStartedEmailNotification () {
if [[ "$EMAIL_ADDR_VALUE" != "" ]]
then
EMAIL_ADDR=`cat $EMAIL_FILE`
HEADER_PART=""
if [[ "$DEPLOY_PKG_NAME" = "all" ]]
then
HEADER_PART="packages uat1 - uat2"
else
HEADER_PART="$DEPLOY_PKG_NAME package"
fi
generateSVNOptionsStatusMsg
/bin/mail -s "[$CURRUSER@$CURRSERVER] Daily DDL build is started for $HEADER_PART ($BUILD_IDN)" $EMAIL_ADDR_VALUE << EOF!
*** DDL build is started.
Started at: $START_TIMESTAMP
$OPTIONS_STATUS_MSG
Please review log file ${LOG_DIR}/${LOG_FILE}
for details
-------------------------
submit2Hermes@$CURRSERVER
--- __o
--- _-\<,_
--- (_)/ (_)
EOF!
fi
}
sendCompletedEmailNotification () {
if [[ "$EMAIL_ADDR_VALUE" != "" ]]
then
EMAIL_ADDR=`cat $EMAIL_FILE`
ARCHIVED_MSG=""
FILES_MSG=""
HEADER_PART=""
if [[ "$DEPLOY_PKG_NAME" = "all" ]]
then
HEADER_PART="oprisk3 - oprisk5 packages"
else
HEADER_PART="$DEPLOY_PKG_NAME package"
fi
if [[ "$BUILD_PKG_CONFIRM" = [Yy] ]]
then
ARCHIVED_MSG="*** All war / jar and dstream files copied on $CURRSERVER under directory:
$ARCHIVE_DIR"
fi
if [[ "$SEND_TO_HERMES_CONFIRM" = [Yy]* ]]
then
FILE_NAMES=`cat $SENT_TO_HERMES_TEMP | grep -v 'Sending' | grep -v 'New' | grep -v '-' | grep '.Z'`
FILES_MSG="*** Sent following file(s) to Hermes:
$FILE_NAMES"
else
FILE_NAMES=`cat $TAR_FILE_NAMES_TEMP`
FILES_MSG="*** Following file(s) tarred under directory:
$BUILD_DIR/riskciti on $CURRSERVER
$FILE_NAMES"
fi
/bin/mail -s "[$CURRUSER@$CURRSERVER] Daily build complete for $HEADER_PART ($BUILD_IDN)" $EMAIL_ADDR_VALUE << EOF!
*** Build is complete.
Started at: $START_TIMESTAMP
Finished at: $FINISH_TIMESTAMP
$OPTIONS_STATUS_MSG
$ARCHIVED_MSG
$FILES_MSG
-------------------------
submit2Hermes@$CURRSERVER
--- __o
--- _-\<,_
--- (_)/ (_)
EOF!
fi
\rm -f $SENT_TO_HERMES_TEMP
\rm -f $TAR_FILE_NAMES_TEMP
}
sendDDLCompletedEmailNotification () {
if [[ "$EMAIL_ADDR_VALUE" != "" ]]
then
EMAIL_ADDR=`cat $EMAIL_FILE`
ARCHIVED_MSG=""
FILES_MSG=""
HEADER_PART=""
if [[ "$DEPLOY_PKG_NAME" = "all" ]]
then
HEADER_PART="uat1 - uat2 packages"
else
HEADER_PART="$DEPLOY_PKG_NAME package"
fi
if [[ "$SEND_TO_HERMES_CONFIRM" = [Yy]* ]]
then
FILE_NAMES=`cat $SENT_TO_HERMES_TEMP | grep -v 'Sending' | grep -v 'New' | grep -v '-' | grep '.Z'`
FILES_MSG="*** Sent following file(s) to Hermes:
$FILE_NAMES"
else
FILE_NAMES=`cat $TAR_FILE_NAMES_TEMP`
FILES_MSG="*** Following file(s) tarred under directory:
$BUILD_DIR on $CURRSERVER
$FILE_NAMES"
fi
/bin/mail -s "[$CURRUSER@$CURRSERVER] Daily DDL build complete for $HEADER_PART ($BUILD_IDN)" $EMAIL_ADDR_VALUE << EOF!
*** Build is complete.
Started at: $START_TIMESTAMP
Finished at: $FINISH_TIMESTAMP
$OPTIONS_STATUS_MSG
$FILES_MSG
-------------------------
submit2Hermes@$CURRSERVER
--- __o
--- _-\<,_
--- (_)/ (_)
EOF!
fi
}
generateSVNOptionsStatusMsg () {
OPTIONS_STATUS_MSG=""
INCLUDE_CASA_CONFIRM_TMP=""
SEND_TO_HERMES_CONFIRM_TMP=""
SRC_AUDIT_CONFIRM_TMP=""
BUILD_PKG_CONFIRM_TMP=""
SVN_TAG_NAME_TEMP=""
if [[ "$SVN_TAG_NAME" = "" ]]
then
SVN_TAG_NAME_TEMP="NO TAG"
else
SVN_TAG_NAME_TEMP=$SVN_TAG_NAME
fi
if [[ "$SEND_TO_HERMES_CONFIRM" = [Nn]* ]]
then
SEND_TO_HERMES_CONFIRM_TMP="NO"
else
SEND_TO_HERMES_CONFIRM_TMP="YES"
fi
if [[ "$SRC_AUDIT_CONFIRM" = [Nn]* ]]
then
SRC_AUDIT_CONFIRM_TMP="NO"
else
SRC_AUDIT_CONFIRM_TMP="YES"
fi
if [[ "$BUILD_PKG_CONFIRM" = [Nn]* ]]
then
BUILD_PKG_CONFIRM_TMP="NO"
else
BUILD_PKG_CONFIRM_TMP="YES"
fi
OPTIONS_STATUS_MSG=`echo "*** Following options were selected
Package name to deploy = $DEPLOY_PKG_NAME
Used any specific SVN tag = $SVN_TAG_NAME_TEMP
Send file to Hermes = $SEND_TO_HERMES_CONFIRM_TMP
Run source audit = $SRC_AUDIT_CONFIRM_TMP
Build local dstream = $BUILD_PKG_CONFIRM_TMP"`
export OPTIONS_STATUS_MSG
}
sendFailedAuditEmail () {
if [[ "$EMAIL_ADDR_VALUE" != "" ]]
then
msg=$1
EMAIL_ADDR=`cat $EMAIL_FILE`
HEADER_PART=""
if [[ "$DEPLOY_PKG_NAME" = "all" ]]
then
HEADER_PART="oprisk3 - oprisk5 packages"
else
HEADER_PART="$DEPLOY_PKG_NAME package"
fi
/bin/mail -s "[$CURRUSER@$CURRSERVER] Daily build for $HEADER_PART ($BUILD_IDN) >> SOURCE AUDIT FAILURE <<" $EMAIL_ADDR_VALUE << EOF!
Build is failed. Source audit failure
Started at: $START_TIMESTAMP
Failed at: `date`
Following is an output source audit log file: $PADUIT_LOG
`cat ${PADUIT_LOG}`
-------------------------
:(
submit2Hermes@$CURRSERVER
--- __o
--- _-\<,_
--- (_)/ (_)
EOF!
fi
}
sendBuildIterruptedEmail () {
if [[ "$EMAIL_ADDR_VALUE" != "" ]]
then
msg=$1
EMAIL_ADDR=`cat $EMAIL_FILE`
HEADER_PART=""
if [[ "$DEPLOY_PKG_NAME" = "all" ]]
then
HEADER_PART="oprisk3 - oprisk5 packages"
else
HEADER_PART="$DEPLOY_PKG_NAME package"
fi
/bin/mail -s "[$CURRUSER@$CURRSERVER] Daily build for $HEADER_PART ($BUILD_IDN) >> BUILD INTERRUPTED <<" $EMAIL_ADDR_VALUE << EOF!
Build is failed. Interrupted by user action
Started at: $START_TIMESTAMP
Interrupted at: `date`
-------------------------
:(
submit2Hermes@$CURRSERVER
--- __o
--- _-\<,_
--- (_)/ (_)
EOF!
fi
}
sendBuildFailedEmail () {
if [[ "$EMAIL_ADDR_VALUE" != "" ]]
then
msg=$1
EMAIL_ADDR=`cat $EMAIL_FILE`
HEADER_PART=""
if [[ "$DEPLOY_PKG_NAME" = "all" ]]
then
HEADER_PART="oprisk3 - oprisk5 packages"
else
HEADER_PART="$DEPLOY_PKG_NAME package"
fi
/bin/mail -s "[$CURRUSER@$CURRSERVER] Daily build for $HEADER_PART ($BUILD_IDN) >> BUILD FAILED <<" $EMAIL_ADDR_VALUE << EOF!
Build is failed.
Started at: $START_TIMESTAMP
Failed at: `date`
View log file ${LOG_DIR}/${LOG_FILE} for details"
-------------------------
:(
submit2Hermes@$CURRSERVER
--- __o
--- _-\<,_
--- (_)/ (_)
EOF!
fi
}
sendDDLTarFailedEmail () {
if [[ "$EMAIL_ADDR_VALUE" != "" ]]
then
msg=$1
EMAIL_ADDR=`cat $EMAIL_FILE`
HEADER_PART=""
if [[ "$DEPLOY_PKG_NAME" = "all" ]]
then
HEADER_PART="uat1 - uat2 packages"
else
HEADER_PART="$DEPLOY_PKG_NAME package"
fi
/bin/mail -s "[$CURRUSER@$CURRSERVER] Daily DDL build for $HEADER_PART ($BUILD_IDN) >> BUILD FAILED <<" $EMAIL_ADDR_VALUE << EOF!
Build is failed.
Started at: $START_TIMESTAMP
Failed at: `date`
View log file ${LOG_DIR}/${LOG_FILE} for details"
-------------------------
:(
submit2Hermes@$CURRSERVER
--- __o
--- _-\<,_
--- (_)/ (_)
EOF!
fi
}
setBuildDirectory () {
BUILD_DIR=/tmp/$1$CURRUSER
export BUILD_DIR
}
setDDLBuildDirectory () {
BUILD_DIR=/home/$CURRUSER/riskciti/DB
export BUILD_DIR
}
setAllPromtValues () {
if [[ "$1" != "" ]]
then
DEPLOY_PKG_NAME="oprisk3"
setBuildDirectory "$DEPLOY_PKG_NAME"
makeBuildDirectory "$*"
SEND_TO_HERMES_CONFIRM="n"
SRC_AUDIT_CONFIRM="n"
BUILD_PKG_CONFIRM="y"
EMAIL_ADDR_VALUE="oprisk.systems@iuo.ssmb.com"
else
## prompt package name
getPackageName
setBuildDirectory "$DEPLOY_PKG_NAME"
makeBuildDirectory "$*"
## prompt submit package to Hermes
getResponse "Would you like to submit generated tar file to Hermes? "
export SEND_TO_HERMES_CONFIRM=$RESPONSE
## prompt source audit
getResponse "Would you like to run source audit script? "
export SRC_AUDIT_CONFIRM=$RESPONSE
## prompt package make, will create rpm and all jar files
getResponse "Would you like to make package to create RPM? "
export BUILD_PKG_CONFIRM=$RESPONSE
getSVNTree
if [[ "$SVNTREE" != "trunk" ]]
then
getSvnTag
fi
## prompt email notification
emailConfirmation
if [[ "$EMAIL_ADDR_VALUE" = "" ]]
then
printMessage2 "Mail confirmation is not enabled"
fi
fi
}
getFunctionMenu(){
RESP=""
while [ -z "${RESP}" ]
do
printMessage2 "
#############################################################################################
#### # # #### ## ## ##### ##### ##### ##### # # ##### #### ## ## ##### ####
# # # # # # # # # # # # # # # # # # # # # # # # #
### # # #### # ## # # # # # # ##### ##### #### # ## # ##### ###
# # # # # # ## # # # # # # # # # # # # ## # # #
#### ## #### # # ##### # # ##### # # ##### # # # # ##### ####
#############################################################################################
please select the package you want to build:
Available options:
1 - Build all-in-one package (including wars/vendorlibs/scripts).
2 - Build war package for all projects.
3 - Build vendor library package.
4 - Build script package.
5 - Build DDL tar package.
6 - Build separate web application package.
Installation type (default: 1 - Build all-in-one package): \c"
read RESP
case "${RESP:=1}" in
"1")
RESP="build_all" ;;
"2")
RESP="build_war" ;;
"3")
RESP="build_ven" ;;
"4")
RESP="build_scr" ;;
"5")
RESP="build_ddl" ;;
"6")
RESP="build_sep" ;;
*)
printMessage2 "\n***$RESP: invalid response, please use the option letter!"
RESP="" ;;
esac
done
export BUILD_FUNCTION_NAME=${RESP}
printMessage "Hermes: Build ${RESP} package"
}
getPackageName()
{
RESP=""
while [ -z "${RESP}" ]
do
printMessage "
Please enter Hermes deployment package name.
Available options:
1 - oprisk3 ( STABLE 1, UAT 1, PRODUCTION )
2 - oprisk4 ( STABLE 2, UAT 2 )
3 - oprisk5 ( STABLE 3, UAT 3 )
4 - oprisk1 ( STABLE 4)
5 - opriskdr ( CONTINGENCY )
Installation type (default: 1 - oprisk3): \c"
read RESP
case "${RESP:=oprisk3}" in
"1" |"oprisk3")
RESP="oprisk3" ;;
"2" |"oprisk4")
RESP="oprisk4" ;;
"3" |"oprisk5")
RESP="oprisk5" ;;
"4" |"oprisk1")
RESP="oprisk1" ;;
"5" |"opriskdr")
RESP="opriskdr" ;;
*)
printMessage2 " *** $RESP: invalid response, please use the option letter or action keyword."
RESP="" ;;
esac
done
export DEPLOY_PKG_NAME=${RESP}
printMessage "Hermes deployment package name set to: ${RESP}"
}
getDDLPackageName()
{
RESP=""
while [ -z "${RESP}" ]
do
printMessage "snektal added STABLE 4
Please enter Hermes deployment package name.
Available options:
1 - uat1 ( UAT 1)
2 - uat2 ( UAT 2)
3 - uat3 ( UAT 3)
Installation type (default: 1 - uat1): \c"
read RESP
case "${RESP:= uat1}" in
"1" |"uat1")
RESP="OPRISKQ1_NEW" ;;
"2" |"uat2")
RESP="OPRISKQ2_NEW" ;;
"3" |"uat3")
RESP="OPRISKQ3_NEW" ;;
*)
printMessage2 "
*** $RESP: invalid response, please try again!
Use the option letter or action keyword."
RESP=""
;;
esac
done
DEPLOY_PKG_NAME=${RESP}
printMessage "Hermes deployment package name set to: ${RESP}"
export DEPLOY_PKG_NAME
}
getTarFileNames () {
printMessage " Getting tar file names. "
cd $BUILD_DIR/riskciti
echo "`ls *.tar`" > $TAR_FILE_NAMES_TEMP
}
moveFilesToArchive () {
if [[ ! -d $ARCHIVE_DIR ]]
then
mkdir -p $ARCHIVE_DIR
fi
cd $BUILD_DIR/riskciti/oprisk/install
#mv war_deployments $ARCHIVE_DIR/.
#mv ejb_deployments $ARCHIVE_DIR/.
#mv lib $ARCHIVE_DIR/.
cd $BUILD_DIR/riskciti
mv *.Z $ARCHIVE_DIR/.
cd -
}
setVariable () {
clear
# set PATH for paudit
PATH="$PATH:/xenv/scripts/bin"
export PATH
export CURRUSER=`logname`
export CURRSERVER=`hostname`
export EMAIL_FILE=/tmp/$CURRUSER"_mailaddr"
export BUILD_DATE=`date +%m%d%Y`
export LOG_FILE="submit2Hermes_"${BUILD_DATE}".log"
export LOG_DIR=$HOME/logs
export SENT_TO_HERMES_TEMP=/tmp/send_to_hermes$$
export TAR_FILE_NAMES_TEMP=/tmp/tar_file_names$$
export BUILD_IDN="build id = "$$
#### variables definition
START_TIMESTAMP=`date`
SVN_TAG_NAME=""
SVNTREE=""
SVNROOT=/svn/34896/newoprisk
SVNPREFIX=https://svn.nam.nsroot.net:9050
# value that indicates if already in cross env
ENV_SET_FLAG="n"
# default name for deploying package
BUILD_FUNCTION_NAME="build_all"
DEPLOY_PKG_NAME="oprisk4"
BUILD_PKG_CONFIRM=""
SEND_TO_HERMES_CONFIRM=""
SRC_AUDIT_CONFIRM=""
DELETE_EXISTING_BUILD=""
ARCHIVE_EXISTING_BUILD=""
INCLUDE_CASA_CONFIRM=""
EMAIL_ADDR_VALUE=""
ALL_PKG_FLAG="0"
OPTIONS_STATUS_MSG=""
OPTIONS_CONFIRM=""
}
################################################
### start here
################################################
mainFunction () {
BUILD_DIR=""
if [ ! -d $LOG_DIR ]
then
mkdir ${LOG_DIR}
fi
setAllPromtValues "$*"
PKG_NAME=$CURRUSER"_"$DEPLOY_PKG_NAME
PADUIT_LOG=/tmp/$PKG_NAME.paudit$$
if [[ "$SVN_TAG_NAME" = "" ]]
then
ARCHIVE_DIR=$CURRUSER"_DAILY_NOTAG_"$BUILD_DATE
else
ARCHIVE_DIR=$CURRUSER"_DAILY_"$SVN_TAG_NAME"_"$BUILD_DATE
fi
if [[ -d /home/$CURRUSER ]]
then
printMessage "Home for user $CURRUSER exists"
ARCHIVE_DIR=/home/$CURRUSER/$ARCHIVE_DIR
else
printMessage "Home for user $CURRUSER does NOT exist"
ARCHIVE_DIR=/var/temp/archive/$ARCHIVE_DIR
fi
export ARCHIVE_DIR
sendStartedEmailNotification
if [[ "$1" != "" ]]
then
verifyEnteredParameters
while [[ "$OPTIONS_CONFIRM" = [Nn]* ]]
do
setAllPromtValues
verifyEnteredParameters
done
fi
checkFileOutFromSVN
## go to pkg directory
jumpToRootDir
# Delete files / dirs that should not be included in package.
cleanPackage
runPkgAudit
printMessage "LOOPING DEPLOY_PKG_NAME = $DEPLOY_PKG_NAME"
export DEPLOY_PKG_NAME
#replace package name in SPEC file
evaluateEnv
createTarFile "$DEPLOY_PKG_NAME"
runTestMake
sendTarFilesToHermes
printMessage "Please review log file ${LOG_DIR}/${LOG_FILE} for build details"
FINISH_TIMESTAMP=`date`
if [[ "$BUILD_PKG_CONFIRM" = [Yy] ]]
then
moveFilesToArchive
fi
sendCompletedEmailNotification
printMessage2 "Started @ $START_TIMESTAMP"
printMessage2 "Finished @ $FINISH_TIMESTAMP"
cd /tmp
#\rm -fr $BUILD_DIR
}
sendDDLTarToHermes () {
jumpToBuildDir
find $BUILD_DIR -type d -name "*svn*" -exec rm -rf {} \; -print
cd OpRisk
chmod -R 777 *
for i in `find . -type f`
do
cp $i $i.copy
tr -d '\r' < $i.copy > $i
sed "s/OPRISKQ1_NEW/$DEPLOY_PKG_NAME/g" $i > $i.copy
rm -rf $i
mv $i.copy $i
done
cd ..
printMessage "Success to dos2unix."
if [[ -f OpRisk.tar ]]
then
rm -rf OpRisk.tar
printMessage "Success to delete OpRisk.tar."
fi
tar -cvf OpRisk.tar ./OpRisk
if [[ $? -eq 1 ]]
then
printMessage "Error. failed to tar source file to OpRisk.tar. "
printMessage ":("
exit 1
## sendDDLTarFailedEmail
fi
printMessage "Success to tar source file to OpRisk.tar."
if [[ "$SEND_TO_HERMES_CONFIRM" = "y" || "$SEND_TO_HERMES_CONFIRM" = "Y" ]]
then
printMessage "Sending DDL tar file to HERMES "
pwd
cd ..
pwd
##send package to hermes
/xenv/scripts/bin/send_to_hermes $BUILD_DIR/OpRisk.tar
if [ $? -eq 1 ]
then
printMessage "Error. failed to send file $i to hermes. exiting. "
printMessage ":("
exit 1
fi
printMessage2 "Sent following file(s) to Hermes:"
printMessage2 "`cat $SENT_TO_HERMES_TEMP | grep -v 'Sending' | grep -v 'New' | grep -v '-' | grep '.Z'`"
printMessage2 "Success. Go ahead and submit the job to Hermes"
printMessage2 ":)"
fi
}
submitDDL () {
getDDLPackageName
setDDLBuildDirectory
makeDDLBuildDirectory
## prompt submit package to Hermes
getResponse "Would you like to submit generated tar file to Hermes? "
export SEND_TO_HERMES_CONFIRM=$RESPONSE
getSVNTree
if [[ "$SVNTREE" != "trunk" ]]
then
getSvnTag
fi
## prompt email notification
emailConfirmation
if [[ "$EMAIL_ADDR_VALUE" = "" ]]
then
printMessage2 "Mail confirmation is not enabled"
fi
## sendDDLStartedEmailNotification
SRC_AUDIT_CONFIRM=n
verifyEnteredParameters
makeLogDirectory
checkDDLFileOutFromSVN
sendDDLTarToHermes
## sendDDLCompletedEmailNotification
}
#****************************************************************************************
# execution starts here #
#****************************************************************************************
trap 'removeTempFiles; sendBuildIterruptedEmail; exit 1' 1 2 3 6 15
setVariable
makeLogDirectory
getFunctionMenu
if [[ "$BUILD_FUNCTION_NAME" = "build_all" ]]
then
mainFunction "$*"
fi
if [[ "$BUILD_FUNCTION_NAME" = "build_war" ]]
then
echo $BUILD_FUNCTION_NAME
fi
if [[ "$BUILD_FUNCTION_NAME" = "build_sep" ]]
then
echo $BUILD_FUNCTION_NAME
fi
if [[ "$BUILD_FUNCTION_NAME" = "build_ven" ]]
then
echo $BUILD_FUNCTION_NAME
fi
if [[ "$BUILD_FUNCTION_NAME" = "build_scr" ]]
then
echo $BUILD_FUNCTION_NAME
fi
if [[ "$BUILD_FUNCTION_NAME" = "build_ddl" ]]
then
submitDDL "$*"
fi
result=$?
echo "********** \n**********\n\tRESULT = $result"
if [ $result -gt 0 ]
then
printMessage "Error. build failed. Exiting. View log file ${LOG_DIR}/${LOG_FILE} for details"
printMessage2 ":("
sendBuildFailedEmail
exit 1
fi
exit 0
#ident "%W%"
printMessage() {
echo -e "\n************************************************************"
echo -e "$1"
echo -e "$1" >> ${LOG_DIR}/${LOG_FILE}
}
printMessage2() {
echo -e "$1"
echo -e "$1" >> ${LOG_DIR}/${LOG_FILE}
}
jumpToRootDir () {
cd $BUILD_DIR/riskciti/oprisk
}
jumpToPkgDir () {
cd $BUILD_DIR/riskciti/oprisk/pkg
}
jumpToBuildDir () {
cd $BUILD_DIR
}
cleanPackage() {
printMessage "Cleaning files/dirs not needed for packaging "
removeSVNDirectories
removeAbsoliteDirs
removeEmptyDirs
removeOtherMakeFile
}
removeOtherMakeFile() {
jumpToRootDir
}
removeEmptyDirs () {
printMessage2 "Removing empty directories "
}
removeAbsoliteDirs () {
printMessage2 "Removing directories we do not require under riskciti/oprisk"
jumpToRootDir
if [[ -d ./DB ]]
then
printMessage2 "removing DB"
\rm -fr ./DB
fi
if [[ -d ./env ]]
then
printMessage2 "removing env"
cp ./env/oprisk.xenv .
cp ./env/opr_setup.ksh .
\rm -fr ./env/*
mv ./opr_setup.ksh ./env/.
chmod +x ./env/opr_setup.ksh
fi
if [[ -f ./etc/tnsnames.txt ]]
then
\rm ./etc/tnsnames.txt
fi
if [[ -d ./pkg/common ]]
then
printMessage2 "removing pkg/common"
\rm -fr ./pkg/common
fi
if [[ -d ./pkg/edcs ]]
then
printMessage2 "removing pkg/edcs"
\rm -fr ./pkg/edcs
fi
if [[ -d ./pkg/rcsa ]]
then
printMessage2 "removing pkg/rcsa"
\rm -fr ./pkg/rcsa
fi
if [[ -d ./scripts ]]
then
printMessage2 "removing scripts"
\rm -fr ./scripts
fi
if [[ -d ./sminfoagent ]]
then
printMessage2 "removing sminfoagent"
\rm -fr ./sminfoagent
fi
if [[ -f ./user_projects/domains/opriskDomain/oprconfig ]]
then
\rm ./user_projects/domains/opriskDomain/oprconfig
fi
\rm user_projects/domains/opriskDomain/keystores/*.jks
if [[ -d ./tools ]]
then
printMessage2 "removing tools"
\rm -fr ./tools
fi
if [[ -d ./install ]]
then
printMessage2 "removing install"
\rm -fr ./install
fi
if [[ -d ./weblogic ]]
then
printMessage2 "removing weblogic"
\rm -fr ./weblogic
fi
if [[ -d ./src/Hierarchy/webcontent/WEB-INF/lib ]]
then
printMessage2 "removing src/Hierarchy/webcontent/WEB-INF/lib"
\rm -fr ./src/Hierarchy/webcontent/WEB-INF/lib
fi
if [[ -d ./src/lib ]]
then
printMessage2 "removing src/lib"
\rm -fr ./src/lib
fi
if [[ -d ./src/Hierarchy_Popup/compile_required_libs ]]
then
printMessage2 "removing src/Hierarchy_Popup/compile_required_libs"
\rm -fr ./src/Hierarchy_Popup/compile_required_libs
fi
if [[ -d ./src/LEO_WFL/WEB-INF/lib ]]
then
printMessage2 "removing src/LEO_WFL/WEB-INF/lib"
\rm -fr ./src/LEO_WFL/WEB-INF/lib
fi
if [[ -d ./src/LEO/WEB-INF/lib ]]
then
printMessage2 "removing src/LEO/WEB-INF/lib"
\rm -fr ./src/LEO/WEB-INF/lib
fi
if [[ -d ./LEO_WFL_POC ]]
then
printMessage2 "removing LEO_WFL_POC"
\rm -fr ./LEO_WFL_POC
fi
if [[ -d ./src/LEO/DDL ]]
then
printMessage2 "removing src/LEO/DDL"
\rm -fr ./src/LEO/DDL
fi
if [[ -f ./src/util/src/com/citigroup/oprisk/entitlement/url/Makefile ]]
then
\rm ./src/util/src/com/citigroup/oprisk/entitlement/url/Makefile
fi
if [[ -f ./src/Hierarchy_Popup/src/com/citi/oprisk/hierarchy/public/js/resources/images/gray/window/left-corners.pspimage ]]
then
\rm ./src/Hierarchy_Popup/src/com/citi/oprisk/hierarchy/public/js/resources/images/gray/window/left-corners.pspimage
fi
if [[ -f ./src/Hierarchy_Popup/src/com/citi/oprisk/hierarchy/public/js/resources/resources.jsb ]]
then
\rm ./src/Hierarchy_Popup/src/com/citi/oprisk/hierarchy/public/js/resources/resources.jsb
fi
if [[ -f ./src/LEO/gwtext/maker/src/public/EOLcity.json ]]
then
\rm ./src/LEO/gwtext/maker/src/public/EOLcity.json
fi
if [[ -f ./src/ama/webcontent/js/ext-2.0.2/resources/images/gray/window/left-corners.pspimage ]]
then
\rm ./src/ama/webcontent/js/ext-2.0.2/resources/images/gray/window/left-corners.pspimage
fi
if [[ -f ./entitlement/gwtext/entitlementinfo/public/js/resources/images/oprisk/delete_icon.png ]]
then
\rm ./entitlement/gwtext/entitlementinfo/public/js/resources/images/oprisk/delete_icon.png
fi
if [[ -f ./entitlement/gwtext/entitlementinfo/public/js/resources/images/oprisk/edit_icon.gif ]]
then
\rm ./entitlement/gwtext/entitlementinfo/public/js/resources/images/oprisk/edit_icon.gif
fi
if [[ -f ./src/fileupload/web/images/ico-hierarchy.gif.1 ]]
then
\rm ./src/fileupload/web/images/ico-hierarchy.gif.1
fi
if [[ -f ./src/fileupload/web/images/b_button-convert.gif.svntmp ]]
then
\rm ./src/fileupload/web/images/b_button-convert.gif.svntmp
fi
if [[ -f ./src/commonv2/eers/com/ssmb/oprisk/eers/Makefile ]]
then
\rm ./src/commonv2/eers/com/ssmb/oprisk/eers/Makefile
fi
find $BUILD_DIR/riskciti -name 'Thumbs.db' -exec \rm -fr {} \; -print
find $BUILD_DIR/riskciti/oprisk/src/LEO/test/sp -name '*.prc' -exec \rm -fr {} \; -print
find $BUILD_DIR/riskciti/oprisk/src/LEO/test/sp -name '*.sql' -exec \rm -fr {} \; -print
find $BUILD_DIR/riskciti/oprisk/src/fileupload/src/com/ssmb/oprisk -name 'Makefile' -exec \rm -fr {} \; -print
find $BUILD_DIR/riskciti/oprisk/src/rcsa/web -name 'Makefile' -exec \rm -fr {} \; -print
}
removeSVNDirectories () {
printMessage "Removing SVN directories"
find $BUILD_DIR/riskciti -name '.svn' -exec \rm -fr {} \; -print
if [ $DELETE_EXISTING_BUILD = "y" ]
then
find $BUILD_DIR -name '*.class' -exec \rm -fr {} \; -print
fi
printMessage2 "Removing other junk files "
find $BUILD_DIR -name '*.log' -exec \rm -f {} \; -print
find $BUILD_DIR -name '*.bak' -exec \rm -f {} \; -print
find $BUILD_DIR -name '*.ldift' -exec \rm -f {} \; -print
find $BUILD_DIR -name '*.xml1' -exec \rm -f {} \; -print
find $BUILD_DIR -name '*.xml_dev' -exec \rm -fr {} \; -print
find $BUILD_DIR -name '*.iws' -exec \rm -f {} \; -print
find $BUILD_DIR -name '*.ipr' -exec \rm -f {} \; -print
find $BUILD_DIR -name '*.iml' -exec \rm -f {} \; -print
find $BUILD_DIR -name '*.orig*' -exec \rm -f {} \; -print
find $BUILD_DIR -name '*.*~' -exec \rm -f {} \; -print
}
removeExistingBuildDir () {
ARCH_DIRNAME=$BUILD_DIR"_"$BUILD_DATE"."$$
if [ -d $BUILD_DIR ]
then
if [ "$1" = "" ]
then
getResponse "Build dir $BUILD_DIR exists. Would like to remove it? "
DELETE_EXISTING_BUILD=$RESPONSE
if [[ "$DELETE_EXISTING_BUILD" = [Nn]* ]]
then
getResponse "Build dir $BUILD_DIR exists. \nWould like to move it to name $ARCH_DIRNAME ? "
ARCHIVE_EXISTING_BUILD=$RESPONSE
fi
else
printMessage2 "Removing existing build directory: $BUILD_DIR "
DELETE_EXISTING_BUILD="y"
fi
if [[ $DELETE_EXISTING_BUILD = "y" ]]
then
\rm -fr $BUILD_DIR
elif [[ "$ARCHIVE_EXISTING_BUILD" = [Yy]* ]]
then
cd /tmp
printMessage2 "Moving directory to $ARCH_DIRNAME"
mv $BUILD_DIR $ARCH_DIRNAME
else
printMessage2 "Please make up your mind ..."
exit 1
fi
fi
}
removeOldTarFile() {
printMessage2 "Removing old tar files"
jumpToRootDir
if [[ -f $BUILD_DIR/riskciti/$PKG_NAME.tar ]]
then
printMessage "Removing existing tar file"
\rm -f $BUILD_DIR/riskciti/$PKG_NAME.tar
elif [[ -f $BUILD_DIR/riskciti/$PKG_NAME.tar.Z ]]
then
printMessage "Removing existing tar file"
\rm -f $BUILD_DIR/riskciti/$PKG_NAME.tar.Z
fi
}
removeTempFiles () {
printMessage "Removing temp files"
\rm -f /tmp/send_to_hermes*
\rm -f /tmp/tar_file_names*
}
makeLogDirectory() {
if [ ! -d $LOG_DIR ]
then
mkdir ${LOG_DIR}
fi
touch ${LOG_DIR}/${LOG_FILE}
printMessage "For status, please view log file ${LOG_DIR}/${LOG_FILE} "
}
makeBuildDirectory () {
removeExistingBuildDir "$*"
if [[ ! -d $BUILD_DIR ]]
then
printMessage "Creating build dir "
mkdir -p $BUILD_DIR
if [ $? -eq 1 ]
then
printMessage ""
printMessage "Error. Failed to create build dir $BUILD_DIR . exiting"
printMessage ":( "
exit 1
fi
fi
}
makeDDLBuildDirectory () {
if [[ ! -d $BUILD_DIR ]]
then
printMessage "Creating build dir "
mkdir -p $BUILD_DIR
if [ $? -eq 1 ]
then
printMessage ""
printMessage "Error. Failed to create build dir $BUILD_DIR . exiting"
printMessage ":( "
exit 1
fi
fi
}
createTarFile() {
printMessage "Taring package source tree "
if [[ "$SVN_TAG_NAME" = "" ]]
then
export PKG_NAME=$CURRUSER"_"$1"_NOTAG"
else
export PKG_NAME=$CURRUSER"_"$1"_"$SVN_TAG_NAME
fi
removeOldTarFile
tar -cvf $BUILD_DIR/riskciti/$PKG_NAME.tar .
}
runPkgAudit() {
if [[ "$SRC_AUDIT_CONFIRM" = [Yy]* ]]
then
printMessage2 "Performig package src audit with /xenv/scripts/bin/paudit_src_5"
/xenv/scripts/bin/paudit_src_5 $BUILD_DIR/riskciti/oprisk > $PADUIT_LOG
result=$?
printMessage2 "Paudit result $result"
if [ $result -ne 0 ]
then
printMessage "Error. paudit_sr failed. exiting. Look at the file $PADUIT_LOG for more info"
printMessage2 ":("
sendFailedAuditEmail
exit 1
fi
fi
if [[ -f $PADUIT_LOG ]]
then
\rm $PADUIT_LOG
fi
}
evaluateEnv() {
jumpToRootDir
sed -e 's?__DEPLOY_PKG_NAME__?'"$DEPLOY_PKG_NAME"'?g' ./rpm/SPECS/all-in-one.spec > ./rpm/SPECS/final_all-in-one.spec
rm -rf ./rpm/SPECS/all-in-one.spec
mv ./rpm/SPECS/final_all-in-one.spec ./rpm/SPECS/all-in-one.spec
sed -e 's?__DEPLOY_PKG_NAME__?'"$DEPLOY_PKG_NAME"'?g' ./scriptspkg/Makefile > ./scriptspkg/final_Makefile
rm -rf ./scriptspkg/Makefile
mv ./scriptspkg/final_Makefile ./scriptspkg/Makefile
}
runTestMake() {
if [[ "$BUILD_PKG_CONFIRM" = [Yy] ]]
then
printMessage "Building the package oprisk"
if [[ "$ENV_SET_FLAG" = "n" ]]
then
setXEnvironment
export ENV_SET_FLAG="y"
echo $ENV_SET_FLAG
fi
#chmod 755 $ROOT/rpm/scripts/request.sh
#sh $ROOT/rpm/scripts/request.sh $ROOT/target.env
#chmod 755 $ROOT/target.env
#cp $ROOT/target.env $ROOT/scriptspkg/newetc/target.env
#chmod 755 $ROOT/rpm/scripts/evaluateEnv.sh
#$ROOT/rpm/scripts/evaluateEnv.sh
#export CLASSPATH=$CLASSPATH:/xenv/oracleclient/X/11.1.0.7_RHAS64/jdbc/lib/ojdbc6.jar:/xenv/oracleclient/X/11.1.0.7_RHAS64/jlib/orai18n.jar:/xenv/WebsphereApplicationServer/X/7.0.0.21/WASHOME/dev/was_public.jar:/xenv/WebsphereApplicationServer/X/7.0.0.21/WASHOME/lib/j2ee.jar:/xenv/WebsphereApplicationServer/X/7.0.0.21/WASHOME/plugins/com.ibm.ws.runtime.jar:/xenv/WebsphereApplicationServer/X/7.0.0.21/WASHOME/runtimes/com.ibm.ws.sib.client.thin.jms_7.0.0.jar:/xenv/quartz/X/1.5.2/quartz-all-1.5.2.jar
make -f oprisk.mk package
if [ $? -gt 0 ]
then
printMessage " Error. make install failed "
printMessage2 ":("
exit 1
fi
jumpToRootDir
## move dstream one level up
mv *rpm* ../.
fi
}
sendTarFilesToHermes () {
removeTempFiles
if [[ "$SEND_TO_HERMES_CONFIRM" = "y" || "$SEND_TO_HERMES_CONFIRM" = "Y" ]]
then
printMessage "Sending tar file to HERMES "
pwd
cd ..
pwd
for i in `ls *.tar`
do
# send package to hermes
/xenv/scripts/bin/send_to_hermes $i >> $SENT_TO_HERMES_TEMP
if [ $? -eq 1 ]
then
printMessage "Error. failed to send file $i to hermes. exiting. "
printMessage ":("
exit 1
fi
done
printMessage2 "Sent following file(s) to Hermes:"
printMessage2 "`cat $SENT_TO_HERMES_TEMP | grep -v 'Sending' | grep -v 'New' | grep -v '-' | grep '.tar'`"
printMessage2 "Success. Go ahead and submit the job to Hermes"
printMessage2 ":)"
else
getTarFileNames
fi
}
setXEnvironment () {
printMessage "Setting / entering XENV "
jumpToRootDir
printMessage2 "Copying env file to `pwd`"
sed -e "s?exec \${XSH}??" /xenv/xenv.linux > /tmp/txenv
chmod +x /tmp/txenv
. /tmp/txenv -i $BUILD_DIR/riskciti/oprisk/oprisk.xenv .
}
setVariables() {
jumpToRootDir
. ./env/opr_setup.ksh
export ENV=./env/opr_setup.ksh
}
getSVNTree(){
TMPTREE=""
while [ -z "${TMPTREE}" ]
do
printMessage "Please specify SVN tree for this build:
Available options:
1 - branches
2 - tags
3 - trunk
Selected SVN tree(default:1 - branches):\c"
read TMPTREE
case "${TMPTREE:=branches}" in
"1" |"branches")
TMPTREE="branches" ;;
"2" |"tags")
TMPTREE="tags" ;;
"3" |"trunk")
TMPTREE="trunk" ;;
*)
printMessage2 "*** $TMPTREE: invalid response, please use the option letter or action keyword."
TMPTREE=""
;;
esac
done
printMessage2 "SVN tree set to: ${TMPTREE}"
export SVNTREE=$TMPTREE
}
getSvnTag(){
SVNTAG=""
while [ -z "${SVNTAG}" ]
do
printMessage "Please specify SVN tag/branch name for this build: \c"
read SVNTAG
echo
getResponse "Entered tag/branch name is: '$SVNTAG'. Would like to continue? "
r=$RESPONSE
if [[ "$r" = [Nn]* ]]
then
SVNTAG=""
else
break
fi
done
export SVN_TAG_NAME=$SVNTAG
}
checkFileOutFromSVN() {
jumpToBuildDir
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/xenv/svn-c/X/1.6.6l_64/lib:/xenv/svn-c/X/1.6.6l_64/lib:/xenv/svn-c/X/1.6.6l_64/lib/apr-util-1:/xenv/svn-c/X/1.6.6l_64/lib/engines:/xenv/svn-c/X/1.6.6l_64/lib/sasl2:/xenv/svn-c/X/1.6.6l_64/modules
export PATH=$PATH:/xenv/svn-c/X/1.6.6l_64/bin:/xenv/C/ia64/3.4.4/RH4.0AS_U2/usr/bin:/xenv/OS/ia64/RH4.0AS_U2/x86_64/bin:/xenv/OS/ia64/RH4.0AS_U2/x86_64/usr/bin
if [ "$SVN_TAG_NAME" != "" ]
then
printMessage "Checking out from $SVN_TAG_NAME"
svn co $SVNPREFIX$SVNROOT/$SVNTREE/$SVN_TAG_NAME riskciti/oprisk
else
svn co $SVNPREFIX$SVNROOT/trunk/oprisk_new_code_base/oprisk riskciti/oprisk
fi
if [ $? -eq 1 ]
then
printMessage "Error. Failed to checkout dir $BUILD_DIR . exiting"
printMessage2 ":("
exit 1
fi
printMessage "Checking out done ..."
}
checkDDLFileOutFromSVN() {
jumpToBuildDir
rm -rf *
if [[ ! -d $BUILD_DIR/OpRisk ]]
then
mkdir OpRisk
fi
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/xenv/svn-c/X/1.6.6l_64/lib:/xenv/svn-c/X/1.6.6l_64/lib:/xenv/svn-c/X/1.6.6l_64/lib/apr-util-1:/xenv/svn-c/X/1.6.6l_64/lib/engines:/xenv/svn-c/X/1.6.6l_64/lib/sasl2:/xenv/svn-c/X/1.6.6l_64/modules
export PATH=$PATH:/xenv/svn-c/X/1.6.6l_64/bin:/xenv/C/ia64/3.4.4/RH4.0AS_U2/usr/bin:/xenv/OS/ia64/RH4.0AS_U2/x86_64/bin:/xenv/OS/ia64/RH4.0AS_U2/x86_64/usr/bin
if [ "$SVN_TAG_NAME" != "" ]
then
printMessage "Checking out from $SVN_TAG_NAME"
svn co $SVNPREFIX$SVNROOT/$SVNTREE/$SVN_TAG_NAME/OpRisk $BUILD_DIR/OpRisk
if [ $? -ne 0 ]
then
printMessage "Error. Failed to checkout dir $BUILD_DIR . exiting"
printMessage2 ":("
exit 1
fi
fi
printMessage "Checking out done ..."
}
getResponse () {
msg=$1
RESPONSE=""
printMessage "$msg <y/n> "
while [ -z "${RESPONSE}" ]
do
read resp
if [[ ${resp} = [Yy]* ]]
then
RESPONSE="y"
break
elif [[ ${resp} = [Nn]* ]]
then
RESPONSE="n"
break
else
printMessage2 "Unknown response ${resp}. Setting to <n> "
RESPONSE="n"
break
fi
done
printMessage2 "$RESPONSE"
export RESPONSE
}
#************************************************************
#
#params: Email
#
#************************************************************
emailConfirmation(){
MAIL_FLAG=""
DEFAULT_MAIL_FLAG="n"
getResponse "Would you like receive an email notification? "
export MAIL_FLAG=$RESPONSE
MAIL_FLAG=${MAIL_FLAG:=${DEFAULT_MAIL_FLAG}}
if [ "$MAIL_FLAG" = "y" ]
then
MAIL_FLAG=""
DEFAULT_MAIL_FLAG="n"
if [[ -f $EMAIL_FILE ]]
then
printMessage2 "Follwing email address already stored in /tmp"
EMAIL_ADDR=`cat $EMAIL_FILE`
printMessage2 "Stored email address string = $EMAIL_ADDR"
EMAIL_ADDR_VALUE=$EMAIL_ADDR
printMessage2 "Would you like to change it [y /n] <default: n> : \c\n"
read MAIL_FLAG
MAIL_FLAG=${MAIL_FLAG:=${DEFAULT_MAIL_FLAG}}
if [ "$MAIL_FLAG" != "n" ]
then
DEFAULT_MAIL_FLAG=""
printMessage2 "Please enter updated email address... : \c\n"
read MAIL_FLAG
MAIL_FLAG=${MAIL_FLAG:=${DEFAULT_MAIL_FLAG}}
if [ "$MAIL_FLAG" != "" ]
then
EMAIL_ADDR_VALUE="$MAIL_FLAG"
touch $EMAIL_FILE
printMessage2 "$EMAIL_ADDR_VALUE" > $EMAIL_FILE
else
printMessage2 "EMail address is invalid... Setting email confirnmation to false"
fi
fi
else
DEFAULT_MAIL_FLAG=""
printMessage2 "Please enter your email address... : \c\n"
read MAIL_FLAG
MAIL_FLAG=${MAIL_FLAG:=${DEFAULT_MAIL_FLAG}}
if [ "$MAIL_FLAG" != "" ]
then
EMAIL_ADDR_VALUE="$MAIL_FLAG"
touch $EMAIL_FILE
printMessage2 "$EMAIL_ADDR_VALUE" > $EMAIL_FILE
fi
fi
fi
export EMAIL_ADDR_VALUE
echo $EMAIL_ADDR_VALUE
}
verifyEnteredParameters () {
generateSVNOptionsStatusMsg
getResponse "Here are entered options
$OPTIONS_STATUS_MSG
Would you like to continue? "
export OPTIONS_CONFIRM=$RESPONSE
}
sendStartedEmailNotification () {
if [[ "$EMAIL_ADDR_VALUE" != "" ]]
then
EMAIL_ADDR=`cat $EMAIL_FILE`
HEADER_PART=""
if [[ "$DEPLOY_PKG_NAME" = "all" ]]
then
HEADER_PART="packages oprisk3 - oprisk5"
else
HEADER_PART="$DEPLOY_PKG_NAME package"
fi
generateSVNOptionsStatusMsg
/bin/mail -s "[$CURRUSER@$CURRSERVER] Daily build is started for $HEADER_PART ($BUILD_IDN)" $EMAIL_ADDR_VALUE << EOF!
*** Build is started.
Started at: $START_TIMESTAMP
$OPTIONS_STATUS_MSG
Please review log file ${LOG_DIR}/${LOG_FILE}
for details
-------------------------
submit2Hermes@$CURRSERVER
--- __o
--- _-\<,_
--- (_)/ (_)
EOF!
fi
}
sendDDLStartedEmailNotification () {
if [[ "$EMAIL_ADDR_VALUE" != "" ]]
then
EMAIL_ADDR=`cat $EMAIL_FILE`
HEADER_PART=""
if [[ "$DEPLOY_PKG_NAME" = "all" ]]
then
HEADER_PART="packages uat1 - uat2"
else
HEADER_PART="$DEPLOY_PKG_NAME package"
fi
generateSVNOptionsStatusMsg
/bin/mail -s "[$CURRUSER@$CURRSERVER] Daily DDL build is started for $HEADER_PART ($BUILD_IDN)" $EMAIL_ADDR_VALUE << EOF!
*** DDL build is started.
Started at: $START_TIMESTAMP
$OPTIONS_STATUS_MSG
Please review log file ${LOG_DIR}/${LOG_FILE}
for details
-------------------------
submit2Hermes@$CURRSERVER
--- __o
--- _-\<,_
--- (_)/ (_)
EOF!
fi
}
sendCompletedEmailNotification () {
if [[ "$EMAIL_ADDR_VALUE" != "" ]]
then
EMAIL_ADDR=`cat $EMAIL_FILE`
ARCHIVED_MSG=""
FILES_MSG=""
HEADER_PART=""
if [[ "$DEPLOY_PKG_NAME" = "all" ]]
then
HEADER_PART="oprisk3 - oprisk5 packages"
else
HEADER_PART="$DEPLOY_PKG_NAME package"
fi
if [[ "$BUILD_PKG_CONFIRM" = [Yy] ]]
then
ARCHIVED_MSG="*** All war / jar and dstream files copied on $CURRSERVER under directory:
$ARCHIVE_DIR"
fi
if [[ "$SEND_TO_HERMES_CONFIRM" = [Yy]* ]]
then
FILE_NAMES=`cat $SENT_TO_HERMES_TEMP | grep -v 'Sending' | grep -v 'New' | grep -v '-' | grep '.Z'`
FILES_MSG="*** Sent following file(s) to Hermes:
$FILE_NAMES"
else
FILE_NAMES=`cat $TAR_FILE_NAMES_TEMP`
FILES_MSG="*** Following file(s) tarred under directory:
$BUILD_DIR/riskciti on $CURRSERVER
$FILE_NAMES"
fi
/bin/mail -s "[$CURRUSER@$CURRSERVER] Daily build complete for $HEADER_PART ($BUILD_IDN)" $EMAIL_ADDR_VALUE << EOF!
*** Build is complete.
Started at: $START_TIMESTAMP
Finished at: $FINISH_TIMESTAMP
$OPTIONS_STATUS_MSG
$ARCHIVED_MSG
$FILES_MSG
-------------------------
submit2Hermes@$CURRSERVER
--- __o
--- _-\<,_
--- (_)/ (_)
EOF!
fi
\rm -f $SENT_TO_HERMES_TEMP
\rm -f $TAR_FILE_NAMES_TEMP
}
sendDDLCompletedEmailNotification () {
if [[ "$EMAIL_ADDR_VALUE" != "" ]]
then
EMAIL_ADDR=`cat $EMAIL_FILE`
ARCHIVED_MSG=""
FILES_MSG=""
HEADER_PART=""
if [[ "$DEPLOY_PKG_NAME" = "all" ]]
then
HEADER_PART="uat1 - uat2 packages"
else
HEADER_PART="$DEPLOY_PKG_NAME package"
fi
if [[ "$SEND_TO_HERMES_CONFIRM" = [Yy]* ]]
then
FILE_NAMES=`cat $SENT_TO_HERMES_TEMP | grep -v 'Sending' | grep -v 'New' | grep -v '-' | grep '.Z'`
FILES_MSG="*** Sent following file(s) to Hermes:
$FILE_NAMES"
else
FILE_NAMES=`cat $TAR_FILE_NAMES_TEMP`
FILES_MSG="*** Following file(s) tarred under directory:
$BUILD_DIR on $CURRSERVER
$FILE_NAMES"
fi
/bin/mail -s "[$CURRUSER@$CURRSERVER] Daily DDL build complete for $HEADER_PART ($BUILD_IDN)" $EMAIL_ADDR_VALUE << EOF!
*** Build is complete.
Started at: $START_TIMESTAMP
Finished at: $FINISH_TIMESTAMP
$OPTIONS_STATUS_MSG
$FILES_MSG
-------------------------
submit2Hermes@$CURRSERVER
--- __o
--- _-\<,_
--- (_)/ (_)
EOF!
fi
}
generateSVNOptionsStatusMsg () {
OPTIONS_STATUS_MSG=""
INCLUDE_CASA_CONFIRM_TMP=""
SEND_TO_HERMES_CONFIRM_TMP=""
SRC_AUDIT_CONFIRM_TMP=""
BUILD_PKG_CONFIRM_TMP=""
SVN_TAG_NAME_TEMP=""
if [[ "$SVN_TAG_NAME" = "" ]]
then
SVN_TAG_NAME_TEMP="NO TAG"
else
SVN_TAG_NAME_TEMP=$SVN_TAG_NAME
fi
if [[ "$SEND_TO_HERMES_CONFIRM" = [Nn]* ]]
then
SEND_TO_HERMES_CONFIRM_TMP="NO"
else
SEND_TO_HERMES_CONFIRM_TMP="YES"
fi
if [[ "$SRC_AUDIT_CONFIRM" = [Nn]* ]]
then
SRC_AUDIT_CONFIRM_TMP="NO"
else
SRC_AUDIT_CONFIRM_TMP="YES"
fi
if [[ "$BUILD_PKG_CONFIRM" = [Nn]* ]]
then
BUILD_PKG_CONFIRM_TMP="NO"
else
BUILD_PKG_CONFIRM_TMP="YES"
fi
OPTIONS_STATUS_MSG=`echo "*** Following options were selected
Package name to deploy = $DEPLOY_PKG_NAME
Used any specific SVN tag = $SVN_TAG_NAME_TEMP
Send file to Hermes = $SEND_TO_HERMES_CONFIRM_TMP
Run source audit = $SRC_AUDIT_CONFIRM_TMP
Build local dstream = $BUILD_PKG_CONFIRM_TMP"`
export OPTIONS_STATUS_MSG
}
sendFailedAuditEmail () {
if [[ "$EMAIL_ADDR_VALUE" != "" ]]
then
msg=$1
EMAIL_ADDR=`cat $EMAIL_FILE`
HEADER_PART=""
if [[ "$DEPLOY_PKG_NAME" = "all" ]]
then
HEADER_PART="oprisk3 - oprisk5 packages"
else
HEADER_PART="$DEPLOY_PKG_NAME package"
fi
/bin/mail -s "[$CURRUSER@$CURRSERVER] Daily build for $HEADER_PART ($BUILD_IDN) >> SOURCE AUDIT FAILURE <<" $EMAIL_ADDR_VALUE << EOF!
Build is failed. Source audit failure
Started at: $START_TIMESTAMP
Failed at: `date`
Following is an output source audit log file: $PADUIT_LOG
`cat ${PADUIT_LOG}`
-------------------------
:(
submit2Hermes@$CURRSERVER
--- __o
--- _-\<,_
--- (_)/ (_)
EOF!
fi
}
sendBuildIterruptedEmail () {
if [[ "$EMAIL_ADDR_VALUE" != "" ]]
then
msg=$1
EMAIL_ADDR=`cat $EMAIL_FILE`
HEADER_PART=""
if [[ "$DEPLOY_PKG_NAME" = "all" ]]
then
HEADER_PART="oprisk3 - oprisk5 packages"
else
HEADER_PART="$DEPLOY_PKG_NAME package"
fi
/bin/mail -s "[$CURRUSER@$CURRSERVER] Daily build for $HEADER_PART ($BUILD_IDN) >> BUILD INTERRUPTED <<" $EMAIL_ADDR_VALUE << EOF!
Build is failed. Interrupted by user action
Started at: $START_TIMESTAMP
Interrupted at: `date`
-------------------------
:(
submit2Hermes@$CURRSERVER
--- __o
--- _-\<,_
--- (_)/ (_)
EOF!
fi
}
sendBuildFailedEmail () {
if [[ "$EMAIL_ADDR_VALUE" != "" ]]
then
msg=$1
EMAIL_ADDR=`cat $EMAIL_FILE`
HEADER_PART=""
if [[ "$DEPLOY_PKG_NAME" = "all" ]]
then
HEADER_PART="oprisk3 - oprisk5 packages"
else
HEADER_PART="$DEPLOY_PKG_NAME package"
fi
/bin/mail -s "[$CURRUSER@$CURRSERVER] Daily build for $HEADER_PART ($BUILD_IDN) >> BUILD FAILED <<" $EMAIL_ADDR_VALUE << EOF!
Build is failed.
Started at: $START_TIMESTAMP
Failed at: `date`
View log file ${LOG_DIR}/${LOG_FILE} for details"
-------------------------
:(
submit2Hermes@$CURRSERVER
--- __o
--- _-\<,_
--- (_)/ (_)
EOF!
fi
}
sendDDLTarFailedEmail () {
if [[ "$EMAIL_ADDR_VALUE" != "" ]]
then
msg=$1
EMAIL_ADDR=`cat $EMAIL_FILE`
HEADER_PART=""
if [[ "$DEPLOY_PKG_NAME" = "all" ]]
then
HEADER_PART="uat1 - uat2 packages"
else
HEADER_PART="$DEPLOY_PKG_NAME package"
fi
/bin/mail -s "[$CURRUSER@$CURRSERVER] Daily DDL build for $HEADER_PART ($BUILD_IDN) >> BUILD FAILED <<" $EMAIL_ADDR_VALUE << EOF!
Build is failed.
Started at: $START_TIMESTAMP
Failed at: `date`
View log file ${LOG_DIR}/${LOG_FILE} for details"
-------------------------
:(
submit2Hermes@$CURRSERVER
--- __o
--- _-\<,_
--- (_)/ (_)
EOF!
fi
}
setBuildDirectory () {
BUILD_DIR=/tmp/$1$CURRUSER
export BUILD_DIR
}
setDDLBuildDirectory () {
BUILD_DIR=/home/$CURRUSER/riskciti/DB
export BUILD_DIR
}
setAllPromtValues () {
if [[ "$1" != "" ]]
then
DEPLOY_PKG_NAME="oprisk3"
setBuildDirectory "$DEPLOY_PKG_NAME"
makeBuildDirectory "$*"
SEND_TO_HERMES_CONFIRM="n"
SRC_AUDIT_CONFIRM="n"
BUILD_PKG_CONFIRM="y"
EMAIL_ADDR_VALUE="oprisk.systems@iuo.ssmb.com"
else
## prompt package name
getPackageName
setBuildDirectory "$DEPLOY_PKG_NAME"
makeBuildDirectory "$*"
## prompt submit package to Hermes
getResponse "Would you like to submit generated tar file to Hermes? "
export SEND_TO_HERMES_CONFIRM=$RESPONSE
## prompt source audit
getResponse "Would you like to run source audit script? "
export SRC_AUDIT_CONFIRM=$RESPONSE
## prompt package make, will create rpm and all jar files
getResponse "Would you like to make package to create RPM? "
export BUILD_PKG_CONFIRM=$RESPONSE
getSVNTree
if [[ "$SVNTREE" != "trunk" ]]
then
getSvnTag
fi
## prompt email notification
emailConfirmation
if [[ "$EMAIL_ADDR_VALUE" = "" ]]
then
printMessage2 "Mail confirmation is not enabled"
fi
fi
}
getFunctionMenu(){
RESP=""
while [ -z "${RESP}" ]
do
printMessage2 "
#############################################################################################
#### # # #### ## ## ##### ##### ##### ##### # # ##### #### ## ## ##### ####
# # # # # # # # # # # # # # # # # # # # # # # # #
### # # #### # ## # # # # # # ##### ##### #### # ## # ##### ###
# # # # # # ## # # # # # # # # # # # # ## # # #
#### ## #### # # ##### # # ##### # # ##### # # # # ##### ####
#############################################################################################
please select the package you want to build:
Available options:
1 - Build all-in-one package (including wars/vendorlibs/scripts).
2 - Build war package for all projects.
3 - Build vendor library package.
4 - Build script package.
5 - Build DDL tar package.
6 - Build separate web application package.
Installation type (default: 1 - Build all-in-one package): \c"
read RESP
case "${RESP:=1}" in
"1")
RESP="build_all" ;;
"2")
RESP="build_war" ;;
"3")
RESP="build_ven" ;;
"4")
RESP="build_scr" ;;
"5")
RESP="build_ddl" ;;
"6")
RESP="build_sep" ;;
*)
printMessage2 "\n***$RESP: invalid response, please use the option letter!"
RESP="" ;;
esac
done
export BUILD_FUNCTION_NAME=${RESP}
printMessage "Hermes: Build ${RESP} package"
}
getPackageName()
{
RESP=""
while [ -z "${RESP}" ]
do
printMessage "
Please enter Hermes deployment package name.
Available options:
1 - oprisk3 ( STABLE 1, UAT 1, PRODUCTION )
2 - oprisk4 ( STABLE 2, UAT 2 )
3 - oprisk5 ( STABLE 3, UAT 3 )
4 - oprisk1 ( STABLE 4)
5 - opriskdr ( CONTINGENCY )
Installation type (default: 1 - oprisk3): \c"
read RESP
case "${RESP:=oprisk3}" in
"1" |"oprisk3")
RESP="oprisk3" ;;
"2" |"oprisk4")
RESP="oprisk4" ;;
"3" |"oprisk5")
RESP="oprisk5" ;;
"4" |"oprisk1")
RESP="oprisk1" ;;
"5" |"opriskdr")
RESP="opriskdr" ;;
*)
printMessage2 " *** $RESP: invalid response, please use the option letter or action keyword."
RESP="" ;;
esac
done
export DEPLOY_PKG_NAME=${RESP}
printMessage "Hermes deployment package name set to: ${RESP}"
}
getDDLPackageName()
{
RESP=""
while [ -z "${RESP}" ]
do
printMessage "snektal added STABLE 4
Please enter Hermes deployment package name.
Available options:
1 - uat1 ( UAT 1)
2 - uat2 ( UAT 2)
3 - uat3 ( UAT 3)
Installation type (default: 1 - uat1): \c"
read RESP
case "${RESP:= uat1}" in
"1" |"uat1")
RESP="OPRISKQ1_NEW" ;;
"2" |"uat2")
RESP="OPRISKQ2_NEW" ;;
"3" |"uat3")
RESP="OPRISKQ3_NEW" ;;
*)
printMessage2 "
*** $RESP: invalid response, please try again!
Use the option letter or action keyword."
RESP=""
;;
esac
done
DEPLOY_PKG_NAME=${RESP}
printMessage "Hermes deployment package name set to: ${RESP}"
export DEPLOY_PKG_NAME
}
getTarFileNames () {
printMessage " Getting tar file names. "
cd $BUILD_DIR/riskciti
echo "`ls *.tar`" > $TAR_FILE_NAMES_TEMP
}
moveFilesToArchive () {
if [[ ! -d $ARCHIVE_DIR ]]
then
mkdir -p $ARCHIVE_DIR
fi
cd $BUILD_DIR/riskciti/oprisk/install
#mv war_deployments $ARCHIVE_DIR/.
#mv ejb_deployments $ARCHIVE_DIR/.
#mv lib $ARCHIVE_DIR/.
cd $BUILD_DIR/riskciti
mv *.Z $ARCHIVE_DIR/.
cd -
}
setVariable () {
clear
# set PATH for paudit
PATH="$PATH:/xenv/scripts/bin"
export PATH
export CURRUSER=`logname`
export CURRSERVER=`hostname`
export EMAIL_FILE=/tmp/$CURRUSER"_mailaddr"
export BUILD_DATE=`date +%m%d%Y`
export LOG_FILE="submit2Hermes_"${BUILD_DATE}".log"
export LOG_DIR=$HOME/logs
export SENT_TO_HERMES_TEMP=/tmp/send_to_hermes$$
export TAR_FILE_NAMES_TEMP=/tmp/tar_file_names$$
export BUILD_IDN="build id = "$$
#### variables definition
START_TIMESTAMP=`date`
SVN_TAG_NAME=""
SVNTREE=""
SVNROOT=/svn/34896/newoprisk
SVNPREFIX=https://svn.nam.nsroot.net:9050
# value that indicates if already in cross env
ENV_SET_FLAG="n"
# default name for deploying package
BUILD_FUNCTION_NAME="build_all"
DEPLOY_PKG_NAME="oprisk4"
BUILD_PKG_CONFIRM=""
SEND_TO_HERMES_CONFIRM=""
SRC_AUDIT_CONFIRM=""
DELETE_EXISTING_BUILD=""
ARCHIVE_EXISTING_BUILD=""
INCLUDE_CASA_CONFIRM=""
EMAIL_ADDR_VALUE=""
ALL_PKG_FLAG="0"
OPTIONS_STATUS_MSG=""
OPTIONS_CONFIRM=""
}
################################################
### start here
################################################
mainFunction () {
BUILD_DIR=""
if [ ! -d $LOG_DIR ]
then
mkdir ${LOG_DIR}
fi
setAllPromtValues "$*"
PKG_NAME=$CURRUSER"_"$DEPLOY_PKG_NAME
PADUIT_LOG=/tmp/$PKG_NAME.paudit$$
if [[ "$SVN_TAG_NAME" = "" ]]
then
ARCHIVE_DIR=$CURRUSER"_DAILY_NOTAG_"$BUILD_DATE
else
ARCHIVE_DIR=$CURRUSER"_DAILY_"$SVN_TAG_NAME"_"$BUILD_DATE
fi
if [[ -d /home/$CURRUSER ]]
then
printMessage "Home for user $CURRUSER exists"
ARCHIVE_DIR=/home/$CURRUSER/$ARCHIVE_DIR
else
printMessage "Home for user $CURRUSER does NOT exist"
ARCHIVE_DIR=/var/temp/archive/$ARCHIVE_DIR
fi
export ARCHIVE_DIR
sendStartedEmailNotification
if [[ "$1" != "" ]]
then
verifyEnteredParameters
while [[ "$OPTIONS_CONFIRM" = [Nn]* ]]
do
setAllPromtValues
verifyEnteredParameters
done
fi
checkFileOutFromSVN
## go to pkg directory
jumpToRootDir
# Delete files / dirs that should not be included in package.
cleanPackage
runPkgAudit
printMessage "LOOPING DEPLOY_PKG_NAME = $DEPLOY_PKG_NAME"
export DEPLOY_PKG_NAME
#replace package name in SPEC file
evaluateEnv
createTarFile "$DEPLOY_PKG_NAME"
runTestMake
sendTarFilesToHermes
printMessage "Please review log file ${LOG_DIR}/${LOG_FILE} for build details"
FINISH_TIMESTAMP=`date`
if [[ "$BUILD_PKG_CONFIRM" = [Yy] ]]
then
moveFilesToArchive
fi
sendCompletedEmailNotification
printMessage2 "Started @ $START_TIMESTAMP"
printMessage2 "Finished @ $FINISH_TIMESTAMP"
cd /tmp
#\rm -fr $BUILD_DIR
}
sendDDLTarToHermes () {
jumpToBuildDir
find $BUILD_DIR -type d -name "*svn*" -exec rm -rf {} \; -print
cd OpRisk
chmod -R 777 *
for i in `find . -type f`
do
cp $i $i.copy
tr -d '\r' < $i.copy > $i
sed "s/OPRISKQ1_NEW/$DEPLOY_PKG_NAME/g" $i > $i.copy
rm -rf $i
mv $i.copy $i
done
cd ..
printMessage "Success to dos2unix."
if [[ -f OpRisk.tar ]]
then
rm -rf OpRisk.tar
printMessage "Success to delete OpRisk.tar."
fi
tar -cvf OpRisk.tar ./OpRisk
if [[ $? -eq 1 ]]
then
printMessage "Error. failed to tar source file to OpRisk.tar. "
printMessage ":("
exit 1
## sendDDLTarFailedEmail
fi
printMessage "Success to tar source file to OpRisk.tar."
if [[ "$SEND_TO_HERMES_CONFIRM" = "y" || "$SEND_TO_HERMES_CONFIRM" = "Y" ]]
then
printMessage "Sending DDL tar file to HERMES "
pwd
cd ..
pwd
##send package to hermes
/xenv/scripts/bin/send_to_hermes $BUILD_DIR/OpRisk.tar
if [ $? -eq 1 ]
then
printMessage "Error. failed to send file $i to hermes. exiting. "
printMessage ":("
exit 1
fi
printMessage2 "Sent following file(s) to Hermes:"
printMessage2 "`cat $SENT_TO_HERMES_TEMP | grep -v 'Sending' | grep -v 'New' | grep -v '-' | grep '.Z'`"
printMessage2 "Success. Go ahead and submit the job to Hermes"
printMessage2 ":)"
fi
}
submitDDL () {
getDDLPackageName
setDDLBuildDirectory
makeDDLBuildDirectory
## prompt submit package to Hermes
getResponse "Would you like to submit generated tar file to Hermes? "
export SEND_TO_HERMES_CONFIRM=$RESPONSE
getSVNTree
if [[ "$SVNTREE" != "trunk" ]]
then
getSvnTag
fi
## prompt email notification
emailConfirmation
if [[ "$EMAIL_ADDR_VALUE" = "" ]]
then
printMessage2 "Mail confirmation is not enabled"
fi
## sendDDLStartedEmailNotification
SRC_AUDIT_CONFIRM=n
verifyEnteredParameters
makeLogDirectory
checkDDLFileOutFromSVN
sendDDLTarToHermes
## sendDDLCompletedEmailNotification
}
#****************************************************************************************
# execution starts here #
#****************************************************************************************
trap 'removeTempFiles; sendBuildIterruptedEmail; exit 1' 1 2 3 6 15
setVariable
makeLogDirectory
getFunctionMenu
if [[ "$BUILD_FUNCTION_NAME" = "build_all" ]]
then
mainFunction "$*"
fi
if [[ "$BUILD_FUNCTION_NAME" = "build_war" ]]
then
echo $BUILD_FUNCTION_NAME
fi
if [[ "$BUILD_FUNCTION_NAME" = "build_sep" ]]
then
echo $BUILD_FUNCTION_NAME
fi
if [[ "$BUILD_FUNCTION_NAME" = "build_ven" ]]
then
echo $BUILD_FUNCTION_NAME
fi
if [[ "$BUILD_FUNCTION_NAME" = "build_scr" ]]
then
echo $BUILD_FUNCTION_NAME
fi
if [[ "$BUILD_FUNCTION_NAME" = "build_ddl" ]]
then
submitDDL "$*"
fi
result=$?
echo "********** \n**********\n\tRESULT = $result"
if [ $result -gt 0 ]
then
printMessage "Error. build failed. Exiting. View log file ${LOG_DIR}/${LOG_FILE} for details"
printMessage2 ":("
sendBuildFailedEmail
exit 1
fi
exit 0