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.

50 lines
1.1 KiB

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