Files
mtusi2026lab4/scripts/init-secrets.sh
T

20 lines
590 B
Bash
Executable File

#!/bin/sh
# Creates local secrets for the Compose stack. Never overwrites an existing secret:
# the PostgreSQL volume is initialised with the first password and keeps it.
set -eu
cd "$(dirname "$0")/.."
mkdir -p secrets
# Readable by the non-root users inside the containers (bind-mounted as is).
umask 022
for name in db_password redis_password s3_access_key_id s3_secret_access_key; do
if [ ! -s "secrets/$name" ]; then
openssl rand -hex 24 > "secrets/$name"
echo "created secrets/$name"
else
echo "secrets/$name already exists, keeping it"
fi
done