#!/bin/ksh93
# IBM_PROLOG_BEGIN_TAG 
# This is an automatically generated prolog. 
#  
# 61haes_r720 src/43haes/usr/sbin/cluster/sa/domino/sbin/cl_dominostop.sh 1.2 
#  
# 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 
# @(#)99	1.2  src/43haes/usr/sbin/cluster/sa/domino/sbin/cl_dominostop.sh, hacmp.assist, 61haes_r720, 1539B_hacmp720 9/11/15 15:11:41
###############################################################################################
#
# NAME:
#       cl_dominostop
#
# PURPOSE:
#       stop script of Smart Assist for Lotus domino server
#
# ARGUMENTS:
#       n/a
#
# RETURNS
#  0 on success
#  1 on Failure
#
#################################################################################################

[[ "VERBOSE_LOGGING" == "high" ]] && set -x
. /usr/es/sbin/cluster/sa/domino/sbin/cl_lotusdominoGlobals
KLIB_HACMPLOG_ENTRY=$KLIB_LOTUS_DOMINO_HACMPLOG_ENTRY

typeset data_dir

while getopts d:p: opt
do
        case $opt in

                d) # Lotus domino server data directory
                        data_dir=$OPTARG
                        ;;
                p) # Lotus domino Program directory
                        DOMINO_PROG_DIR=$OPTARG
                        ;;
        esac
done

USER=$(ls -l $data_dir/notes.ini|awk '{print $3}')
cd $data_dir
ps -fu $USER|grep -w $DOMINO_PROG_DIR/notes/latest/ibmpow/server   > /dev/null 2>&1 
(( $? == 1 )) && exit 0

KLIB_SA_logmsg INFO 2 11 lotusdominosa.cat "stoping the Lotus domino server with data directory %1\$s and user as %2\$s\n" $data_dir $USER
/usr/bin/su $USER  "-c  $DOMINO_PROG_DIR/bin/server -q > /dev/null 2>&1"
if (( $? < 50 ));then
        exit 0
else
        exit 1
fi
