#!/bin/sh
# server type check (AUTH, GSB, ISB)
# ---------------------------------------------- #


##### Main routine ###############################

# Function read
. ${INST_HOME}/function.sh

##### GrobalParameter ############################
# get param
EXPECT_SVR=${1} # (AUTH or GSB or ISB)

##### TRAP #######################################
# Deny Ctrl+C
trap 'echo "Deny Ctrl+C"' 1 2 3 15

# init
initialize

# result init
FLAG=0
PRO_FILE=""

#----- server type check -------------------------#
if [ "${EXPECT_SVR}" = "AUTH" ] ; then
  if [ ! -e ${ADMIN_PROPERTIES_FILE} ] ; then
    FLAG=1
    PRO_FILE=${ADMIN_PROPERTIES_FILE}
  fi
elif [ "${EXPECT_SVR}" = "GSB" ] ; then
  if [ ! -e ${GSB_PROPERTIES_FILE} ] ; then
    FLAG=1
    PRO_FILE=${GSB_PROPERTIES_FILE}
  fi
elif [ "${EXPECT_SVR}" = "ISB" ] ; then
  if [ ! -e ${ISB_PROPERTIES_FILE} ] ; then
    FLAG=1
    PRO_FILE=${ISB_PROPERTIES_FILE}
  fi
else
  FLAG=2
fi

# UnExpect server type
if [ $FLAG -eq 1 ] ; then
  $echo "${OCCURED_ERROR}"
  $echo ""
  msg_err "ERR: ${SERVERTYPE_MISS}" \
          "" \
          "<!> ${EXIST_FILE}" \
          "    [ ${PRO_FILE} ]" \
          ""
elif [ $FLAG -eq 2 ] ; then
  $echo "${OCCURED_ERROR}"
  $echo ""
  msg_err "ERR: ${SERVERTYPE_MISS}"
fi

exit $FLAG