Files
mtusi2026lab5/scripts/bootstrap.sh
2026-11-13 12:48:18 +03:00

26 lines
848 B
Bash
Executable File

#!/bin/sh
set -eu
cd "$(dirname "$0")/.."
umask 077
mkdir -p secrets/lab5
if [ ! -f .env.lab5 ]; then
{ printf 'POSTGRES_PASSWORD='; openssl rand -hex 24
printf 'REDIS_PASSWORD='; openssl rand -hex 24
printf 'HOST_PORT=18085\nAPI_REPLICAS=2\n'
} > .env.lab5
fi
if [ ! -f secrets/lab5/private_key.pem ]; then
openssl genrsa -out secrets/lab5/private_key.pem 2048 2>/dev/null
fi
if [ ! -f secrets/lab5/public_key.pem ]; then
openssl rsa -in secrets/lab5/private_key.pem -pubout -out secrets/lab5/public_key.pem 2>/dev/null
fi
# Only synthetic stand keys, readable by the non-root application inside containers.
chmod 755 secrets secrets/lab5
chmod 444 secrets/lab5/*.pem
printf '%s\n' 'Local lab5 settings and synthetic keys ready; existing files preserved.'
python3 scripts/bootstrap-storage.py
python3 scripts/bootstrap-broker.py