#!/usr/bin/env bash # Run one simulated day inside the running container. # # scripts/daily.sh [daily flags...] # # Schedule it once a day, e.g. in crontab: # 0 6 * * * /path/to/scripts/daily.sh >> /var/log/halcyon-daily.log 2>&1 # # Environment: # HALCYON_CONTAINER container name (default: halcyon, as in docker-compose.yml) # # The world settings (WH_SEED, WH_ASTEROIDS, ...) come from the container's # environment, so the daily run always matches the server. set -euo pipefail container="${HALCYON_CONTAINER:-halcyon}" if ! docker inspect -f '{{.State.Running}}' "$container" 2>/dev/null | grep -qx true; then echo "error: container '$container' is not running (try: docker compose up -d)" >&2 exit 1 fi echo "$(date -u +%Y-%m-%dT%H:%M:%SZ) running daily job in $container" # No -t: this must work from cron, where there is no terminal. exec docker exec "$container" daily "$@"