diff --git a/type/__ungleich_matrix/man.rst b/type/__ungleich_matrix/man.rst index b4b2903..b8583e4 100644 --- a/type/__ungleich_matrix/man.rst +++ b/type/__ungleich_matrix/man.rst @@ -8,8 +8,8 @@ cdist-type__ungleich_matrix - ungleich matrix enviroment DESCRIPTION ----------- -This type deploys a Matrix homeserver (synapse) and web client (element) on -ungleich's infrastructure. This is a singleton type. +This type deploys a Matrix homeserver (synapse) and optionally a web client +(element) on ungleich's infrastructure. This is a singleton type. REQUIRED PARAMETERS @@ -21,13 +21,6 @@ synapse-domain Public address of the Matrix homeserver. This must be a domain name, as it is used to generate TLS certificates and configuration for the web server. -element-address - Public address of the Element web client. This must be a domain name, as it is - used to generate TLS certificates and configuration for the web server. - -element-version - Version of the Element client to be deployed. - synapse-smtp-user SMTP user to ungleich's mail infrastructure. Used by Synapse to send notifications over email. @@ -45,6 +38,14 @@ synapse-extra-parameters element-extra-parameters Extra parameters passed to the `__matrix_element` type. +element-address + Public address of the Element web client. This must be a domain name, as it + is used to generate TLS certificates and configuration for the web server. + Element is only deployed if this parameter is set. + +element-version + Version of the Element client to be deployed. + BOOLEAN PARAMETERS ------------------ None. diff --git a/type/__ungleich_matrix/manifest b/type/__ungleich_matrix/manifest index 65a4dcf..b132404 100755 --- a/type/__ungleich_matrix/manifest +++ b/type/__ungleich_matrix/manifest @@ -35,9 +35,15 @@ SMTP_SERVER_PORT="587" # Type parameters. matrix_domain=$(cat "$__object/parameter/matrix-domain") -element_domain=$(cat "$__object/parameter/element-domain") synapse_domain=$(cat "$__object/parameter/synapse-domain") -element_version=$(cat "$__object/parameter/element-version") + +if [ -f "$__object/parameter/element-domain" ]; then + element_domain=$(cat "$__object/parameter/element-domain") + deploy_element=1 +fi +if [ -f "$__object/parameter/element-version" ]; then + element_version=$(cat "$__object/parameter/element-version") +fi synapse_smtp_user=$(cat "$__object/parameter/synapse-smtp-user") synapse_smtp_password=$(cat "$__object/parameter/synapse-smtp-password") @@ -59,7 +65,19 @@ postgres_database='matrix-synapse' www_directory_owner=root nginx_basedir='/var/www/static' -### +## +# Check for invalid parameter combinations. + +if [ -n "$element_domain" ] && [ -z "$element_version" ]; then + echo "--element-version is required if --element-domain is set." >&2 + exit 1 +fi +if [ -z "$element_domain" ] && [ -n "$element_version" ]; then + echo "--element-domain is required if --element-version is set." >&2 + exit 1 +fi + +## # Deployment logic. # Install & configure PGSQL database. @@ -84,6 +102,7 @@ __matrix_synapse \ --database-user "$postgres_user" \ --database-host '/var/run/postgresql' \ --enable-notifications \ + --notification-from "Matrix <$synapse_smtp_user>" \ --smtp-host "$SMTP_SERVER" \ --smtp-port "$SMTP_SERVER_PORT" \ --smtp-use-starttls \ @@ -91,20 +110,6 @@ __matrix_synapse \ --smtp-pass "$synapse_smtp_password" \ $synapse_extra_parameters -# Install & configure Element (matrix web client). -# shellcheck disable=SC2086 -__matrix_element ungleich \ - --install_dir "$nginx_basedir/$www_directory_owner/$element_domain/www" \ - --default_server_url "$synapse_base_url" \ - --default_server_name "$matrix_domain" \ - --owner "$www_directory_owner" \ - --version "$element_version" \ - --jitsi_domain "$JITSI_DOMAIN" \ - --privacy_policy_url "$PRIVACY_POLICY_URL" \ - --disable_custom_urls \ - --branding_auth_footer_links [] \ - $element_extra_parameters - # Install and configure NGINX web server/proxy. __package nginx @@ -152,7 +157,7 @@ require="__matrix_synapse __package/nginx" \ # clients if matrix_domain is element_domain (= both are handled by this # type). element_nginx_config= -if [ "${element_domain:?}" = "${matrix_domain:?}" ]; then +if [ "$element_domain" = "${matrix_domain:?}" ]; then element_nginx_config="$(cat <<- EOF location = /.well-known/matrix/server { default_type application/json; @@ -175,9 +180,25 @@ if [ "${element_domain:?}" = "${matrix_domain:?}" ]; then )" fi -require="__package/nginx" \ - __ungleich_nginx_static_site "$element_domain" \ - --owner "$www_directory_owner" \ - --listen '443 [::]:443' \ - --base_directory "$nginx_basedir" \ - --locationopt "$element_nginx_config" +if [ -n "$deploy_element" ]; then + # Install & configure Element (matrix web client). + # shellcheck disable=SC2086 + __matrix_element ungleich \ + --install_dir "$nginx_basedir/$www_directory_owner/$element_domain/www" \ + --default_server_url "$synapse_base_url" \ + --default_server_name "$matrix_domain" \ + --owner "$www_directory_owner" \ + --version "$element_version" \ + --jitsi_domain "$JITSI_DOMAIN" \ + --privacy_policy_url "$PRIVACY_POLICY_URL" \ + --disable_custom_urls \ + --branding_auth_footer_links [] \ + $element_extra_parameters + + require="__package/nginx" \ + __ungleich_nginx_static_site "$element_domain" \ + --owner "$www_directory_owner" \ + --listen '443 [::]:443' \ + --base_directory "$nginx_basedir" \ + --locationopt "$element_nginx_config" +fi diff --git a/type/__ungleich_matrix/parameter/optional b/type/__ungleich_matrix/parameter/optional index 9307d6a..1adc62c 100644 --- a/type/__ungleich_matrix/parameter/optional +++ b/type/__ungleich_matrix/parameter/optional @@ -1,2 +1,4 @@ +element-domain +element-version synapse-extra-parameters element-extra-parameters diff --git a/type/__ungleich_matrix/parameter/required b/type/__ungleich_matrix/parameter/required index 5000d5f..9a374a3 100644 --- a/type/__ungleich_matrix/parameter/required +++ b/type/__ungleich_matrix/parameter/required @@ -1,6 +1,4 @@ matrix-domain -element-domain synapse-domain -element-version synapse-smtp-user synapse-smtp-password