forked from mtusi2026/mtusi2026lab2
17 lines
552 B
Bash
Executable File
17 lines
552 B
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
cd "$(dirname "$0")/.."
|
|
mkdir -p secrets
|
|
|
|
if [ -f secrets/postgres_password ]; then
|
|
echo "secrets/ уже существует — оставляю как есть"
|
|
exit 0
|
|
fi
|
|
|
|
password="$(head -c 32 /dev/urandom | od -An -tx1 | tr -d ' \n')"
|
|
printf '%s' "$password" > secrets/postgres_password
|
|
printf 'postgresql+psycopg://messenger:%s@postgres:5432/messenger' "$password" > secrets/database_url
|
|
|
|
chmod 644 secrets/postgres_password secrets/database_url
|
|
echo "OK: secrets/postgres_password и secrets/database_url созданы"
|