fork 0k-charms
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
743 B

  1. #!/bin/bash
  2. set -e
  3. PASSWORD="$(relation-get password)"
  4. USER="$(relation-get user)"
  5. DBNAME="$(relation-get dbname)"
  6. HOST="$(relation-get host)"
  7. PORT="$(relation-get port)"
  8. control=$(p0 "$USER" "$DBNAME" "$PASSWORD" "$HOST" "$PORT" | md5_compat)
  9. ## Used doc from https://github.com/mattermost/docker/blob/main/env.example
  10. config-add "\
  11. services:
  12. $MASTER_BASE_SERVICE_NAME:
  13. environment:
  14. MM_SQLSETTINGS_DRIVERNAME: postgres
  15. MM_SQLSETTINGS_DATASOURCE: \"postgres://${USER}:${PASSWORD}@${HOST}:${PORT}/${DBNAME}?sslmode=disable&connect_timeout=10\"
  16. " || exit 17
  17. [ "$control" == "$(relation-get control 2>/dev/null)" ] && exit 0
  18. relation-set control "$control"
  19. info "Configured $SERVICE_NAME code for $HOST:$PORT access."