Files
mtusi2026lab2/scripts/bootstrap-local.sh
T
afanasefff_aandCursor 6300cfc6e0 Добавить мессенджер на Java с PostgreSQL и сессиями в Redis.
Данные и действующий токен переживают рестарт, сессии хранятся в Redis с AOF.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-14 20:52:39 +03:00

17 lines
541 B
Bash
Executable File

#!/bin/sh
set -eu
cd "$(dirname "$0")/.."
mkdir -p secrets
umask 077
if [ ! -s secrets/postgres_password ]; then
tr -dc 'A-Za-z0-9' < /dev/urandom | head -c 24 > secrets/postgres_password
fi
pass=$(tr -d '\n' < secrets/postgres_password)
printf 'jdbc:postgresql://postgres:5432/messenger?user=messenger&password=%s\n' "$pass" > secrets/database_url
printf 'redis://redis:6379/0\n' > secrets/cache_url
chmod 600 secrets/postgres_password
chmod 644 secrets/database_url secrets/cache_url
if [ ! -f .env ]; then
cp .env.example .env
fi