Files
mtusi2026lab2/scripts/init-secrets.sh
T
celis cac37bddec ЛР 2 — БПИ2303 — Морару — на 5 (трек 2)
TypeScript/Node API на PostgreSQL с сессиями в Valkey (AOF), миграции,
compose-стенд, restart hook, тесты уровня 4 и эксперимент трека 2
(планы запроса на 240k сообщений, стоимость записи, backup/restore).
2026-10-29 20:58:56 +03:00

21 lines
780 B
Bash
Executable File

#!/bin/sh
# Generates local synthetic credentials in ./secrets (git-ignored). Safe to re-run: keeps existing files.
set -eu
cd "$(dirname "$0")/.."
mkdir -p secrets
umask 077
rand() { python3 -c 'import secrets; print(secrets.token_urlsafe(24))'; }
if [ ! -f secrets/postgres_password ]; then
pg=$(rand)
printf '%s' "$pg" > secrets/postgres_password
printf 'postgresql://messenger:%s@postgres:5432/messenger' "$pg" > secrets/database_url
fi
if [ ! -f secrets/valkey_auth.conf ]; then
vk=$(rand)
printf 'requirepass %s\n' "$vk" > secrets/valkey_auth.conf
printf 'redis://:%s@valkey:6379/0' "$vk" > secrets/cache_url
fi
# containers run as non-root users and read these via bind-mounted secrets
chmod 644 secrets/*
echo "secrets ready in ./secrets (values not printed)"