#!/bin/bash

COLLECTOR_FLAGS=()
COLLECTOR_CONFIG="${COLLECTOR_CONFIG:-/app/config/collector.yaml}"

[ -n "${COLLECTOR_DEBUG}" ] && COLLECTOR_FLAGS=("${COLLECTOR_FLAGS[@]}" "--debug")
[ -n "${COLLECTOR_TRACE}" ] && COLLECTOR_FLAGS=("${COLLECTOR_FLAGS[@]}" "--trace")

run() {
    exec "/app/hamview-collector" \
        "${COLLECTOR_FLAGS[@]}" \
        --config "${COLLECTOR_CONFIG}"
}

case "$@" in
    "")
        run
        ;;
    *)
        exec "/bin/sh" -c "$@"
        ;;
esac
