#!/bin/ksh93 # ALTRAN_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # Copyright (C) Altran ACT S.A.S. 2017,2021. All rights reserved. # # ALTRAN_PROLOG_END_TAG # # IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # 61haes_r721 src/43haes/lib/ksh93/ezupdate/common.sh 1.3 # # Licensed Materials - Property of IBM # # COPYRIGHT International Business Machines Corp. 2016 # All Rights Reserved # # US Government Users Restricted Rights - Use, duplication or # disclosure restricted by GSA ADP Schedule Contract with IBM Corp. # # IBM_PROLOG_END_TAG # @(#) 7d4c34b 43haes/lib/ksh93/ezupdate/common.sh, 726, 2147A_aha726, Feb 05 2021 09:50 PM typeset scriptname=${0##*/} typeset scriptargs="$*" ############################################################################## # Global variables for log ############################################################################## export PS4='EZUpdate:$scriptname[$LINENO]:${0##*/}:($SECONDS) ' # log level, by default 0 export CLEZUPDATE_LOG_LEVEL=5 # log file, by default /var/hacmp/EZUpdate/EZUpdate.log export CLEZUPDATE_LOG_DIR="/var/hacmp/EZUpdate" export CLEZUPDATE_LOG_FILE="${CLEZUPDATE_LOG_DIR}/EZUpdate.log" # log mode, either append or wrap # append if CLEZUPDATE_LOG_APPEND=1 # wrap if CLEZUPDATE_LOG_APPEND=0 # By default wrap mode export CLEZUPDATE_LOG_APPEND=0 ############################################################################## # Global variables for accessing utilities ############################################################################## typeset TOOLDIR=/usr/es/sbin/cluster/utilities typeset CLMGR_CMD="$TOOLDIR/clmgr" typeset CAA_CLRSH=/usr/sbin/clrsh typeset HA_CLRSH=${TOOLDIR}/cl_rsh typeset CLRSH=$HA_CLRSH #CLRSH -n typeset CLRCP=${TOOLDIR}/cl_rcp typeset CLHANDLE="${TOOLDIR}/clhandle -a" typeset GET_LOCAL_NODENAME="${TOOLDIR}/get_local_nodename" typeset CSPOCDIR=/usr/es/sbin/cluster/cspoc typeset CLI_ON_NODE="/usr/es/sbin/cluster/cspoc/cli_on_node -N" export PATH=$PATH if [[ -f $TOOLDIR/cl_get_path ]]; then export PATH=$($TOOLDIR/cl_get_path all) export OP_SEP=$(${TOOLDIR}/cl_get_path -S 2>/dev/null) export OP_SEP=${OP_SEP:-\~} fi ############################################################################## # Global variables for msg catalogs ############################################################################## typeset EZUPDATE_MSGS=ezupdate.cat typeset CLUSTER_T_SET=1 typeset NODE_T_SET=2 typeset CL_EZUPDATE_MAIN_SET=3 typeset CL_EZUPDATE_USAGE_SET=4 typeset CL_EZUPDATE_USEREXIT_SET=5 typeset CL_EZUPDATE_CHECKNIM_SET=6 typeset CL_EZUPDATE_CHECKLPPS_SET=7 typeset CL_EZUPDATE_CHECKIFIX_SET=8 typeset CL_EZUPDATE_INSTALL_SET=9 typeset DSPMSG="/usr/bin/dspmsg $EZUPDATE_MSGS -s" typeset CANNOT_INT_MSG="$($DSPMSG $CL_EZUPDATE_USEREXIT_SET 4 'Cannot interrupt, please retry later.\n')" ############################################################################## # Global constants ############################################################################## typeset -r ACTION=( Q="QUERY" P="PREVIEW" C="COMMIT" R="REJECT" A="APPLY" B="BOOT" QUERY="QUERY" PREVIEW="PREVIEW" COMMIT="COMMIT" REJECT="REJECT" APPLY="APPLY" BOOT="BOOT" ) typeset -r MODE_TYPE=( H="HELP" A="AUTOMATIC" ) typeset -r MSG_TYPE=( ERR="ERROR" WARN="WARNING" INF="INFO" ) typeset -r UPDATE_SOURCE=( LOCAL="LOCAL" NIM="NIM" ) typeset -r NODE_LOCALIZATION=( LOCAL="local" REMOTE="remote" ) typeset -r MANAGE_MODE=( ONLINE="online" AUTO="auto" MANUAL="manual" UNMANAGE="unmanage" OFFLINE="offline" MOVE="move" NON_DISRUPTIVE="non_disruptive" SILENT="silent" ROLLING="rolling" NONE="none" ) typeset -r RC=( OK=0 FAILURE=1 PARAM_ERROR=2 PING_ERROR=3 SSH_ERROR=4 EMPTY_DIR=6 PHA_CMD_ERROR=7 NOT_FOUND=8 RG_CANNOT_MOVE=9 WARNING=127 QUIESCE_REBOOT=200 QUIESCE_NO_REBOOT=201 UNKNOWN=-99 ) ##################################################################### # # NAME: DSP_MSG # # FUNCTION: # Display an error message with internationalization to stderr. # Log the message into the logfile with the right prefix. # # EXECUTION ENVIRONMENT: # # NOTES: # # RECOVERY OPERATION: none # # DATA STRUCTURES: # parameters: # 1: the MSG_TYPE can be ERROR | INFO # 2: parameter for DSPMSG function # global: # # RETURNS: none # # OUTPUT: display messages ##################################################################### function DSP_MSG { [[ "$VERBOSE_LOGGING" == "yes" ]] && set -x [[ "$DEBUG_MODE" == "yes" ]] && set -x typeset msg="" typeset msg_type="$1" typeset msg_set="$2" typeset msg_no="$3" typeset msg_def=$4 shift 4 msg=$($DSPMSG $msg_set $msg_no "$msg_def" "$@") print -- "$msg" if [[ $msg_type == ${MSG_TYPE.ERR} ]] then log_error "$msg" elif [[ $msg_type == ${MSG_TYPE.WARN} ]] then log_warn "$msg" else log_trace 0 "$msg" fi } # End of "DSP_MSG()" ##################################################################### # # NAME: WALL_MSG # # FUNCTION: # Displays the message on the wall. # # EXECUTION ENVIRONMENT: # # NOTES: # # RECOVERY OPERATION: none # # DATA STRUCTURES: # parameters: # 1: parameter for DSPMSG function # global: # # RETURNS: none # # OUTPUT: display messages ##################################################################### function WALL_MSG { [[ "$VERBOSE_LOGGING" == "yes" ]] && set -x [[ "$DEBUG_MODE" == "yes" ]] && set -x typeset msg="" typeset msg_set="$1" typeset msg_no="$2" typeset msg_def=$3 shift 3 msg=$($DSPMSG $msg_set $msg_no "$msg_def" "$@") wall -- "$msg" } # End of "WALL_MSG()"