########################################################################
# (c) Copyright 2006-2009, 2016-2017, 2020 Hewlett Packard Enterprise Development LP
# @(#) Serviceguard UPCC Package Configuration Script Template
# @(#) Product Name : HPE Serviceguard
# @(#) Product Version : A.12.80.03
# @(#) Patch Name :
#
# **********************************************************************
# * *
# * This script is a template that can be used when creating a *
# * customer defined script. *
# * *
# * Once created, this script can be configured into the package *
# * configuration file with the "external_script" and *
# * "external_pre_script" parameters. Note that the respective *
# * "sg/external" and the "sg/external_pre" module need to be *
# * specified in the package configuraton file in order to *
# * configure these parameters. The master control script will *
# * then invoke the script at the pre-defined entry point among *
# * Serviceguard provided scripts depending on the parameter used. *
# * *
# * This script replaces the existing "customer_defined_run_cmds()" *
# * and "customer_defined_halt_cmds()" functions in the pre-11.18 *
# * control script. *
# * *
# * --------- *
# * I N P U T *
# * --------- *
# * The script should expect the following parameters when called *
# * by the master control script: *
# * *
# * $1 : script action or operation - start, stop or validate *
# * $2 : a temporary file name containing the package specific *
# * environment variables. This parameter is optional for *
# * "start" and "stop" action. *
# * *
# * ----------- *
# * O U T P U T *
# * ----------- *
# * The script should exit with the following values: *
# * *
# * 0 : if success *
# * 1 : When the package should not be restarted as a result of *
# * failure in this script. *
# * 2 : When package should not restart on the local node, but *
# * can be restarted from another node. *
# * *
# * ----------------------------------------- *
# * E N V I R O N M E N T V A R I A B L E S *
# * ----------------------------------------- *
# * The following environment variables are exported by the package *
# * manager or the master control script: *
# * *
# * SG_PACKAGE : name of the package to operate on *
# * (available at package run and halt *
# * time only. At package validation time, *
# * SG_PACKAGE_NAME can be used as a *
# * substitute.) *
# * SG_NODE : name of the node the script is invoked on *
# * (available at package run and halt *
# * time only, not at package validation *
# * time.) *
# * SG_SCRIPT_LOG_FILE: name of the package log file *
# * (available at package run and halt *
# * time only, not at package validation *
# * time.) *
# * SG_UTILS : name of the utility function file *
# * located at: *
# * $SGCONF/scripts/mscripts/utils.sh *
# * (exported by the master control script) *
# * SG_ENV_FILE : temporary file which contains the *
# * package parameters in a posix shell *
# * format. The file can be passed in as *
# * an argument, or generated by the *
# * function sg_source_pkg_env, that invokes *
# * the command cmgetpkgenv (see man page *
# * for details). *
# * (exported by the master control script) *
# * *
# * --------------------------------- *
# * U T I L I T Y F U N C T I O N S *
# * --------------------------------- *
# * The following utility functions are sourced in from $SG_UTILS *
# * ($SGCONF/scripts/mscripts/utils.sh) and available for use: *
# * *
# * sg_log <log level> <log msg> *
# * *
# * By default, only log messages with a log level of 0 will *
# * be output to the log file. If parameter "log_level" is *
# * configured in the package configuration file, then log *
# * messages that have a log level that is equal to or *
# * greater than the configured log level will be output. *
# * *
# * In addition, the format of the time stamp is prefixed in *
# * front of the log message. *
# * *
# * *
# * sg_source_pkg_env <operation> [<pkg environment file>] *
# * *
# * source in the package specific environment variables *
# * *
# **********************************************************************
#
########################################################################
###########################
# Source utility functions.
###########################
if [[ -z $SG_UTILS ]]
then
. /etc/cmcluster.conf
SG_UTILS=$SGCONF/scripts/mscripts/utils.sh
fi
if [[ -f ${SG_UTILS} ]]; then
. ${SG_UTILS}
if (( $? != 0 ))
then
echo "ERROR: Unable to source package utility functions file: ${SG_UTILS}"
exit 1
fi
else
echo "ERROR: Unable to find package utility functions file: ${SG_UTILS}"
exit 1
fi
###################################################################
#
# Get the environment for this package through utility function
# sg_source_pkg_env().
#
###################################################################
sg_source_pkg_env $*
#########################################################################
#
# validate_command
#
# This function should define actions to take when the package is
# being validated during cmcheckconf/cmapplyconf on all the configured
# package nodes.
#
#########################################################################
function validate_command
{
# Output messages will only be displayed in STDOUT, if there is
# any error condition while executing the master control script
# with a "validate" parameter from cmcheckconf/cmapplyconf command
sg_log 5 "validate_command"
# ADD your package validation steps here
return 0
}
#########################################################################
#
# start_command
#
# This function should define actions to take when the package starts
#
#########################################################################
function start_command
{
sg_log 5 "start_command"
# ADD your package start steps here
if [ "${HOSTNAME}" = "gerpap1" ]; then
su - sgpadm -c "/usr/sap/SGP/SYS/exe/uc/linuxx86_64/sapcontrol -nr 00 -prot NI_HTTP -function StartService SGP"
sleep 5
su - sgpadm -c "/usr/sap/SGP/SYS/exe/uc/linuxx86_64/sapcontrol -nr 00 -prot NI_HTTP -function Start"
fi
sleep 30
su - sgpadm -c "sapcontrol -nr 02 -function RestartInstance"
return 0
}
#########################################################################
#
# stop_command
#
# This function should define actions to take when the package halts
#
# It's recommended that the actions performed in this function should be
# made idempotent, that is if the halt action has already been performed
# successfully before, it should not generate an error, but exit successfully.
#
# All SG provided scripts are currently idempotent.
#
#########################################################################
function stop_command
{
sg_log 5 "stop_command"
if [ "${HOSTNAME}" = "gerpap1" ]; then
su - sgpadm -c "/usr/sap/SGP/SYS/exe/uc/linuxx86_64/sapcontrol -nr 00 -prot NI_HTTP -function Stop"
sleep 5
su - sgpadm -c "/usr/sap/SGP/SYS/exe/uc/linuxx86_64/sapcontrol -nr 00 -prot NI_HTTP -function StopService"
su - sgpadm -c "/usr/sap/SGP/SYS/exe/uc/linuxx86_64/cleanipc 00 remove"
fi
# ADD your package halt steps here
return 0
}
################
# main routine
################
sg_log 5 "customer defined script"
#########################################################################
#
# Customer defined external script must be specified with three required
# entry points: start, stop, and validate.
#
# It's not recommended to add additional entry points to the script
# due to potential name space collision with future Serviceguard releases.
#
#########################################################################
typeset -i exit_val=0
case ${1} in
start)
start_command $*
exit_val=$?
;;
stop)
stop_command $*
exit_val=$?
;;
validate)
validate_command $*
exit_val=$?
;;
*)
sg_log 0 "INFO: Unknown operation: $1"
;;
esac
exit $exit_val
댓글 없음:
댓글 쓰기