forked from mtusi2026/mtusi2026lab5
ЛР 5 — БПИ2302 — Щербацевич — на 4
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
ROOT=$(CDPATH= cd -- "$(dirname "$0")/.." && pwd)
|
||||
SECRETS="$ROOT/secrets"
|
||||
mkdir -p "$SECRETS"
|
||||
umask 077
|
||||
|
||||
write_secret() {
|
||||
name=$1
|
||||
value=$2
|
||||
if [ ! -f "$SECRETS/$name" ]; then
|
||||
printf '%s' "$value" > "$SECRETS/$name"
|
||||
fi
|
||||
}
|
||||
|
||||
read_secret() {
|
||||
tr -d '\r\n' < "$SECRETS/$1"
|
||||
}
|
||||
|
||||
hex_bytes() {
|
||||
od -An -N "$1" -tx1 /dev/urandom | tr -d ' \n'
|
||||
}
|
||||
|
||||
write_secret postgres_password "$(hex_bytes 18)"
|
||||
write_secret minio_root_user "lab$(hex_bytes 4)"
|
||||
write_secret minio_root_password "$(hex_bytes 18)"
|
||||
write_secret s3_access_key_id "s3$(hex_bytes 6)"
|
||||
write_secret s3_secret_access_key "$(hex_bytes 24)"
|
||||
write_secret rabbitmq_user messenger
|
||||
write_secret rabbitmq_password "$(hex_bytes 18)"
|
||||
|
||||
pg=$(read_secret postgres_password)
|
||||
rabbit_user=$(read_secret rabbitmq_user)
|
||||
rabbit_password=$(read_secret rabbitmq_password)
|
||||
write_secret database_url "postgresql+asyncpg://messenger:${pg}@postgres:5432/messenger"
|
||||
write_secret host_database_url "postgresql+asyncpg://messenger:${pg}@127.0.0.1:5433/messenger"
|
||||
write_secret cache_url "redis://redis:6379/0"
|
||||
write_secret host_cache_url "redis://127.0.0.1:6379/0"
|
||||
write_secret host_s3_endpoint "http://127.0.0.1:9000"
|
||||
write_secret broker_url "amqp://${rabbit_user}:${rabbit_password}@rabbitmq:5672/"
|
||||
|
||||
if [ ! -f "$ROOT/.env" ]; then
|
||||
cp "$ROOT/.env.example" "$ROOT/.env"
|
||||
fi
|
||||
echo "local secrets are ready"
|
||||
Reference in New Issue
Block a user