#!/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 

isSBCImported=false
for alxcconffile in /var/lib/lxc/SBC/config /var/lib/lxc/OSB/config; do
  [ -e $alxcconffile ] || continue
  grep rootfs $alxcconffile | grep -q /opt/SBC/share || continue
  sizeOfSBCImage=$(2>/dev/null stat -c %s `readlink -f /opt/SBC/share/SBC.img`)
  #check if empty
  [ "x$sizeOfSBCImage" = "x" ] && continue
  #check if NaN
  [ $sizeOfSBCImage -eq $sizeOfSBCImage ] || continue
  #assume SBC Image is imported if image is bigger than 1GB
  [ $sizeOfSBCImage -gt 999999999 ] || continue
  isSBCImported=true
  break
done

if $isSBCImported; then
  . /opt/SBC/etc/common.conf
  echo "$OSB_PRODUCT_TYPE is imported"
  exit 1
else
  echo "No SBC/OSB imported image found"
  exit 0
fi
