35 lines
No EOL
1.2 KiB
Bash
35 lines
No EOL
1.2 KiB
Bash
#!/bin/bash
|
|
|
|
# 1. Setup variables from your environment
|
|
CONTAINER_NAME="minio-node${MINIO_NODE_NUMBER}"
|
|
DATA_PATH="/docker/minio/data"
|
|
# Example: MINIO_BUCKET_REGISTRY="forgejo prometheus backups"
|
|
|
|
echo "Checking S3 Bucket Registry..."
|
|
|
|
# 2. Stop the clustered container to prevent file locks/sync conflicts
|
|
docker stop $CONTAINER_NAME 2>/dev/null || true
|
|
|
|
# 3. Loop through the registry
|
|
for BUCKET in ${MINIO_BUCKET_REGISTRY}; do
|
|
TARGET_DIR="$DATA_PATH/$BUCKET"
|
|
|
|
if [ -d "$TARGET_DIR" ]; then
|
|
echo "Bucket '$BUCKET' already exists on host. Skipping."
|
|
else
|
|
echo "Bucket '$BUCKET' missing. Creating directory..."
|
|
# We create it with the correct permissions (MinIO usually runs as 1000)
|
|
mkdir -p "$TARGET_DIR"
|
|
chown -R 1000:1000 "$TARGET_DIR"
|
|
|
|
# Optional: Use a standalone container to 'formalize' the bucket
|
|
# if you want MinIO metadata generated immediately
|
|
docker run --rm \
|
|
-v "$DATA_PATH":/data \
|
|
alpine:latest sh -c "mkdir -p /data/$BUCKET && chown -R 1000:1000 /data/$BUCKET"
|
|
fi
|
|
done
|
|
|
|
# 4. Restart the real clustered container
|
|
echo "Restarting $CONTAINER_NAME..."
|
|
docker start $CONTAINER_NAME |