forked from mtusi2026/mtusi2026lab4
ЛР 4 — вложения S3 и reconciler
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
rc alias set local http://rustfs:9000 "$RUSTFS_ROOT_ACCESS_KEY" "$RUSTFS_ROOT_SECRET_KEY" >/dev/null
|
||||
attempt=0
|
||||
until rc ls local/ >/dev/null 2>&1; do
|
||||
attempt=$((attempt + 1))
|
||||
if [ "$attempt" -ge 60 ]; then echo 'RustFS did not become ready' >&2; exit 1; fi
|
||||
sleep 2
|
||||
done
|
||||
rc bucket create --ignore-existing "local/$S3_BUCKET" >/dev/null
|
||||
if ! rc admin user list local/ 2>/dev/null | grep -Fq "$S3_API_ACCESS_KEY"; then
|
||||
rc admin user add local/ "$S3_API_ACCESS_KEY" "$S3_API_SECRET_KEY" >/dev/null
|
||||
fi
|
||||
sed "s/messenger-attachments/$S3_BUCKET/g" /bootstrap/policy.json > /tmp/messenger-api-policy.json
|
||||
rc admin policy create local/ messenger-api /tmp/messenger-api-policy.json >/dev/null 2>&1 || true
|
||||
rc admin policy attach local/ messenger-api --user "$S3_API_ACCESS_KEY" >/dev/null
|
||||
printf '%s\n' 'Private bucket and restricted API user are ready.'
|
||||
Reference in New Issue
Block a user