#! /bin/sh
set -e

sleep 10
ALL_TASKS=$(ls /Berkanavt/cm_workdir/worker/var/state)
AUTOSTART=$(cat /Berkanavt/cm_workdir/autostart)

for TASK in $ALL_TASKS; do
    echo "Mark $TASK as success"
    curl --silent "http://localhost:3130/command/mark-success?target=$TASK"
done

for TASK in $AUTOSTART; do
    echo "Start $TASK"
    curl --silent "http://locahost:3130/command/forced-run?target=$TASK"
done
