#!/bin/bash
#
# This can be used to restart the simulated radar data to synchronize it with lightning
# feeds that are also restarted at certain points in time.
#
# CRON_TZ=UTC
# 0 1,5,9,13,17,21 * * * cd /srv/radar-replay && ./restart-replay.sh nz-full >| /srv/radar-replay/restart-replay.log 2>&1

dataSet="${1:-nz}"
scriptPath="$(realpath "${0}")"
scriptDir="$(dirname "${scriptPath}")"
replayPath="${scriptDir}/${dataSet}-replay.sh"

if [ ! -x "${replayPath}" ]; then
    echo -e "
Usage:   ${scriptPath} DATASET

Where:   DATASET-replay.sh exists under ${scriptDir}

Example: ${scriptPath} nz
"
    exit 1
fi

kill $(pgrep --full java.*/srv/radar-replay) &> /dev/null
sleep 10
eval "daysBack=0 ${replayPath}"
