#!/bin/bash

declare scriptPath="$(realpath "${0}")"
declare scriptDir="$(dirname "${scriptPath}")"
declare radarReplayDirDef="$(dirname "${scriptDir}")"

# You can specify the version of the container image to use via FOCUS_VERSION
declare FOCUS_VERSION="${FOCUS_VERSION:-7.4.0}"
# Allows setting where replay data is located on system (like /srv/radar-replay/site-data)
declare RADAR_REPLAY_DIR="${RADAR_REPLAY_DIR:-${radarReplayDirDef}}"

RAW2PB="/usr/libexec/vaisala/pipes/raw2pb_input_dto"
if ((${FOCUS_VERSION//./} > 0)) && ((${FOCUS_VERSION//./} < 720)); then
  # raw2pb executable was at a different location in older JARS
  RAW2PB="/usr/vaisala/radarsw/data-manager-input-service/bin/raw2pb"
fi

exec docker run --network none --mount type=bind,source=${RADAR_REPLAY_DIR},destination=${RADAR_REPLAY_DIR},readonly --rm \
  com.vaisala.fire/cloud-input-service:${FOCUS_VERSION} \
  ${RAW2PB} "${@}"
