#!/bin/sh # Create the Coordinator's database role (idempotent). Run on the node as root: sudo sh provision-db.sh # The role may read exactly four columns of one table. The password is read from /opt/coa/secrets/coordinator_db_password (created here when missing) and goes to psql on stdin. set -eu umask 077 if [ ! -s /opt/coa/secrets/coordinator_db_password ]; then head -c 32 /dev/urandom | base64 | tr -d '/+=\n' | head -c 40 > /opt/coa/secrets/coordinator_db_password fi chown root:10002 /opt/coa/secrets/coordinator_db_password chmod 0440 /opt/coa/secrets/coordinator_db_password PW=$(cat /opt/coa/secrets/coordinator_db_password) docker exec -i coa-postgres-postgres-1 sh -c 'PGPASSWORD=$(cat /run/secrets/postgres_password) exec psql -U coa -d coa_registry -v ON_ERROR_STOP=1 -q' <