forked from mtusi2026/mtusi2026lab5
18 lines
727 B
Bash
18 lines
727 B
Bash
#!/bin/sh
|
|
set -eu
|
|
root_user=$(cat /run/secrets/rustfs_root_user)
|
|
root_password=$(cat /run/secrets/rustfs_root_password)
|
|
app_key=$(cat /run/secrets/s3_access_key_id)
|
|
app_secret=$(cat /run/secrets/s3_secret_access_key)
|
|
rc alias set local http://rustfs:9000 "$root_user" "$root_password"
|
|
if ! rc bucket list local/ | grep -q 'messenger-attachments'; then
|
|
rc bucket create local/messenger-attachments
|
|
fi
|
|
if ! rc admin policy info local messenger-objects >/dev/null 2>&1; then
|
|
rc admin policy create local messenger-objects /policy.json
|
|
fi
|
|
if ! rc admin user info local "$app_key" >/dev/null 2>&1; then
|
|
rc admin user add local "$app_key" "$app_secret"
|
|
fi
|
|
rc admin policy attach local messenger-objects --user "$app_key"
|