28 lines
491 B

#!/bin/bash
set -e
. lib/common
PASSWORD="$(relation-get password)"
USER="$(relation-get user)"
DBNAME="$(relation-get dbname)"
control=$(echo -en "$USER\0$DBNAME\0$PASSWORD" | md5_compat)
cfg-merge "
database:
name: psycopg2
args:
user: $USER
password: $PASSWORD
database: $DBNAME
host: $MASTER_TARGET_SERVICE_NAME
port: 5432
cp_min: 5
cp_max: 10
"
relation-set control "$control"
info "Configured $SERVICE_NAME code for $TARGET_SERVICE_NAME access."