lab4 - оценка 4

This commit is contained in:
Rakshasa2
2026-10-26 18:16:58 +03:00
parent ec540a1a72
commit aea79e8ed7
19 changed files with 2833 additions and 20 deletions
+30
View File
@@ -0,0 +1,30 @@
global
log stdout format raw local0 info
maxconn 4096
defaults
mode http
timeout connect 5s
timeout client 30s
timeout server 30s
timeout check 5s
option httplog
option dontlognull
resolvers docker
nameserver dns1 127.0.0.11:53
hold valid 5s
hold nx 5s
hold refused 5s
hold timeout 5s
frontend fe_main
bind *:8080
default_backend be_api
backend be_api
balance roundrobin
option httpchk GET /health/ready
http-check expect status 200
default-server inter 2s fall 3 rise 2 init-addr libc,none resolvers docker
server-template api 2 api:8080 check
+74
View File
@@ -0,0 +1,74 @@
#!/bin/sh
set -eu
export AWS_EC2_METADATA_DISABLED=true
: "${S3_ENDPOINT:?S3_ENDPOINT is required}"
: "${S3_BUCKET:?S3_BUCKET is required}"
: "${AWS_DEFAULT_REGION:?AWS_DEFAULT_REGION is required}"
echo "Waiting for RustFS S3 API at ${S3_ENDPOINT} ..."
i=0
while true; do
i=$((i + 1))
if aws --endpoint-url "${S3_ENDPOINT}" s3api list-buckets --region "${AWS_DEFAULT_REGION}" >/dev/null 2>&1; then
echo "RustFS is reachable."
break
fi
if [ "$i" -ge 60 ]; then
echo "RustFS did not become reachable in time" >&2
exit 1
fi
sleep 2
done
echo "Ensuring bucket ${S3_BUCKET} ..."
out=$(aws \
--endpoint-url "${S3_ENDPOINT}" \
s3api create-bucket \
--bucket "${S3_BUCKET}" \
--region "${AWS_DEFAULT_REGION}" 2>&1) || true
case "${out}" in
*BucketAlreadyOwnedByYou*|*BucketAlreadyExists*|*already exists*)
echo "Bucket already exists."
;;
*AccessDenied*)
echo "Cannot create bucket: access denied." >&2
echo "${out}" >&2
exit 1
;;
*error*|*Error*)
echo "Unexpected create-bucket output:" >&2
echo "${out}" >&2
exit 1
;;
*)
echo "Bucket created or already present."
;;
esac
echo "Verifying bucket ..."
aws --endpoint-url "${S3_ENDPOINT}" s3api head-bucket --bucket "${S3_BUCKET}" --region "${AWS_DEFAULT_REGION}" >/dev/null
echo "Making bucket private (best effort) ..."
aws --endpoint-url "${S3_ENDPOINT}" \
s3api put-bucket-acl \
--bucket "${S3_BUCKET}" \
--acl private \
--region "${AWS_DEFAULT_REGION}" >/dev/null 2>&1 || true
aws --endpoint-url "${S3_ENDPOINT}" \
s3api put-public-access-block \
--bucket "${S3_BUCKET}" \
--public-access-block-configuration \
BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true \
--region "${AWS_DEFAULT_REGION}" >/dev/null 2>&1 || true
echo "RustFS bootstrap completed"