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.

31 lines
772 B

  1. #!/bin/bash
  2. set -e
  3. PASSWORD="$(relation-get password)"
  4. USER="$(relation-get user)"
  5. DBNAME="$(relation-get dbname)"
  6. control=$(echo -en "$USER\0$DBNAME\0$PASSWORD" | md5_compat)
  7. config-add "\
  8. services:
  9. $MASTER_BASE_SERVICE_NAME:
  10. environment:
  11. DB_HOST: $MASTER_TARGET_SERVICE_NAME
  12. MM_DBNAME: $DBNAME
  13. MM_PASSWORD: $PASSWORD
  14. MM_USERNAME: $USER
  15. "
  16. if [ -e "$SERVICE_CONFIGSTORE/mattermost/config/config.json" ]; then
  17. sed -ri 's/(^\s+"DataSource": "postgres:[^:]+:)([^@]+)@/\1'"$PASSWORD"'@/' \
  18. "$SERVICE_CONFIGSTORE/mattermost/config/config.json" || exit 1
  19. fi
  20. [ "$control" == "$(relation-get control 2>/dev/null)" ] && exit 0
  21. relation-set control "$control"
  22. info "Configured $SERVICE_NAME code for $TARGET_SERVICE_NAME access."