#!/usr/bin/env bash # Builds and starts the demo, streams the logs live until both boards finish, then shows the # result of each board and tears everything down. set -uo pipefail cd "$(dirname "$0")" EXITDIR=$(mktemp -d) # compose.restart.yaml enables the "Run again" button (mounts the Docker socket; local use only). export COMPOSE_FILE=compose.yaml:compose.restart.yaml docker compose up --build -d || exit 1 echo echo ">>> Live web view: http://localhost:8099 (open it now; the programs start after their countdown)" echo docker compose logs -f & LOGS_PID=$! # Wait for both boards to exit (they run: start delay, steps, then exit with 0 = all checks passed). for svc in board-c board-cpp; do docker wait "$(docker compose ps -aq "$svc")" > "$EXITDIR/$svc.exit" done sleep 1 kill "$LOGS_PID" 2>/dev/null echo echo "================ RESULT ================" status=0 for svc in board-c board-cpp; do code=$(cat "$EXITDIR/$svc.exit") echo "$svc exit code: $code" [ "$code" = "0" ] || status=1 done [ $status = 0 ] && echo "ALL CHECKS PASSED" || echo "FAILURES (see logs above)" echo echo "Containers are still up for inspection. Stop with: docker compose -f $(pwd)/compose.yaml down" exit $status