#!/bin/sh

. /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 

case $deployment in
   $DEP_ECOAP | $DEP_SURVIVABLE_ECOAP )
          #deployment is an EntGW
          true
          ;;
   $DEP_DSCXLV2_DUPLEX | $DEP_DSCXLV2_LOCAL_SEP_DUPLEX | $DEP_LOCAL_SEP_SRV )
          #deployment is Duplex => continue after this block as there is more code
          true
          ;;
   *)     
          echo "Deployment is not an EntGW or Duplex - returning not enabled."
          exit 0
esac

#on Quorum this also does not make sense
2>/dev/null 1>/dev/null /opt/webservice/scripts/is_quorum
[ $? -eq 1 ] && {
    echo "Node is a quorum - returning not enabled."
    exit 0
}

#determine node
mynode=2
grep ">$(hostname)<" /var/opt/ha/conf/haipsetup.xml | grep -q system.name-node1 && mynode=1

if [ "x1" = "x`/opt/webservice/scripts/gethaipsetupentry.sh system.iSG.node${mynode}`" ] ; then
  echo "iSoftGate is enabled"
  exit 1
else
  echo "iSoftGate is disabled"
  exit 0
fi
