#!/bin/sh

# script to determine the deployment (variant) Enterprise GW / HTS
# that means a SG LW running in Enterprise GW mode natively on an Ecoserver to replace a classic NCUI in AP shelf
# return 1 in case of Enterprise GW
# return 0 in case of non Enterprise GW

if [ "$appHome" = "" ]; then
  appHome="/opt/webservice"
fi
if [ "$varPath" = "" ]; then
  varPath="/var/opt/webservice"
fi

. /opt/webservice/install/deployment.properties

deployment=`/opt/webservice/scripts/gethaipsetupentry.sh system.multiNodeSystem`
rc=$?
if [ "$rc" != "0" ]; then
 echo "System is not a valid OpenScape 4000 installation"
 exit -1
fi

# check HW, only EcoServer can host an Enterprise GW
/opt/webservice/scripts/is_ecoserver >/dev/null 2>&1
rc=$?
if [ "$rc" = "0" ]; then
    # Hardware is not an EcoServer
    # deployment can not be a Enterprise GW 
    echo "Hardware is not EcoServer, therefore cannot host Enterprise Gateway"
    exit 0
fi

is_container=0
if [ -f /opt/soco/native/os/linux/is_container.sh ]; then
  /opt/soco/native/os/linux/is_container.sh
  rc=$?
  if [ ${rc} == "0" ]; then
    is_container=0
  else
    is_container=1
  fi
fi
if [ "${is_container}" = "1" ]; then
  # on iSG on EntGW we have to return false
  exit 0
fi

case $deployment in
   $DEP_ECOAP | $DEP_SURVIVABLE_ECOAP)
	  echo "Deployment variant is Enterprise Gateway"
          exit 1
          ;;
   $DEP_LOCAL_SEP_SRV | $DEP_LOCAL_SEP_SRV_SG | $DEP_DSCXLV2_DUPLEX | $DEP_DSCXLV2_DUPLEX_SG | $DEP_DSCXLV2_LOCAL_SEP_DUPLEX | $DEP_DSCXLV2_DUPLEX_REPLACEMENT | $DEP_SINGLE_NODE_SRV | $DEP_SURV_SG | $DEP_STANDALONE_SG | $DEP_REDU_SG | $DEP_APE | $DEP_RG8300 | $DEP_DSCXLV2_SIMPLEX)
	  echo "Deployment variant is not Enterprise Gateway"
          exit 0
          ;;
   $DEP_UNDEFINED)
          echo "Deployment is still undefined"
          exit 0
          ;;
   *)
          echo "Unknown Deployment"
          exit -1
esac
