argocd/apps/postgres/init/10-app-databases.sh

15 lines
553 B
Bash
Raw Normal View History

2026-10-11 21:03:33 +02:00
#!/bin/sh
# Runs once, on the first start with an empty data directory. One role and one
# database per app; passwords come from postgres-secrets.
# Adding an app later: run the same CREATE ROLE / CREATE DATABASE by hand
# (kubectl -n postgres exec -it postgres-0 -- psql -U postgres).
set -e
for app in wikijs paperless linkwarden firefly hedgedoc; do
var=$(echo "$app" | tr a-z A-Z)_DB_PASSWORD
eval pass=\$$var
psql -v ON_ERROR_STOP=1 -U "$POSTGRES_USER" <<SQL
CREATE ROLE $app LOGIN PASSWORD '$pass';
CREATE DATABASE $app OWNER $app;
SQL
done