#!/bin/sh
set -e

# Wait for MinIO to be ready
until (mc alias set local http://minio:9000 admin 0153093693-0009) do
  echo 'Waiting for MinIO...'
  sleep 1
done

# Create bucket if it doesn't exist
if ! mc ls local/airflow-logs >/dev/null 2>&1; then
  mc mb local/airflow-logs
  mc anonymous set download local/airflow-logs
  echo 'MinIO bucket initialized'
else
  echo 'MinIO bucket already exists'
fi
