#!/bin/bash set -e yell() { printf "\033[1;6;37;41m$0: $*\033[0m\n" >&2; } die() { yell "$*" exit 111 } try() { "$@" || die "FAIL: $*"; } cmd() { local info="${2:-$1}" echo "==================================================" echo -e "💡 $info " echo "==================================================" eval "$1" } # . /opt/IBM/ace-12.0.9.0/server/bin/mqsiprofile cat /opt/mdw/bars/broker_list config=$(cat /opt/mdw/bars/broker.log | tr ' ' '\n' | grep -vF 'BROKER\;EXECUTIONGROUP\;QM\;PORT\;MAXHEAP\;JAVAOSSTACK\;HTTP_PORT') target=$VAR2 path=$VAR3 BROKER=$VAR4 AWAKE=$VAR5 if [[ $target == "DRC" ]]; then if [[ $(mqsilist | grep "$BROKER" | grep "stopped") ]]; then if [[ $(dspmq | grep ${BROKER}.QM | grep "Ended") ]]; then try cmd "strmqm ${BROKER}.QM > output.log 2>&1 &" \ "Start QM ${BROKER}.QM" sleep 30 fi try cmd "mqsistart $BROKER > output.log 2>&1 &" \ "Start Integration Node $BROKER" sleep $((2 * 60)) fi fi while read -r line; do trimmed_line=$(echo "$line" | xargs) if [[ "$line" == "BROKER;EXECUTIONGROUP;QM;PORT;MAXHEAP;JAVAOSSTACK;HTTP_PORT;HTTPS_PORT;EMBEDDED_LISTENER" || "$trimmed_line" == "" ]]; then echo "No need to execute because is line 1 or blank" else broker=$(echo "$line" | cut -d';' -f 1) executiongroup=$(echo "$line" | cut -d';' -f 2) qm=$(echo "$line" | cut -d';' -f 3) port=$(echo "$line" | cut -d';' -f 4) maxHeap=$(echo "$line" | cut -d';' -f 5) osStack=$(echo "$line" | cut -d';' -f 6) httpPort=$(echo "$line" | cut -d';' -f 7) httpsPort=$(echo "$line" | cut -d';' -f 8) embListener=$(echo "$line" | cut -d';' -f 9) # cek jika belum ada directory # if [[ ! -d "$path/$broker" ]]; then # try cmd "mkdir -m 775 -p $path/$broker" \ # "Create directory $broker" # fi if [[ ! $(mqsilist | grep "$broker") ]]; then try cmd "mqsicreatebroker $broker -q $qm -e $path/$broker" \ "Create Integration Node $broker" try cmd "mqsichangeproperties $broker -b webadmin -o HTTPConnector -n port -v $port" \ "Setup Integration Node port : $port" fi # start jika broker stop if [[ $(mqsilist | grep "$broker" | grep "stopped") ]]; then try cmd "mqsistart $broker" \ "Start Integration Node $broker" fi # cek kalau belum ada executiongroup if [[ ! $(mqsilist "$broker" | grep "$executiongroup") ]]; then try cmd "mqsicreateexecutiongroup $broker -e $executiongroup" \ "Create Intergration Server $executiongroup" try cmd "mqsichangeflowstats $broker -e $executiongroup -s -c inactive" \ "Disable accumulation of statistics about message flow" try cmd "mqsichangeresourcestats $broker -e $executiongroup -c inactive" \ "Disable control statistics gathering for resources" fi # Cek kalau executiongroup is stop if [[ $(mqsilist "$broker" | grep "$executiongroup" | grep "stopped") ]]; then try cmd "mqsistart $broker -e $executiongroup -w 1800" \ "Start Integration Server $executiongroup" fi # cek jika tidak null broker properties MAXHEAP if [[ ! "$(mqsireportproperties "$broker" -e "$executiongroup" -o ComIbmJVMManager -n jvmMaxHeapSize | grep -vE '^$|BIP')" == "$maxHeap" ]]; then try cmd "mqsichangeproperties $broker -e $executiongroup -o ComIbmJVMManager -n jvmMaxHeapSize -v $maxHeap" \ "Change properties jvmMaxHeapSize $maxHeap" fi # cek jika tidak null broker properties JAVOSSTACK if [[ ! "$(mqsireportproperties "$broker" -e "$executiongroup" -o ComIbmJVMManager -n jvmJavaOSStackSize | grep -vE '^$|BIP')" == "$osStack" ]]; then try cmd "mqsichangeproperties $broker -e $executiongroup -o ComIbmJVMManager -n jvmJavaOSStackSize -v $osStack" \ "Change properties jvmJavaOSStackSize $osStack" try cmd "mqsichangeproperties $broker -e $executiongroup -o ComIbmJVMManager -n jvmSystemProperty -v \"-Dlogback.configurationFile=/opt/mdw/jplugin/logback.xml\"" \ "Change properties jvmSystemProperty $executiongroup '-Dlogback.configurationFile=/opt/mdw/jplugin/logback.xml'" fi if [[ -z "$httpPort" ]]; then echo "httpPort is empty or unset" else try cmd "mqsichangeproperties $broker -e $executiongroup -o HTTPConnector -n ListenerPort -v $httpPort" \ "Change properties HTTPConnector ListenerPort $httpPort" fi if [[ -z "$httpsPort" ]]; then echo "httpsPort is empty or unset" else try cmd "mqsichangeproperties $broker -e $executiongroup -o HTTPSConnector -n ListenerPort -v $httpsPort" \ "Change properties HTTPSConnector ListenerPort $httpsPort" fi if [[ $target == "DC" ]]; then if [[ $(mqsilist "$broker" | grep "$executiongroup" | grep "stopped") ]]; then echo "no need to start, beacause executiongroup is stop" else try cmd "mqsistop $broker -e $executiongroup -w 1800" \ "Stop Integration Server $executiongroup" fi if [[ -z "$embListener" ]]; then echo "Embedded Listerner is empty or unset" else try cmd "mqsichangeproperties $broker -f -e $executiongroup -o ExecutionGroup -n httpNodesUseEmbeddedListener -v true" \ "Change properties ExecutionGroup httpNodesUseEmbeddedListener $embListener" fi try cmd "mqsistart $broker -e $executiongroup -w 1800" \ "Start Integration Server $executiongroup" fi fi done <<<"$config" if [[ $target == "DRC" && $AWAKE == false ]]; then try cmd "mqsistop $BROKER > output.log 2>&1 &" \ "Stop Integration Node $BROKER" sleep $((2 * 60)) try cmd "endmqm -i $qm" \ "Stop QM $qm" sleep $((2 * 60)) fi