[__ungleich_matrix] Make element optional, set notification-from
This commit is contained in:
parent
e91afafeba
commit
3b8d59bbf4
4 changed files with 57 additions and 35 deletions
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,2 +1,4 @@
|
|||
element-domain
|
||||
element-version
|
||||
synapse-extra-parameters
|
||||
element-extra-parameters
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
matrix-domain
|
||||
element-domain
|
||||
synapse-domain
|
||||
element-version
|
||||
synapse-smtp-user
|
||||
synapse-smtp-password
|
||||
|
|
Loading…
Reference in a new issue