#!/bin/bash

# returns 0 is SBC is not allowed and 1 is SBC is allowed on this deployment + HW Type

# Source : https://confluence.dev.global-intra.net:8443/display/OS4KD/V10R1+Deployment+Matrix

. /etc/profile

[ -e /opt/force-SBC-allowed ] && exit 1

exec 1>/dev/null
exec 2>/dev/null

. /opt/webservice/install/deployment.properties

# SBC is NOT allowed on Duplex
/opt/webservice/scripts/is_duplex
[ $? -eq 1 ] && exit 0

# SBC is NOT allowed on StdSG
/opt/webservice/scripts/is_sg_standalone
[ $? -eq 1 ] && exit 0

# SBC is NOT allowed on non-Eco or non-Branch HW Types
( system-is-ecoserver || system-is-branch ) || exit 0

# SBC is NOT allowed on Branch if SG is disabled
has_sg=`/opt/webservice/scripts/gethaipsetupentry.sh system-hidden.softGate`
( system-is-branch && [ "$has_sg" = "0" ] ) && exit 0

# SBC is NOT allowed on Manager as Appliance
[ -x /opt/webservice/scripts/is_manager ] && {
    /opt/webservice/scripts/is_manager
    [ $? -eq 1 ] && exit 0
}

# in all other cases SBC is allowed
exit 1
