#!/bin/ksh93
# IBM_PROLOG_BEGIN_TAG 
# This is an automatically generated prolog. 
#  
# 61haes_r721 src/43haes/usr/sbin/cluster/utilities/Scluster.sh 1.2 
#  
# Licensed Materials - Property of IBM 
#  
# Restricted Materials of IBM 
#  
# COPYRIGHT International Business Machines Corp. 2015 
# 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 
##################################################
# name: Scluster
# inputs: should only be start
# returns: 1 for Usage, otherwise returns 0
# purpose: start IBM.ConfigRM at system reboot if not
# started.
##################################################

case "$1" in
start )
        CLNAME=$(/usr/sbin/rsct/bin/ct_clusterinfo -c)
        if [[ -n $CLNAME && $CLNAME != "IW" ]]; then
                CTHAGSPID=$(LANG=C lssrc -s cthags | tail -n 1 | awk '{ print $3 }')
                CONFIGRMPID=$(LANG=C lssrc -s IBM.ConfigRM| tail -n 1 | awk '{ print $3 }')
                if [[ "${CTHAGSPID}" != "inoperative" && "${CONFIGRMPID}" == "inoperative" ]]; then
                        # (re)start IBM.ConfigRM if needed ... "Kcluster stop" probably stopped it
                        echo "Starting IBM.ConfigRM..."
                        startsrc -s IBM.ConfigRM
                fi
        fi
        exit 0
        ;;
* )
        echo "Usage: $0 (start | stop)"
        exit 1
esac
exit 0
