порт лабы 4
This commit is contained in:
Executable
+40
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
mkdir -p secrets
|
||||
chmod 700 secrets
|
||||
umask 077
|
||||
|
||||
create_random_secret() {
|
||||
local name="$1"
|
||||
local value="$2"
|
||||
|
||||
if [[ ! -s "secrets/$name" ]]; then
|
||||
printf '%s\n' "$value" > "secrets/$name"
|
||||
fi
|
||||
|
||||
chmod 644 "secrets/$name"
|
||||
}
|
||||
|
||||
create_random_secret postgres_password "$(python3 -c 'import secrets; print(secrets.token_hex(24))')"
|
||||
|
||||
if [[ ! -s secrets/database_url ]]; then
|
||||
PASSWORD="$(cat secrets/postgres_password)"
|
||||
printf 'postgresql+asyncpg://lab2:%s@postgres:5432/messenger\n' "$PASSWORD" > secrets/database_url
|
||||
fi
|
||||
|
||||
create_random_secret cache_url 'redis://redis:6379/0'
|
||||
create_random_secret minio_root_user "minio-$(python3 -c 'import secrets; print(secrets.token_hex(12))')"
|
||||
create_random_secret minio_root_password "$(python3 -c 'import secrets; print(secrets.token_hex(32))')"
|
||||
create_random_secret s3_access_key_id "$(python3 -c 'import secrets; print(secrets.token_hex(20))')"
|
||||
create_random_secret s3_secret_access_key "$(python3 -c 'import secrets; print(secrets.token_hex(32))')"
|
||||
|
||||
chmod 644 secrets/*
|
||||
|
||||
if [[ ! -f .env ]]; then
|
||||
cp .env.example .env
|
||||
fi
|
||||
|
||||
docker compose config --quiet
|
||||
Reference in New Issue
Block a user