ЛР 2: PostgreSQL и сессии, оценка 3

This commit is contained in:
2026-11-03 17:30:05 +03:00
parent 65003b6119
commit 0cf56ee2b5
21 changed files with 668 additions and 24 deletions
+21
View File
@@ -0,0 +1,21 @@
#!/bin/sh
set -eu
cd "$(dirname "$0")/.."
mkdir -p secrets
chmod 700 secrets
if [ ! -f secrets/db_password ]; then
python3 -c 'import secrets; print(secrets.token_urlsafe(32))' > secrets/db_password
fi
chmod 600 secrets/db_password
if [ ! -f secrets/database_url ]; then
python3 - <<'PY2' > secrets/database_url
from pathlib import Path
from urllib.parse import quote
p=Path('secrets/db_password').read_text().strip()
print('postgresql://messenger:'+quote(p,safe='')+'@db:5432/messenger')
PY2
fi
chmod 600 secrets/database_url
if [ ! -f .env ]; then
printf 'SESSION_TTL_SECONDS=3600\n' > .env
fi