#!/bin/bash

set -eu

if [[ -z "${Environment}" ]]; then
  echo 'Environment var not set.'
  exit 1
fi

if [[ -z "${CONFIG_FILE:-}" ]]; then
  echo 'CONFIG_FILE var not set.'
  exit 1
fi

if [[ ! -f "/var/app/${CONFIG_FILE}" ]]; then
  echo "config file /var/app/${CONFIG_FILE} not found"
  exit 1
fi

echo "using /var/app/${CONFIG_FILE}"
/var/app/router -c "/var/app/${CONFIG_FILE}" --log "${ROUTER_LOG_LEVEL:-info}"
