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.

34 lines
837 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. config-add "\
  10. services:
  11. $MASTER_BASE_SERVICE_NAME:
  12. environment:
  13. DB_HOST: $HOST
  14. DB_PORT_NUMBER: $PORT
  15. MM_DBNAME: $DBNAME
  16. MM_PASSWORD: $PASSWORD
  17. MM_USERNAME: $USER
  18. "
  19. if [ -e "$SERVICE_CONFIGSTORE/mattermost/config/config.json" ]; then
  20. sed -ri 's/(^\s+"DataSource": "postgres:[^:]+:)([^@]+)@/\1'"$PASSWORD"'@/' \
  21. "$SERVICE_CONFIGSTORE/mattermost/config/config.json" || exit 1
  22. fi
  23. [ "$control" == "$(relation-get control 2>/dev/null)" ] && exit 0
  24. relation-set control "$control"
  25. info "Configured $SERVICE_NAME code for $HOST:$PORT access."