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.

47 lines
1.0 KiB

  1. #!/bin/bash
  2. set -e
  3. PASSWORD="$(relation-get password)"
  4. DBUSER="$(relation-get user)"
  5. DBNAME="$(relation-get dbname)"
  6. . lib/common
  7. control=$(printf "%s\0" "$DBUSER" "$DBNAME" "$PASSWORD" | md5_compat)
  8. ## Note: we don't use environment variable as it will be ignored if
  9. ## $CONFIG_FILE is found. So better modify directly the config file.
  10. # config-add "\
  11. # services:
  12. # $MASTER_BASE_SERVICE_NAME:
  13. # environment:
  14. # - DB_TYPE=postgres
  15. # - DB_HOST=$MASTER_TARGET_SERVICE_NAME
  16. # - DB_NAME=$DBNAME
  17. # - DB_USER=$USER
  18. # - DB_PASSWD=$PASSWORD
  19. # "
  20. # ini set database DB_TYPE postgres
  21. # ini set database HOST postgres
  22. # ini set database NAME gitea.mydomain.org
  23. # ini set database USER gitea.mydomain.org
  24. # ini set database PASSWD g61wsLvKj8cF6A1S
  25. # ini set database SSL_MODE disable
  26. ini merge <<EOF
  27. [database]
  28. DB_TYPE = postgres
  29. HOST = $MASTER_TARGET_SERVICE_NAME
  30. NAME = $DBNAME
  31. USER = $DBUSER
  32. PASSWD = $PASSWORD
  33. SSL_MODE = disable
  34. EOF
  35. relation-set control "$control"
  36. info "Configured $SERVICE_NAME code for $TARGET_SERVICE_NAME access."