#!/bin/ksh93
# IBM_PROLOG_BEGIN_TAG 
# This is an automatically generated prolog. 
#  
# 61haes_r714 src/43haes/usr/sbin/cluster/sa/domino/sbin/cl_domino_manual.sh 1.1 
#  
# Licensed Materials - Property of IBM 
#  
# COPYRIGHT International Business Machines Corp. 2010 
# 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 
# @(#)43	1.1  src/43haes/usr/sbin/cluster/sa/domino/sbin/cl_domino_manual.sh, hacmp.assist, 61haes_r714 11/28/11 15:02:27
#################################################################################
# Name: cl_domino_manual
#
# Purpose: To create PowerHA SystemMirror resources and Resource group for Managing
#          Lotus domino server using manual configuration.
#
# Arguments:
#       n/a
#
# Returns: 0 for Sucess
#          1 for Failure
################################################################################

. /usr/es/sbin/cluster/sa/domino/sbin/cl_lotusdominoGlobals
. /usr/es/sbin/cluster/sa/domino/sbin/cl_lotusdominoUtilities
KLIB_HACMPLOG_ENTRY=$KLIB_LOTUS_DOMINO_HACMPLOG_ENTRY

dspmsg -s 1 lotusdominosa.cat 55 "configuring Lotus domino server using manual configuration\n"
KLIB_SA_logmsg INFO 1 55 lotusdominosa.cat "configuring Lotus domino server using manual configuration\n"

typeset APPLICATION_ID       # Smart Assist Application Name of the domino server.
typeset NODES                # Participating nodes in the cluster.
typeset DATA_DIR             # Domino server node and data directory
typeset DOMINO_CLSTR         # Domino cluster between the domino servers

while getopts f: opt
do
        case $opt in

                f) # xml file path
                        XML_PATH=$OPTARG
                        ;;
        esac
done

APPLICATION_ID=$($LOTUS_DOMINO_HA_SBIN/cl_lotus_domino_query -n|grep -v application_name)
validateAppName "$APPLICATION_ID"
[[ "$?" == "1" ]] && {
        KLIB_SA_logmsg ERROR 1 11 lotusdominosa.cat "smart assist for Lotus domino Application id=%1\$s is not in the rage [a-z][A-z][0-9]_.\n" "$APPLICATION_ID"
        exit 1
        }

NODES=$($SA_SBIN/clsaxmlutil -s -x $XML_PATH -m $LOTUS_DOMINO_HA_CONFIG/cl_dominoserver_config.xsd -t Nodes|awk -F= '{ print $2 }')
if [[ $? != 0 || -z $NODES ]];then
        KLIB_SA_logmsg ERROR 1 56 lotusdominosa.cat "No value is specified for Nodes property in Lotus domino xml file\n"
        exit 1
else
	NODES=$(echo $NODES|tr "," " ")
fi

DATA_DIR=$($SA_SBIN/clsaxmlutil -s -x $XML_PATH -m $LOTUS_DOMINO_HA_CONFIG/cl_dominoserver_config.xsd -t DataDirectory|awk -F= '{ print $2 }')
[[ $? != 0 || -z $DATA_DIR ]] && {
        KLIB_SA_logmsg ERROR 1 57 lotusdominosa.cat "No value is specified for DataDirectory property in Lotus domino xml file\n"
        exit 1
        }
DOMINO_CLSTR=$($SA_SBIN/clsaxmlutil -s -x $XML_PATH -m $LOTUS_DOMINO_HA_CONFIG/cl_dominoserver_config.xsd -t DominoCluster|awk -F= '{ print $2 }')
[[ $? != 0 || -z $DOMINO_CLSTR ]] && {
        KLIB_SA_logmsg ERROR 1 58 lotusdominosa.cat "No value is specified for DominoCluster property in Lotus domino xml file\n"
        exit 1
        }

$LOTUS_DOMINO_HA_SBIN/cl_lotus_domino_config -a "$APPLICATION_ID" -n "$NODES" -p "$DATA_DIR" -d "$DOMINO_CLSTR"
exit $?
