#!/bin/sh # Operator step 1 (after scripts/pki.sh init): local .env and random bootstrap credentials in secrets/bootstrap/. # Nothing is printed. Existing files are kept, so a re-run never changes the passwords of a live stand. # # Who gets what: # stores (postgres, minio, valkey, grafana) read their OWN admin/ACL material from Docker secrets; # API and worker get NO password files at all: scripts/bao.sh bootstrap copies their credentials into OpenBao # and the services read them there after authenticating with their client certificate. set -eu cd "$(dirname "$0")/.." [ -f .env ] || cp .env.example .env umask 077 mkdir -p secrets/bootstrap cd secrets/bootstrap put() { [ -f "$1" ] || printf '%s' "$2" > "$1"; } random() { python3 -c "import secrets;print(secrets.token_urlsafe(24),end='')"; } put postgres_password "$(random)" # superuser `messenger`: migrations and operator only put db_api_password "$(random)" # role app_api put db_worker_password "$(random)" # role app_worker put minio_root_user messenger_root put minio_root_password "$(random)" put s3_api_access_key messenger-api put s3_api_secret_key "$(random)" put s3_worker_access_key messenger-worker put s3_worker_secret_key "$(random)" put valkey_api_password "$(random)" # ACL user `api` put grafana_admin_password "$(random)" put migrate_database_url "postgresql://messenger:$(cat postgres_password)@postgres:5432/messenger" chmod 644 ./* # read by container users through Docker secrets; the directory itself is 700 cd .. chmod 700 . bootstrap echo "bootstrap credentials ready in secrets/bootstrap/ (.env present)"