#!/bin/bash set -e PASSWORD="$(relation-get password)" USER="$(relation-get user)" DBNAME="$(relation-get dbname)" control=$(echo -en "$USER\0$DBNAME\0$PASSWORD" | md5_compat) init-config-add " $SERVICE_NAME: environment: POSTGRES_HOST: $MASTER_TARGET_SERVICE_NAME POSTGRES_DB: $DBNAME POSTGRES_USER: $USER POSTGRES_PASSWORD: $PASSWORD " [ "$control" == "$(relation-get control 2>/dev/null)" ] && exit 0 relation-set control "$control" info "Configured $SERVICE_NAME code for $TARGET_SERVICE_NAME access."