Matrix Docker Ansible eploy
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

32 строки
1.3 KiB

  1. #!/bin/sh
  2. # Asks the homeserver who Meowlnir's appservice token belongs to.
  3. #
  4. # A `200` response proves the homeserver has Meowlnir's appservice registration loaded.
  5. # A `401` (`M_UNKNOWN_TOKEN`) response means it is running without it — the condition that otherwise surfaces as Meowlnir endlessly logging "Failed to connect to homeserver".
  6. #
  7. # Usage: meowlnir-whoami
  8. #
  9. # Prints the response body, followed by the HTTP status code on its own final line.
  10. set -eu
  11. CONFIG_FILE='{{ matrix_bot_meowlnir_config_path }}/config.yaml'
  12. CONTAINER_NAME='matrix-bot-meowlnir'
  13. HOMESERVER_ADDRESS='{{ matrix_bot_meowlnir_config_homeserver_address }}'
  14. REQUEST_TIMEOUT='{{ matrix_bot_meowlnir_api_request_timeout_seconds }}'
  15. # The configuration file is generated by Ansible, so its layout is predictable.
  16. as_token="$(awk '$1 == "as_token:" { print $2; exit }' "$CONFIG_FILE" | sed 's/^"//; s/"$//')"
  17. if [ -z "$as_token" ]; then
  18. echo "Could not read as_token from $CONFIG_FILE" >&2
  19. exit 1
  20. fi
  21. # Runs curl inside the container, because the homeserver is only reachable over the container network.
  22. exec {{ devture_systemd_docker_base_host_command_docker }} exec "$CONTAINER_NAME" \
  23. curl -sS --max-time "$REQUEST_TIMEOUT" \
  24. -H "Authorization: Bearer $as_token" \
  25. -w '\n%{http_code}' \
  26. "$HOMESERVER_ADDRESS/_matrix/client/v3/account/whoami"