31 lines
1.1 KiB
Bash
31 lines
1.1 KiB
Bash
#!/usr/bin/env sh
|
|||
|
|
set -eu
|
||
|
|
|
||
|
|
: "${MINIO_ROOT_USER:?MINIO_ROOT_USER is required}"
|
||
|
|
: "${MINIO_ROOT_PASSWORD:?MINIO_ROOT_PASSWORD is required}"
|
||
|
|
: "${OBJECT_STORAGE_BUCKET:?OBJECT_STORAGE_BUCKET is required}"
|
||
|
|
: "${ADMIN_WEB_ORIGIN:?ADMIN_WEB_ORIGIN is required}"
|
||
|
|
|
||
|
|
mc alias set lehuo http://minio:9000 "$MINIO_ROOT_USER" "$MINIO_ROOT_PASSWORD" --api S3v4 >/dev/null
|
||
|
|
mc mb --ignore-existing "lehuo/$OBJECT_STORAGE_BUCKET" >/dev/null
|
||
|
|
mc anonymous set none "lehuo/$OBJECT_STORAGE_BUCKET" >/dev/null
|
||
|
|
mc version enable "lehuo/$OBJECT_STORAGE_BUCKET" >/dev/null
|
||
|
|
|
||
|
|
cat > /tmp/cors.xml <<EOF
|
||
|
|
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
|
||
|
|
<CORSRule>
|
||
|
|
<AllowedOrigin>${ADMIN_WEB_ORIGIN}</AllowedOrigin>
|
||
|
|
<AllowedMethod>GET</AllowedMethod>
|
||
|
|
<AllowedMethod>PUT</AllowedMethod>
|
||
|
|
<AllowedMethod>HEAD</AllowedMethod>
|
||
|
|
<AllowedHeader>*</AllowedHeader>
|
||
|
|
<ExposeHeader>ETag</ExposeHeader>
|
||
|
|
<MaxAgeSeconds>3600</MaxAgeSeconds>
|
||
|
|
</CORSRule>
|
||
|
|
</CORSConfiguration>
|
||
|
|
EOF
|
||
|
|
mc cors set "lehuo/$OBJECT_STORAGE_BUCKET" /tmp/cors.xml >/dev/null
|
||
|
|
rm -f /tmp/cors.xml
|
||
|
|
|
||
|
|
echo "MinIO private bucket initialized."
|