Files
lasuite-drive/minio-initialize.sh
T
2026-09-28 17:26:36 +02:00

35 lines
1.0 KiB
Bash

#!/bin/sh
set -e
# Use an isolated mc config dir: the bundled Bitnami image runs its own
# internal mc client (as the "minio" user) against the default /.mc path,
# which collides with this script running as root against the same path.
export MC_CONFIG_DIR=/tmp/mc-drive-init
# Wait for minio to be ready (up to 60 seconds)
i=0
while ! mc ready local 2>/dev/null; do
i=$((i+1))
if [ "$i" -ge 60 ]; then
echo "minio-initialize: timed out waiting for minio to be ready" >&2
exit 1
fi
sleep 1
done
MINIO_ROOT_USER="$(cat /run/secrets/minio_ru)"
MINIO_ROOT_PASSWORD="$(cat /run/secrets/minio_rp)"
mc alias set drive http://localhost:9000 "${MINIO_ROOT_USER}" "${MINIO_ROOT_PASSWORD}"
# Idempotent: skip if bucket already exists
if mc ls drive/drive-media-storage > /dev/null 2>&1; then
echo "minio-initialize: bucket 'drive-media-storage' already exists, skipping"
exit 0
fi
echo "minio-initialize: creating bucket 'drive-media-storage'..."
mc mb drive/drive-media-storage
mc version enable drive/drive-media-storage
echo "minio-initialize: done"