Files
coa-server-manager/services/coa-registry/deploy/provision-db.sh
T
ДмитрийandClaude Sonnet 5.5 1267bcc41e Phase 10: central realm Registry, Host publishing lifecycle, deployment
crates/coa-registry-proto (protocol 1: types, limits, signed-request canonicalisation, test vectors),
services/coa-registry (axum + PostgreSQL, migrations, rate limits, Dockerfile, deploy files),
services/coa-registry-e2e (Host lifecycle against the real service, live VPS gate),
coa-core realm_registry (identity keys, client, publishing loop on its own thread),
Settings -> Public listing card, docs REGISTRY_PROTOCOL.md and REGISTRY_DEPLOYMENT.md.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-07 20:23:13 +05:00

19 lines
1006 B
Bash

#!/bin/sh
# Create the Registry's database role and database (idempotent). Run on the node as root: sudo sh provision-db.sh
# The password is read from /opt/coa/secrets/registry_db_password and goes to psql on stdin, never on a command line.
set -eu
PW=$(cat /opt/coa/secrets/registry_db_password)
docker exec -i coa-postgres-postgres-1 sh -c 'PGPASSWORD=$(cat /run/secrets/postgres_password) exec psql -U coa -d coa -v ON_ERROR_STOP=1 -q' <<SQL
DO \$\$ BEGIN
IF NOT EXISTS (SELECT FROM pg_roles WHERE rolname = 'coa_registry') THEN
CREATE ROLE coa_registry LOGIN PASSWORD '$PW' NOSUPERUSER NOCREATEDB NOCREATEROLE CONNECTION LIMIT 20;
ELSE
ALTER ROLE coa_registry PASSWORD '$PW';
END IF;
END \$\$;
SELECT 'CREATE DATABASE coa_registry OWNER coa_registry' WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'coa_registry')\gexec
REVOKE ALL ON DATABASE coa_registry FROM PUBLIC;
GRANT CONNECT ON DATABASE coa_registry TO coa_registry;
SQL
echo "registry role and database are in place"