This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
until mc alias set local https://minio:9000 "$MINIO_ROOT_USER" "$MINIO_ROOT_PASSWORD" >/dev/null 2>&1; do sleep 2; done
|
||||
mc mb --ignore-existing "local/$S3_BUCKET"
|
||||
mc anonymous set none "local/$S3_BUCKET"
|
||||
|
||||
cat >/tmp/api-policy.json <<EOF
|
||||
{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":["s3:ListBucket"],"Resource":["arn:aws:s3:::$S3_BUCKET"],"Condition":{"StringLike":{"s3:prefix":["original/*","variants/*"]}}},{"Effect":"Allow","Action":["s3:PutObject"],"Resource":["arn:aws:s3:::$S3_BUCKET/staging/*"]},{"Effect":"Allow","Action":["s3:GetObject"],"Resource":["arn:aws:s3:::$S3_BUCKET/original/*","arn:aws:s3:::$S3_BUCKET/variants/*"]}]}
|
||||
EOF
|
||||
cat >/tmp/worker-policy.json <<EOF
|
||||
{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":["s3:ListBucket"],"Resource":["arn:aws:s3:::$S3_BUCKET"],"Condition":{"StringLike":{"s3:prefix":["staging/*","original/*","variants/*"]}}},{"Effect":"Allow","Action":["s3:GetObject"],"Resource":["arn:aws:s3:::$S3_BUCKET/staging/*"]},{"Effect":"Allow","Action":["s3:PutObject","s3:DeleteObject"],"Resource":["arn:aws:s3:::$S3_BUCKET/original/*","arn:aws:s3:::$S3_BUCKET/variants/*","arn:aws:s3:::$S3_BUCKET/staging/*"]}]}
|
||||
EOF
|
||||
for policy in attachments-api attachments-worker; do
|
||||
file=/tmp/api-policy.json; [ "$policy" = attachments-worker ] && file=/tmp/worker-policy.json
|
||||
if ! mc admin policy info local "$policy" >/dev/null 2>&1; then
|
||||
mc admin policy create local "$policy" "$file"
|
||||
fi
|
||||
done
|
||||
for credential in "$S3_ACCESS_KEY:$S3_SECRET_KEY:attachments-api" "$S3_WORKER_ACCESS_KEY:$S3_WORKER_SECRET_KEY:attachments-worker"; do
|
||||
access=${credential%%:*}; rest=${credential#*:}; secret=${rest%%:*}; policy=${rest##*:}
|
||||
if ! mc admin user info local "$access" >/dev/null 2>&1; then mc admin user add local "$access" "$secret" >/dev/null; fi
|
||||
mc admin policy attach local "$policy" --user "$access" >/dev/null
|
||||
done
|
||||
Reference in New Issue
Block a user