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

57 строки
2.2 KiB

  1. #!/bin/bash
  2. # clear out old variables if they exist
  3. if test -f ./vars.yml*; then
  4. rm ./vars.yml*
  5. fi
  6. if test -f ./hosts*; then
  7. rm ./hosts*
  8. fi
  9. rm -rf inventory/host_vars/*
  10. if test -f inventory/hosts*; then
  11. rm inventory/hosts*
  12. fi
  13. # prompt the user for basic info
  14. read -p "Enter the base domain (e.g. example.com): " domain
  15. read -p "Enter the external IP address: " address
  16. # initialize vars.yml
  17. mkdir inventory/host_vars/matrix.$domain
  18. cp examples/vars.yml inventory/host_vars/matrix.$domain/vars.yml
  19. sed -i "s/matrix_domain: YOUR_BARE_DOMAIN_NAME_HERE/matrix_domain: $domain/" inventory/host_vars/matrix.$domain/vars.yml
  20. read -p "Enable automatic SSL certificate management? (y/n): " cert
  21. if [[ $cert == "n" || $cert == "N" ]]
  22. then
  23. sed -i "s/matrix_ssl_lets_encrypt_support_email: ''/matrix_ssl_retrieval_method: /" inventory/host_vars/matrix.$domain/vars.yml
  24. else
  25. read -p "Provide an email for contact from Let's Encrypt: " email
  26. sed -i "s/matrix_ssl_lets_encrypt_support_email: '/matrix_ssl_lets_encrypt_support_email: \'$email/" inventory/host_vars/matrix.$domain/vars.yml
  27. fi
  28. pw=$(openssl rand -hex 64)
  29. sed -i "s/matrix_coturn_turn_static_auth_secret: '/matrix_coturn_turn_static_auth_secret: \'$pw/" inventory/host_vars/matrix.$domain/vars.yml
  30. pw=$(openssl rand -hex 64)
  31. sed -i "s/matrix_synapse_macaroon_secret_key: '/matrix_synapse_macaroon_secret_key: \'$pw/" inventory/host_vars/matrix.$domain/vars.yml
  32. pw=$(openssl rand -hex 64)
  33. sed -i "s/matrix_postgres_connection_password: '/matrix_postgres_connection_password: \'$pw/" inventory/host_vars/matrix.$domain/vars.yml
  34. # initialize hosts
  35. cp examples/hosts inventory/hosts
  36. sed -i "s/matrix.<your-domain> ansible_host=<your-server's external IP address>/matrix.$domain ansible_host=$address/" inventory/hosts
  37. read -p "Are you running this Ansible playbook on the same server as the one you're installing to? (y/n): " same
  38. if [[ $same == "y" || $same == "Y" ]]
  39. then
  40. sed -i "s/ansible_ssh_user=root/ansible_ssh_user=root ansible_connection=local/" inventory/hosts
  41. fi
  42. # create symbolic links to make the config files more accessible
  43. ln -s inventory/host_vars/matrix.$domain/vars.yml .
  44. ln -s inventory/hosts .
  45. echo "The files 'vars.yml' and 'hosts' are ready to be configured."