Skeleton contracts / contracts (pull_request) Blocked by required conditions
31 lines
1.2 KiB
Bash
31 lines
1.2 KiB
Bash
#!/bin/sh
|
|
set -eu
|
|
export MC_CONFIG_DIR=/tmp/mc
|
|
mkdir -p "$MC_CONFIG_DIR/certs/CAs"
|
|
cp /run/trust/ca.crt "$MC_CONFIG_DIR/certs/CAs/lab.crt"
|
|
if ! mc alias set local https://s3:9000 labroot "$(cat /run/identity/admin)" >/dev/null 2>&1; then
|
|
echo 'MinIO administrative connection failed' >&2
|
|
exit 1
|
|
fi
|
|
|
|
# New buckets are private by default. Keep the existing bucket policy on replay.
|
|
mc mb --ignore-existing local/messenger-attachments >/dev/null
|
|
users=$(mc --no-color admin user list local)
|
|
policies=$(mc --no-color admin policy list local)
|
|
for role in api worker recovery; do
|
|
name="lab-$role"
|
|
if ! printf '%s\n' "$policies" | grep -Fxq "$name"; then
|
|
mc admin policy create local "$name" "/lab/$role.json" >/dev/null
|
|
fi
|
|
user=$(printf '%s\n' "$users" | awk -v name="$name" '$2 == name')
|
|
if [ -z "$user" ]; then
|
|
if ! mc admin user add local "$name" "$(cat "/run/identity/$role")" >/dev/null 2>&1; then
|
|
printf 'Could not create MinIO user %s\n' "$name" >&2
|
|
exit 1
|
|
fi
|
|
elif [ -n "$(printf '%s\n' "$user" | awk '{print $3}')" ]; then
|
|
continue
|
|
fi
|
|
mc admin policy attach local "$name" --user "$name" >/dev/null
|
|
done
|