Matrix Docker Ansible eploy
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 

54 行
2.0 KiB

  1. #jinja2: lstrip_blocks: True
  2. #!/bin/bash
  3. {% if matrix_synapse_matrix_authentication_service_enabled %}
  4. echo "Registering users is handled by the Matrix Authentication Service, so you cannot use this script anymore."
  5. echo "Consider using the {{ matrix_synapse_register_user_script_matrix_authentication_service_path }} script instead."
  6. exit 2
  7. {% else %}
  8. if [ $# -ne 3 ]; then
  9. echo "Usage: "$0" <username> <password> <admin access: 0 or 1>"
  10. exit 1
  11. fi
  12. user=$1
  13. password=$2
  14. admin=$3
  15. wait_for_synapse() {
  16. local timeout_seconds=180
  17. local interval_seconds=5
  18. local elapsed=0
  19. local last_reason=""
  20. while [ "$elapsed" -lt "$timeout_seconds" ]; do
  21. if ! {{ devture_systemd_docker_base_host_command_docker }} ps -a --format '{{"{{"}}.Names{{"}}"}}' | grep -q '^matrix-synapse$'; then
  22. last_reason="container not found"
  23. elif [ "$({{ devture_systemd_docker_base_host_command_docker }} inspect -f '{{"{{"}}.State.Running{{"}}"}}' matrix-synapse 2>/dev/null)" != "true" ]; then
  24. last_reason="container not running"
  25. elif ! {{ devture_systemd_docker_base_host_command_docker }} exec matrix-synapse \
  26. curl -fsS "http://localhost:{{ matrix_synapse_container_client_api_port }}/health" >/dev/null 2>&1; then
  27. last_reason="health endpoint not ready"
  28. else
  29. return 0
  30. fi
  31. sleep "$interval_seconds"
  32. elapsed=$((elapsed + interval_seconds))
  33. done
  34. echo "Timed out waiting for matrix-synapse to become healthy after ${timeout_seconds}s (${last_reason})."
  35. return 1
  36. }
  37. if ! wait_for_synapse; then
  38. exit 1
  39. fi
  40. if [ "$admin" -eq "1" ]; then
  41. {{ devture_systemd_docker_base_host_command_docker }} exec matrix-synapse register_new_matrix_user -u "$user" -p "$password" -c /data/homeserver.yaml --admin http://localhost:{{ matrix_synapse_container_client_api_port }}
  42. else
  43. {{ devture_systemd_docker_base_host_command_docker }} exec matrix-synapse register_new_matrix_user -u "$user" -p "$password" -c /data/homeserver.yaml --no-admin http://localhost:{{ matrix_synapse_container_client_api_port }}
  44. fi
  45. {% endif %}