#!/bin/bash

################################################################################
# Copyright 2023-2025 by NI SP Software GmbH, All rights reserved.
# Copyright 1999-2023 by Nice, srl., All rights reserved.
#
# This software includes confidential and proprietary information
# of NI SP Software GmbH ("Confidential Information").
# You shall not disclose such Confidential Information
# and shall use it only in accordance with the terms of
# the license agreement you entered into with NI SP Software.
################################################################################
################################################################################


# Avoid recursive loops

[ -n "${EF_AWSBATCH_DO_NOT_RECURSE}" ] && exit 0
EF_AWSBATCH_DO_NOT_RECURSE=true
export EF_AWSBATCH_DO_NOT_RECURSE

EF_PLUGIN_NAME="EnginFrame AWS Batch Plug-in"
export EF_PLUGIN_NAME

EF_PLUGIN_ROOT="${EF_ROOT}/plugins/awsbatch"
export EF_PLUGIN_ROOT


# Load common EnginFrame functions and environment

. "${EF_ROOT}/plugins/ef/lib/functions"

ef_init_environment


# Load AWS Batch Plug-in configuration

ef_source_conf awsbatch "ef.awsbatch.conf"

if [ -z "${AWSBATCH_CLUSTER_ID}" ] ; then
  ef_error "AWSBATCH_CLUSTER_ID is not correctly defined inside ef.awsbatch.conf" \
    "EnginFrame AWS Batch Plugin Error" \
    "\${EF_ROOT}/plugins/awsbatch/bin/common"
  exit 1
fi

if [ -z "${cluster}" ]; then
    cluster="${AWSBATCH_CLUSTER_ID}"
    export cluster
fi
if [ "${cluster}" != "${AWSBATCH_CLUSTER_ID}" ]; then
    ef_error "Unknown cluster \"${cluster}\"" "EnginFrame AWS Batch Plugin Error" "$0"
    exit 1
fi

if [ -z "${AWSBATCH_CLUSTER_REGION}" ] ; then
  ef_error "AWS_CLUSTER_REGION is not correctly defined inside ef.awsbatch.conf" \
    "EnginFrame AWS Batch Plugin Error" \
    "\${EF_ROOT}/plugins/awsbatch/bin/common"
  exit 1
fi

AWS_DEFAULT_REGION="${AWSBATCH_CLUSTER_REGION}"
export AWS_DEFAULT_REGION


## Load common awsbatch Plugin functions

. "${EF_ROOT}/plugins/awsbatch/bin/functions.lib.sh"

# vi: ts=4 sw=4 et syntax=sh :
