#!/bin/bash ########################################################################### # # # DO NOT CHANGE THIS FILE - IT WILL BE OVERWRITTEN !!! # # # ########################################################################### # NAME # stop.all - Stop all application modules (AdminServer, databases etc) # # DESCRIPTION # Script to stop all environments under this install # # SYNTAX # stop.all [environment] # # AUTHOR # written by David Cohen # # REVISION HISTORY # 0.1 01/01/2010 ddc - Initial Creation # 0.2 02/14/2012 j6b - Add header information and security # 0.3 03/08/2012 j6b - Add tomcat for Qxtend and set DLC correctly # 0.4 10/09/2015 j6b - Use qclib.sh for setting of variables # 0.5 10/13/2015 j6b - Use 'default' naming convention # 0.6 10/21/2015 j6b - Adding comments from r3h (Ron Hunt) # 0.7 11/12/2015 j6b - Add running customized code if qcCUST exists # 0.8 11/16/2015 j6b - Change logfile permissions # 0.91 03/01/2016 j6b - Use the scripts in odutils (primary) or local # 0.92 03/01/2016 j6b - Replace qclib.sh with LIB directory # 0.93 04/11/2016 j6b - Add appman.sh call # 1.0 04/12/2016 j6b - Frozen v1.0 version # 1.1 08/31/2016 j6b - CLDBA-997 - Call checkDown.sh for hanging PIDs # 1.2 10/02/2018 j6b - CLDBA-2542: Add logic for TMS window services # 1.3 11/14/2018 j6b - CLDBA-2595: Add logic for Boomi # 1.4 11/30/2018 p9p - CLPMR-2322: Move appman execution before checkDown # 1.5 11/30/2021 p9p - CLDBA-6321: Added logic for MariaDB database # ------------------------------------------------------------------------- # vim:ts=4 VERS=1.5 # Version of this script. ##----------------## ## Load Libraries ## ##----------------## _me=${0} _libdir=$(dirname ${_me})/../scripts/lib typeset -i _libcount=0 if [[ -d ${_libdir} ]] then # Load standard libraries for i in $(ls ${_libdir}/*std.LIB 2> /dev/null) do source ${i} _libcount=$((_libcount + 1)) done # Load customized libraries - if applicable for i in $(ls ${_libdir}/*cst.LIB 2> /dev/null) do source ${i} done else echo "Library ${_libdir} not found" exit 99 fi if [[ ${_libcount} = 0 ]] then echo "No libraries loaded from ${LIB}" exit 99 fi if [[ "${1}" == "-h" ]] || [[ "${1}" == "--help" ]] then dispHelp; exit 0 fi ##------------------## ## Local Variables ## ##------------------## getEnv ${1} TERM=xterm;export TERM _scriptdir=/${qcLOC}/apps/mfgpro/scripts ##------------------## ## Define Functions ## ##------------------## stopAction() { # Syntax: stopAction script module _script=${1} _module=${2} if [[ -x ${_scriptdir}/${_script} ]] then if ! ${_scriptdir}/${_script} ${qcENV} then _errno=${?} logMsg ERR "local: ${_script} FAILED - exitcode: ${_errno}" errorHandler ${?} ERR "${_module} could not be stopped" else logMsg INF "local: ${_script} completed" fi elif [[ -x ${qcUTILS}/qond/scripts/${_script} ]] then if ! ${qcUTILS}/qond/scripts/${_script} ${qcENV} then _errno=${?} logMsg ERR "remote: ${_script} FAILED - exitcode: ${_errno}" errorHandler ${?} ERR "${_module} could not be stopped" else logMsg INF "remote: ${_script} completed" fi else logMsg INF "${_script} for ${_module} not available" fi } ##----------------## ## M A I N ## ##----------------## checkUser errorHandler ${?} ERR "This user is not allowed to stop the environment" if [[ -f ${qcLOGFILE} ]] then _cmd="${qcCMD} /bin/mv -f ${qcLOGFILE} ${qcLOGFILE}.$(date '+%d')" eval ${_cmd} fi # Create logfile with right permissions _cmd="${qcCMD} touch ${qcLOGFILE}" eval ${_cmd} logMsg INF "Script starts. (v=${VERS}) (PID=$$)" if [[ "${qcENV}" == "dr" ]] then # Only stop all databases #[[ -f ${qcUTILS}/qond/scripts/stopdb.sh ]] && ${qcUTILS}/qond/scripts/stopdb.sh ${qcENV} && errorHandler ${?} ERR "Databases could not be stopped" stopAction stopdb.sh Databases logMsg INF "Script ends (DR system)." exit 0 fi # Execute customized code if [[ -f ${qcCUST} ]] then logMsg INF "Customized code started" eval "${qcCMD} ${qcCUST} ${qcENV}" logMsg INF "Customized code ended" fi if BoomiInstalled ; then # Stop Boomi #[[ -x ${_scriptdir}/stopboomi.sh ]] && ${_scriptdir}/stopboomi.sh && errorHandler ${?} ERR "Boomi could not be stopped" stopAction stopboomi.sh "Boomi" else # Stop Radley background processes [[ -d /${qcLOC}/apps/radley/rpcc ]] && /${qcLOC}/apps/radley/rpcc/stop.${qcLOC}.rpcc.sh && errorHandler ${?} ERR "Radley could not be stopped" # Stop Windows TMS service #[[ -x ${_scriptdir}/stop.tmswebui ]] && ${_scriptdir}/stop.tmswebui && errorHandler ${?} ERR "Windows services could not be stopped" stopAction stop.tmswebui "Window TMS services" # Stop Windows service #[[ -x ${_scriptdir}/stop.qrs ]] && ${_scriptdir}/stop.qrs && errorHandler ${?} ERR "Windows services could not be stopped" stopAction stop.qrs "Window services" #Stop EE daemons if [[ -x ${_scriptdir}/daemons.bash ]] then logMsg INF "Stop EE daemons" ${_scriptdir}/daemons.bash stop errorHandler ${?} ERR "EE Daemons could not be stopped" fi # Stop QXtend tomcat #[[ -x ${_scriptdir}/stop.tomcat_qx ]] && ${_scriptdir}/stop.tomcat_qx && errorHandler ${?} ERR "Tomcat QXtend could not be stopped" stopAction stop.tomcat_qx "Tomcat QXtend" # Stop tomcat #[[ -x ${_scriptdir}/stop.tomcat ]] && ${_scriptdir}/stop.tomcat && errorHandler ${?} ERR "Tomcat could not be stopped" stopAction stop.tomcat Tomcat # Stop all Appservers #[[ -x ${qcUTILS}/qond/scripts/stopaps.sh ]] && ${qcUTILS}/qond/scripts/stopaps.sh ${qcENV} && errorHandler ${?} ERR "Appservers could not be stopped" stopAction stopaps.sh Appservers # Stop all databases #[[ -x ${qcUTILS}/qond/scripts/stopdb.sh ]] && ${qcUTILS}/qond/scripts/stopdb.sh ${qcENV} && errorHandler ${?} ERR "Databases could not be stopped" stopAction stopdb.sh Databases #Stop Maria Database [[ -x ${_scriptdir}/stop.mariadb ]] && stopAction stop.mariadb Database # Stop AdminServer #[[ -x ${qcUTILS}/qond/scripts/stop.admin ]] && ${qcUTILS}/qond/scripts/stop.admin ${qcENV} && errorHandler ${?} ERR "AdminServer could not be stopped" stopAction stop.admin AdminServer # Call application management script # CLDBA-1780 - j6b - 07/24/2017 # If local appman.sh is available execute the local one # otherwise execute the one in /usr/remote/odutils if [[ -x ${_scriptdir}/appman.sh ]] ; then logMsg INF "local appman.sh starts" ${_scriptdir}/appman.sh -e ${qcLOC} logMsg INF "local appman.sh ends." elif [[ -f ${qcUTILS}/qond/scripts/appman.sh ]] ; then logMsg INF "appman.sh starts" ${qcUTILS}/qond/scripts/appman.sh -e ${qcLOC} logMsg INF "appman.sh ends." fi fi # CLDBA-997 - Look for hanging processes stopAction checkDown.sh All logMsg INF "Script ends." exit 0