#!/usr/bin/env bash
set -euo pipefail

mkdir -p /data/out /data/guidance /data/autopilot

if [[ -n "${FPV_OUT_VIDEO_PATH:-}" ]]; then
    mkdir -p "$(dirname "${FPV_OUT_VIDEO_PATH}")"
fi

if [[ -n "${FPV_GUIDANCE_EXPORT_PATH:-}" ]]; then
    mkdir -p "$(dirname "${FPV_GUIDANCE_EXPORT_PATH}")"
fi

if [[ -n "${FPV_AUTOPILOT_JSON_PATH:-}" ]]; then
    mkdir -p "$(dirname "${FPV_AUTOPILOT_JSON_PATH}")"
fi

echo "[entrypoint] source=${FPV_SOURCE:-<config default>} backend=${FPV_AUTOPILOT_BACKEND:-json} proto_udp=${FPV_PROTO_UDP_ENABLE:-0}"

exec "$@"
