#!/bin/bash
set -euo pipefail

. "{{ deepflow_agent_env_file }}"

args=("${DEEPFLOW_AGENT_ENDPOINT_ARG}" "${DEEPFLOW_GRPC_ENDPOINT}")

if [[ "${DEEPFLOW_AGENT_DISABLE_PCAP}" == "true" ]]; then
  args+=("--disable-pcap")
fi
if [[ "${DEEPFLOW_AGENT_DISABLE_VECTOR}" == "true" ]]; then
  args+=("--disable-vector")
fi
if [[ "${DEEPFLOW_AGENT_DISABLE_PLUGINS}" == "true" ]]; then
  args+=("--disable-plugins")
fi
if [[ -n "${DEEPFLOW_AGENT_ARGS}" ]]; then
  # shellcheck disable=SC2206
  extra_args=(${DEEPFLOW_AGENT_ARGS})
  args+=("${extra_args[@]}")
fi

exec "{{ deepflow_agent_binary_path }}" "${args[@]}"
