#!/usr/bin/env /lib/runit/invoke-run

set -e

. /etc/ark/monitor-config

# logging only captures stdout, so merge stderr in with it
exec 2>&1

# make sure there is at least a minimum configuration file
mkdir -p /etc/ark/activity-team-probing/
if [ ! -s /etc/ark/activity-team-probing/scamper-config ]; then
    echo "PPS=${SCAMPER_PPS:-100}" > /etc/ark/activity-team-probing/scamper-config
fi

# fetch the team-probing-specific scamper configuration for this node (a cron
# job will keep it up to date if it changes later)
if [ -x /usr/bin/ark-activity-config ]; then
    /usr/bin/ark-activity-config team-probing || true
fi

echo "Starting ark-activity-team-probing..."
exec chpst -u ark /usr/bin/ark-team-prober -m "${ARK_MONITOR}"
