#!/bin/sh
# A build node's jobs, when something happened instead of on timers: once
# when this starts (the node booted, or was set up), and after each task
# the worker finished ("Task: <id> completed" in its log), its updates and
# a new isolation image when Devuan's indices changed
# (dur-worker-update).  Kept running by init (setup-worker.sh).
set -u
log=/var/log/debusine-worker/worker.log
/usr/share/dur/dur-worker-update
tail -n 0 -F "$log" 2> /dev/null | while read -r first second rest; do
    [ "$first" = Task: ] || continue
    case $rest in completed*) /usr/share/dur/dur-worker-update ;; esac
done
