-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit-minio.sh
More file actions
46 lines (38 loc) · 1.1 KB
/
init-minio.sh
File metadata and controls
46 lines (38 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/sh
# Wait for MinIO to be ready
echo "Waiting for MinIO to start..."
until curl -f http://localhost:9000/minio/health/live; do
echo "MinIO is not ready yet..."
sleep 2
done
echo "MinIO is ready. Setting up bucket..."
# Configure mc (MinIO Client)
mc alias set myminio http://localhost:9000 ${MINIO_ROOT_USER} ${MINIO_ROOT_PASSWORD}
# Create the bucket
mc mb myminio/template-bucket --ignore-existing
# Create bucket policy for public access
cat > /tmp/bucket-policy.json <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": "*",
"Action": [
"s3:GetObject",
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::template-bucket",
"arn:aws:s3:::template-bucket/*"
]
}
]
}
EOF
# Apply the public policy
mc anonymous set-json /tmp/bucket-policy.json myminio/template-bucket
# Clean up
rm -f /tmp/bucket-policy.json
echo "Bucket 'template-bucket' is now public!"
echo "Access files at: http://localhost:9000/template-bucket/"