From ea7df8518d9daa667b6dbdbdf7746d873519b473 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sun, 6 Feb 2022 18:05:38 +0000 Subject: [PATCH 01/31] Fix Go installation for multiple architectures --- conf/systemd.service | 5 +- scripts/_common.sh | 2 + scripts/install | 42 ++++--- scripts/remove | 4 + scripts/restore | 15 +-- scripts/upgrade | 36 +++--- scripts/ynh_install_go | 247 +++++++++++++++++++++++++++++++++++++++++ 7 files changed, 300 insertions(+), 51 deletions(-) create mode 100644 scripts/ynh_install_go diff --git a/conf/systemd.service b/conf/systemd.service index 996a086..861b72d 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -7,7 +7,10 @@ Type=simple User=__APP__ Group=__APP__ WorkingDirectory=__FINALPATH__/ -ExecStart=__FINALPATH__/./bin/dendrite-monolith-server --tls-cert=/etc/yunohost/certs/__DOMAIN__/crt.pem --tls-key=/etc/yunohost/certs/__DOMAIN__/key.pem --config=dendrite.yaml --http-bind-address=:__PORT__ --https-bind-address=:__TLS_PORT__ >> /var/log/__APP__/__APP__.log 2>&1 +Environment="__YNH_GO_LOAD_PATH__" +ExecStart=__FINALPATH__/bin/dendrite-monolith-server --tls-cert=/etc/yunohost/certs/__DOMAIN__/crt.pem --tls-key=/etc/yunohost/certs/__DOMAIN__/key.pem --config=dendrite.yaml --http-bind-address=:__PORT__ --https-bind-address=:__TLS_PORT__ +StandardOutput=append:/var/log/__APP__/__APP__.log +StandardError=inherit # Sandboxing options to harden security # Depending on specificities of your service/app, you may need to tweak these diff --git a/scripts/_common.sh b/scripts/_common.sh index c0220ac..c974660 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -7,6 +7,8 @@ # dependencies used by the app pkg_dependencies="postgresql postgresql-contrib" +go_version="1.16" + #================================================= # PERSONAL HELPERS #================================================= diff --git a/scripts/install b/scripts/install index d03d6b6..e2d21dc 100644 --- a/scripts/install +++ b/scripts/install @@ -7,6 +7,7 @@ #================================================= source _common.sh +source ynh_install_go source /usr/share/yunohost/helpers #================================================= @@ -67,6 +68,15 @@ ynh_exec_warn_less yunohost firewall allow TCP $tls_port ynh_app_setting_set --app=$app --key=port --value=$port ynh_app_setting_set --app=$app --key=tls_port --value=$tls_port +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Configuring system user..." --weight=1 + +# Create a system user +# It needs to be created before using the ynh_install_go helper +ynh_system_user_create --username=$app --use_shell --groups="ssl-cert" + #================================================= # INSTALL DEPENDENCIES #================================================= @@ -74,15 +84,8 @@ ynh_script_progression --message="Installing dependencies..." --weight=3 ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies -# Install Go if needed -if ! command -v /usr/local/go/bin/go &> /dev/null -then - ynh_script_progression --message="Installing Go dependency... (this will take some time)" --weight=3 - ynh_setup_source --source_id="go" --dest_dir="/usr/local/" -fi - -export PATH=$PATH:/usr/local/go/bin -env_path=$PATH +# Install Go +ynh_exec_warn_less ynh_install_go --go_version=$go_version #================================================= # CREATE A POSTGRESQL DATABASE @@ -94,8 +97,8 @@ ynh_app_setting_set --app=$app --key=db_name --value=$db_name ynh_psql_test_if_first_run ynh_psql_setup_db --db_user=$db_name --db_name=$db_name -ynh_psql_execute_as_root \ ---sql="CREATE DATABASE $db_name ENCODING 'UTF8' LC_COLLATE='C' LC_CTYPE='C' template=template0 OWNER $app;" +ynh_psql_execute_as_root --sql="DROP DATABASE $db_name" +ynh_psql_execute_as_root --sql="CREATE DATABASE $db_name ENCODING 'UTF8' LC_COLLATE='C' LC_CTYPE='C' template=template0 OWNER $app;" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -114,26 +117,21 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." --weight=1 - -# Create a system user -ynh_system_user_create --username=$app -adduser $app ssl-cert - #================================================= # SPECIFIC SETUP #================================================= # BUILDING SOURCES AND SETTING UP THE SERVER #================================================= +ynh_use_go + +mkdir -p "$final_path/bin" +chown -R $app:root $final_path + pushd "$final_path" ynh_script_progression --message="Building the sources (it will take some time)..." --weight=6 # Build the sources - mkdir ./bin - ynh_exec_warn_less ./build.sh + ynh_exec_warn_less ynh_exec_as $app $ynh_go_load_path HOME=$final_path ./build.sh ynh_script_progression --message="Generating the keys..." --weight=1 # Generate a Matrix signing key for federation ./bin/generate-keys --private-key matrix_key.pem diff --git a/scripts/remove b/scripts/remove index 601e5f3..effd47e 100644 --- a/scripts/remove +++ b/scripts/remove @@ -7,6 +7,7 @@ #================================================= source _common.sh +source ynh_install_go source /usr/share/yunohost/helpers #================================================= @@ -58,6 +59,9 @@ ynh_script_progression --message="Removing dependencies..." --weight=3 # Remove metapackage and its dependencies ynh_remove_app_dependencies +# Remove Go +ynh_remove_go + #================================================= # REMOVE APP MAIN DIR #================================================= diff --git a/scripts/restore b/scripts/restore index 375b040..4fbfa23 100644 --- a/scripts/restore +++ b/scripts/restore @@ -8,6 +8,7 @@ # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh +source ../settings/scripts/ynh_install_go source /usr/share/yunohost/helpers #================================================= @@ -66,7 +67,7 @@ ynh_restore_file --origin_path="$final_path" ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 # Create the dedicated user (if not existing) -ynh_system_user_create --username=$app +ynh_system_user_create --username=$app --use_shell --groups="ssl-cert" #================================================= # RESTORE USER RIGHTS @@ -87,15 +88,8 @@ ynh_script_progression --message="Reinstalling dependencies..." --weight=3 # Define and install dependencies ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies -# Install Go if needed -if ! command -v /usr/local/go/bin/go &> /dev/null -then - ynh_script_progression --message="Installing Go dependency... (this will take some time)" --weight=3 - ynh_setup_source --source_id="go" --dest_dir="/usr/local/" -fi - -export PATH=$PATH:/usr/local/go/bin -env_path=$PATH +# Install Go +ynh_install_go --go_version=$go_version #================================================= # RESTORE THE PSQL DATABASE @@ -119,6 +113,7 @@ systemctl enable $app.service --quiet #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 +ynh_use_go yunohost service add $app --description="Dendrite Matrix homeserver" --log="/var/log/$app/Monolith.log" --needs_exposed_ports "$tls_port" #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index f490dbc..60cf7bb 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -7,6 +7,7 @@ #================================================= source _common.sh +source ynh_install_go source /usr/share/yunohost/helpers #================================================= @@ -81,6 +82,15 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." - # Create a dedicated NGINX config ynh_add_nginx_config +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 + +# Create a dedicated user (if not existing) +# It needs to be created before using the ynh_install_go helper +ynh_system_user_create --username=$app --use_shell --groups="ssl-cert" + #================================================= # UPGRADE DEPENDENCIES #================================================= @@ -88,23 +98,8 @@ ynh_script_progression --message="Upgrading dependencies..." --weight=1 ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies" -# TODO: check Go version and upgrade if needed -if ! command -v /usr/local/go/bin/go &> /dev/null -then - ynh_script_progression --message="Installing Go dependency... (this will take some time)" --weight=3 - ynh_setup_source --source_id="go" --dest_dir="/usr/local/" -fi - -export PATH=$PATH:/usr/local/go/bin -env_path=$PATH - -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 - -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app +# Install Go +ynh_exec_warn_less ynh_install_go --go_version=$go_version #================================================= # SPECIFIC UPGRADE @@ -112,10 +107,15 @@ ynh_system_user_create --username=$app # BUILDING SOURCES AND SETTING UP THE SERVER #================================================= +ynh_use_go + +mkdir -p "$final_path/bin" +chown -R $app:root $final_path + pushd "$final_path" ynh_script_progression --message="Building the sources (it will take some time)..." --weight=6 # Build the sources - ynh_exec_warn_less ./build.sh + ynh_exec_warn_less ynh_exec_as $app $ynh_go_load_path HOME=$final_path ./build.sh popd #================================================= diff --git a/scripts/ynh_install_go b/scripts/ynh_install_go new file mode 100644 index 0000000..28a5f9c --- /dev/null +++ b/scripts/ynh_install_go @@ -0,0 +1,247 @@ +#!/bin/bash + +ynh_go_try_bash_extension() { + if [ -x src/configure ]; then + src/configure && make -C src || { + ynh_print_info --message="Optional bash extension failed to build, but things will still work normally." + } + fi +} + +goenv_install_dir="/opt/goenv" +go_version_path="$goenv_install_dir/versions" +# goenv_ROOT is the directory of goenv, it needs to be loaded as a environment variable. +export GOENV_ROOT="$goenv_install_dir" + +# Load the version of Go for an app, and set variables. +# +# ynh_use_go has to be used in any app scripts before using Go for the first time. +# This helper will provide alias and variables to use in your scripts. +# +# To use gem or Go, use the alias `ynh_gem` and `ynh_go` +# Those alias will use the correct version installed for the app +# For example: use `ynh_gem install` instead of `gem install` +# +# With `sudo` or `ynh_exec_as`, use instead the fallback variables `$ynh_gem` and `$ynh_go` +# And propagate $PATH to sudo with $ynh_go_load_path +# Exemple: `ynh_exec_as $app $ynh_go_load_path $ynh_gem install` +# +# $PATH contains the path of the requested version of Go. +# However, $PATH is duplicated into $go_path to outlast any manipulation of $PATH +# You can use the variable `$ynh_go_load_path` to quickly load your Go version +# in $PATH for an usage into a separate script. +# Exemple: $ynh_go_load_path $final_path/script_that_use_gem.sh` +# +# +# Finally, to start a Go service with the correct version, 2 solutions +# Either the app is dependent of Go or gem, but does not called it directly. +# In such situation, you need to load PATH +# `Environment="__YNH_GO_LOAD_ENV_PATH__"` +# `ExecStart=__FINALPATH__/my_app` +# You will replace __YNH_GO_LOAD_ENV_PATH__ with $ynh_go_load_path +# +# Or Go start the app directly, then you don't need to load the PATH variable +# `ExecStart=__YNH_GO__ my_app run` +# You will replace __YNH_GO__ with $ynh_go +# +# +# one other variable is also available +# - $go_path: The absolute path to Go binaries for the chosen version. +# +# usage: ynh_use_go +# +# Requires YunoHost version 3.2.2 or higher. +ynh_use_go () { + go_version=$(ynh_app_setting_get --app=$app --key=go_version) + + # Get the absolute path of this version of Go + go_path="$go_version_path/$go_version/bin" + + # Allow alias to be used into bash script + shopt -s expand_aliases + + # Create an alias for the specific version of Go and a variable as fallback + ynh_go="$go_path/go" + alias ynh_go="$ynh_go" + + # Load the path of this version of Go in $PATH + if [[ :$PATH: != *":$go_path"* ]]; then + PATH="$go_path:$PATH" + fi + # Create an alias to easily load the PATH + ynh_go_load_path="PATH=$PATH" + + # Sets the local application-specific Go version + pushd $final_path + $goenv_install_dir/bin/goenv local $go_version + popd +} + +# Install a specific version of Go +# +# ynh_install_go will install the version of Go provided as argument by using goenv. +# +# This helper creates a /etc/profile.d/goenv.sh that configures PATH environment for goenv +# for every LOGIN user, hence your user must have a defined shell (as opposed to /usr/sbin/nologin) +# +# Don't forget to execute go-dependent command in a login environment +# (e.g. sudo --login option) +# When not possible (e.g. in systemd service definition), please use direct path +# to goenv shims (e.g. $goenv_ROOT/shims/bundle) +# +# usage: ynh_install_go --go_version=go_version +# | arg: -v, --go_version= - Version of go to install. +# +# Requires YunoHost version 3.2.2 or higher. +ynh_install_go () { + # Declare an array to define the options of this helper. + local legacy_args=v + local -A args_array=( [v]=go_version= ) + local go_version + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + + # Load goenv path in PATH + local CLEAR_PATH="$goenv_install_dir/bin:$PATH" + + # Remove /usr/local/bin in PATH in case of Go prior installation + PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@') + + # Move an existing Go binary, to avoid to block goenv + test -x /usr/bin/go && mv /usr/bin/go /usr/bin/go_goenv + + # Install or update goenv + goenv="$(command -v goenv $goenv_install_dir/bin/goenv | head -1)" + if [ -n "$goenv" ]; then + ynh_print_info --message="goenv already seems installed in \`$goenv'." + pushd "${goenv%/*/*}" + if git remote -v 2>/dev/null | grep "https://github.com/syndbg/goenv.git"; then + echo "Trying to update with git..." + git pull -q --tags origin master + cd .. + ynh_go_try_bash_extension + fi + popd + else + ynh_print_info --message="Installing goenv with git..." + mkdir -p $goenv_install_dir + pushd $goenv_install_dir + git init -q + git remote add -f -t master origin https://github.com/syndbg/goenv.git > /dev/null 2>&1 + git checkout -q -b master origin/master + ynh_go_try_bash_extension + goenv=$goenv_install_dir/bin/goenv + popd + fi + + goenv_latest="$(command -v "$goenv_install_dir"/plugins/*/bin/goenv-latest goenv-latest | head -1)" + if [ -n "$goenv_latest" ]; then + ynh_print_info --message="\`goenv latest' command already available in \`$goenv_latest'." + pushd "${goenv_latest%/*/*}" + if git remote -v 2>/dev/null | grep "https://github.com/momo-lab/xxenv-latest.git"; then + ynh_print_info --message="Trying to update xxenv-latest with git..." + git pull -q origin master + fi + popd + else + ynh_print_info --message="Installing xxenv-latest with git..." + mkdir -p "${goenv_install_dir}/plugins" + git clone -q https://github.com/momo-lab/xxenv-latest.git "${goenv_install_dir}/plugins/xxenv-latest" + fi + + # Enable caching + mkdir -p "${goenv_install_dir}/cache" + + # Create shims directory if needed + mkdir -p "${goenv_install_dir}/shims" + + # Restore /usr/local/bin in PATH + PATH=$CLEAR_PATH + + # And replace the old Go binary + test -x /usr/bin/go_goenv && mv /usr/bin/go_goenv /usr/bin/go + + # Install the requested version of Go + local final_go_version=$(goenv latest --print $go_version) + ynh_print_info --message="Installation of Go-$final_go_version" + goenv install --skip-existing $final_go_version + + # Store go_version into the config of this app + ynh_app_setting_set --app=$YNH_APP_INSTANCE_NAME --key=go_version --value=$final_go_version + + # Cleanup Go versions + ynh_cleanup_go + + # Set environment for Go users + echo "#goenv +export GOENV_ROOT=$goenv_install_dir +export PATH=\"$goenv_install_dir/bin:$PATH\" +eval \"\$(goenv init -)\" +#goenv" > /etc/profile.d/goenv.sh + + # Load the environment + eval "$(goenv init -)" +} + +# Remove the version of Go used by the app. +# +# This helper will also cleanup Go versions +# +# usage: ynh_remove_go +ynh_remove_go () { + local go_version=$(ynh_app_setting_get --app=$YNH_APP_INSTANCE_NAME --key=go_version) + + # Load goenv path in PATH + local CLEAR_PATH="$goenv_install_dir/bin:$PATH" + + # Remove /usr/local/bin in PATH in case of Go prior installation + PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@') + + # Remove the line for this app + ynh_app_setting_delete --app=$YNH_APP_INSTANCE_NAME --key=go_version + + # Cleanup Go versions + ynh_cleanup_go +} + +# Remove no more needed versions of Go used by the app. +# +# This helper will check what Go version are no more required, +# and uninstall them +# If no app uses Go, goenv will be also removed. +# +# usage: ynh_cleanup_go +ynh_cleanup_go () { + + # List required Go versions + local installed_apps=$(yunohost app list | grep -oP 'id: \K.*$') + local required_go_versions="" + for installed_app in $installed_apps + do + local installed_app_go_version=$(ynh_app_setting_get --app=$installed_app --key="go_version") + if [[ $installed_app_go_version ]] + then + required_go_versions="${installed_app_go_version}\n${required_go_versions}" + fi + done + + # Remove no more needed Go versions + local installed_go_versions=$(goenv versions --bare --skip-aliases | grep -Ev '/') + for installed_go_version in $installed_go_versions + do + if ! `echo ${required_go_versions} | grep "${installed_go_version}" 1>/dev/null 2>&1` + then + ynh_print_info --message="Removing of Go-$installed_go_version" + $goenv_install_dir/bin/goenv uninstall --force $installed_go_version + fi + done + + # If none Go version is required + if [[ ! $required_go_versions ]] + then + # Remove goenv environment configuration + ynh_print_info --message="Removing of goenv" + ynh_secure_remove --file="$goenv_install_dir" + ynh_secure_remove --file="/etc/profile.d/goenv.sh" + fi +} From 429633adea3edbaa8d016930c32aa23076bff2f6 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sun, 6 Feb 2022 23:45:36 +0100 Subject: [PATCH 02/31] Update nginx.conf --- conf/nginx.conf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/conf/nginx.conf b/conf/nginx.conf index d192170..a4bbe4c 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -5,11 +5,13 @@ location ~ ^/$ { } location /.well-known/matrix/server { + default_type application/json; return 200 '{ "m.server": "__DOMAIN__:443" }'; } location /.well-known/matrix/client { return 200 '{ "m.homeserver": { "base_url": "https://__DOMAIN__" } }'; + more_set_headers Access-Control-Allow-Origin: *"; } location /_matrix { From e97fb5bdf5f43e1b93f0a823d1d0c835aceec217 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Tue, 8 Feb 2022 21:12:07 +0100 Subject: [PATCH 03/31] Fix change_url while using Go helper --- scripts/change_url | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/change_url b/scripts/change_url index 6160dea..3e1c3aa 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -7,6 +7,7 @@ #================================================= source _common.sh +source ynh_install_go source /usr/share/yunohost/helpers #================================================= @@ -112,6 +113,9 @@ fi #================================================= ynh_script_progression --message="Updating systemd configuration..." --weight=1 +# Load the Go environment path +ynh_use_go + # Create a dedicated systemd config ynh_add_systemd_config From c1621ec3b37b16a8f57ba7c6147bb2bbadd92a7d Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 9 Feb 2022 16:07:45 +0100 Subject: [PATCH 04/31] Update nginx.conf --- conf/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index a4bbe4c..a591ffb 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -11,7 +11,7 @@ location /.well-known/matrix/server { location /.well-known/matrix/client { return 200 '{ "m.homeserver": { "base_url": "https://__DOMAIN__" } }'; - more_set_headers Access-Control-Allow-Origin: *"; + more_set_headers "Access-Control-Allow-Origin: *"; } location /_matrix { From ba90df99b7216d37cadc7edfb19c995c5ae9e553 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Tue, 16 Aug 2022 06:29:35 +0000 Subject: [PATCH 05/31] Upgrade to v0.9.3 --- conf/app.src | 4 ++-- manifest.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/app.src b/conf/app.src index 9827ab6..833ae85 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://api.github.com/repos/matrix-org/dendrite/tarball/v0.8.5 -SOURCE_SUM=53ff43f77f4dfcab70d25684beadc486d65c8dd514e19426380e404e1aef2501 +SOURCE_URL=https://api.github.com/repos/matrix-org/dendrite/tarball/v0.9.3 +SOURCE_SUM=9601b1cb916395199bbf588da78da7382ad2c22567855adb475441e3b2a8a08c SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/manifest.json b/manifest.json index 503d77e..37749af 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Matrix homeserver of second generation", "fr": "Serveur Matrix de seconde génération" }, - "version": "0.8.5~ynh1", + "version": "0.9.3~ynh1", "url": "https://matrix.org/", "upstream": { "license": "Apache-2.0", From fc779544022f26d7b6c8c0c6d58a60172597eb43 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Tue, 16 Aug 2022 06:29:38 +0000 Subject: [PATCH 06/31] Auto-update README --- README.md | 3 ++- README_fr.md | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e6ba6d8..1d12ac7 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,8 @@ Dendrite is a second-generation Matrix homeserver written in Go. It intends to p - Scalable: can run on multiple machines and eventually scale to massive homeserver deployments. -**Shipped version:** 0.8.5~ynh1 +**Shipped version:** 0.9.3~ynh1 + ## Disclaimers / important information :warning: The upstream app is still in beta. Tread carefully. diff --git a/README_fr.md b/README_fr.md index 70af96f..0273846 100644 --- a/README_fr.md +++ b/README_fr.md @@ -24,7 +24,8 @@ Dendrite is a second-generation Matrix homeserver written in Go. It intends to p - Scalable: can run on multiple machines and eventually scale to massive homeserver deployments. -**Version incluse :** 0.8.5~ynh1 +**Version incluse :** 0.9.3~ynh1 + ## Avertissements / informations importantes :warning: The upstream app is still in beta. Tread carefully. From ded79c8124c1abb4635401feb83dbc6cabe4c05d Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Tue, 16 Aug 2022 14:05:33 +0000 Subject: [PATCH 07/31] Auto-update README --- README.md | 1 + README_fr.md | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e6ba6d8..d2ecae7 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ Dendrite is a second-generation Matrix homeserver written in Go. It intends to p **Shipped version:** 0.8.5~ynh1 + ## Disclaimers / important information :warning: The upstream app is still in beta. Tread carefully. diff --git a/README_fr.md b/README_fr.md index 70af96f..e76fa33 100644 --- a/README_fr.md +++ b/README_fr.md @@ -24,7 +24,8 @@ Dendrite is a second-generation Matrix homeserver written in Go. It intends to p - Scalable: can run on multiple machines and eventually scale to massive homeserver deployments. -**Version incluse :** 0.8.5~ynh1 +**Version incluse :** 0.8.5~ynh1 + ## Avertissements / informations importantes :warning: The upstream app is still in beta. Tread carefully. From 69a6bbf53ccb9b95774ef1689529c3d56df65b42 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Sat, 20 Aug 2022 06:28:51 +0000 Subject: [PATCH 08/31] Upgrade to v0.9.4 --- conf/app.src | 4 ++-- manifest.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/app.src b/conf/app.src index 833ae85..f48afbe 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://api.github.com/repos/matrix-org/dendrite/tarball/v0.9.3 -SOURCE_SUM=9601b1cb916395199bbf588da78da7382ad2c22567855adb475441e3b2a8a08c +SOURCE_URL=https://api.github.com/repos/matrix-org/dendrite/tarball/v0.9.4 +SOURCE_SUM=0301fd8aa24b856ecc15feec5a31adca5c89f8040eaf9d5f4d844ad9abc4aa55 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/manifest.json b/manifest.json index 37749af..efffde0 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Matrix homeserver of second generation", "fr": "Serveur Matrix de seconde génération" }, - "version": "0.9.3~ynh1", + "version": "0.9.4~ynh1", "url": "https://matrix.org/", "upstream": { "license": "Apache-2.0", From 244755dcd2a926984b9e074e916c892c9437a81b Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Sat, 20 Aug 2022 06:28:57 +0000 Subject: [PATCH 09/31] Auto-update README --- README.md | 2 +- README_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1d12ac7..3ab949f 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Dendrite is a second-generation Matrix homeserver written in Go. It intends to p - Scalable: can run on multiple machines and eventually scale to massive homeserver deployments. -**Shipped version:** 0.9.3~ynh1 +**Shipped version:** 0.9.4~ynh1 ## Disclaimers / important information diff --git a/README_fr.md b/README_fr.md index 0273846..8571ac6 100644 --- a/README_fr.md +++ b/README_fr.md @@ -24,7 +24,7 @@ Dendrite is a second-generation Matrix homeserver written in Go. It intends to p - Scalable: can run on multiple machines and eventually scale to massive homeserver deployments. -**Version incluse :** 0.9.3~ynh1 +**Version incluse :** 0.9.4~ynh1 ## Avertissements / informations importantes From a2a4f6e56d46a577717bf46c480d3570f7a9e48a Mon Sep 17 00:00:00 2001 From: tituspijean Date: Wed, 24 Aug 2022 20:56:30 +0200 Subject: [PATCH 10/31] Setup CORS in nginx.conf --- conf/nginx.conf | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index a591ffb..4d3d417 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -5,8 +5,9 @@ location ~ ^/$ { } location /.well-known/matrix/server { - default_type application/json; + default_type application/json; return 200 '{ "m.server": "__DOMAIN__:443" }'; + more_set_headers "Access-Control-Allow-Origin: *"; } location /.well-known/matrix/client { @@ -20,4 +21,5 @@ location /_matrix { proxy_set_header Host $host; proxy_read_timeout 600; client_max_body_size 100M; + more_set_headers "Access-Control-Allow-Origin: *"; } From f5306855de01c26cd315300e7e66713782b38a23 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Wed, 24 Aug 2022 21:29:25 +0200 Subject: [PATCH 11/31] Fix SSO permissions --- scripts/install | 16 ++++++++++++++++ scripts/upgrade | 29 +++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/scripts/install b/scripts/install index 402f950..2a44872 100644 --- a/scripts/install +++ b/scripts/install @@ -185,6 +185,22 @@ ynh_add_systemd_config #================================================= # GENERIC FINALIZATION +#================================================= +# SETUP PERMISSIONS +#================================================= +ynh_script_progression --message="Configuring permissions..." --weight=1 + +ynh_permission_update --permission=main --show_tile=false --protected=true + +ynh_permission_create --permission=server_api --url=$domain/_matrix \ + --label="Server access for client apps." --show_tile=false --allowed=visitors \ + --auth_header=false --protected=true +if yunohost --output-as plain domain list | grep -q "^$server_name$"; then + ynh_permission_create --permission=server_client_infos --url=$server_name/.well-known/matrix \ + --label="Server info for clients. (well-known)" --show_tile=false --allowed=visitors \ + --auth_header=false --protected=true +fi + #================================================= # SETUP LOGROTATE #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 66c2985..a793ac1 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -161,6 +161,35 @@ ynh_add_systemd_config #================================================= # GENERIC FINALIZATION +#================================================= +# SETUP PERMISSIONS +#================================================= +ynh_script_progression --message="Configuring permissions..." --weight=1 + +ynh_permission_update --permission=main --show_tile=false --protected=true + +if ! ynh_permission_exists --permission=server_api; then + ynh_permission_create --permission=server_api --url=$domain/_matrix \ + --label="Server access for client apps." --show_tile=false --allowed=visitors \ + --auth_header=false --protected=true +else + ynh_permission_url --permission=server_api --url=$domain/_matrix --remove_url=$server_name/.well-known/matrix \ + --auth_header=false + ynh_permission_update --permission=server_api --label="Server access for client apps." --show_tile=false \ + --protected=true +fi + +if yunohost --output-as plain domain list | grep -q "^$server_name"'$' && ! ynh_permission_exists --permission=server_client_infos; then + ynh_permission_create --permission=server_client_infos --url=$server_name/.well-known/matrix \ + --label="Server info for clients. (well-known)" --show_tile=false --allowed=visitors \ + --auth_header=false --protected=true +elif yunohost --output-as plain domain list | grep -q "^$server_name"'$'; then + ynh_permission_url --permission=server_client_infos --url=$server_name/.well-known/matrix \ + --auth_header=false + ynh_permission_update --permission=server_client_infos --label="Server info for clients. (well-known)" --show_tile=false \ + --protected=true +fi + #================================================= # SETUP LOGROTATE #================================================= From 475caf74aa25c746811fe4d0cb8611bf035a0d67 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Wed, 24 Aug 2022 21:54:03 +0200 Subject: [PATCH 12/31] Go is removed after build No need to call it in the service environment --- conf/systemd.service | 1 - 1 file changed, 1 deletion(-) diff --git a/conf/systemd.service b/conf/systemd.service index 861b72d..5ad0e2d 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -7,7 +7,6 @@ Type=simple User=__APP__ Group=__APP__ WorkingDirectory=__FINALPATH__/ -Environment="__YNH_GO_LOAD_PATH__" ExecStart=__FINALPATH__/bin/dendrite-monolith-server --tls-cert=/etc/yunohost/certs/__DOMAIN__/crt.pem --tls-key=/etc/yunohost/certs/__DOMAIN__/key.pem --config=dendrite.yaml --http-bind-address=:__PORT__ --https-bind-address=:__TLS_PORT__ StandardOutput=append:/var/log/__APP__/__APP__.log StandardError=inherit From c0bfc39486ac0672d78e4637a45dcedd05995084 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Thu, 25 Aug 2022 00:03:07 +0200 Subject: [PATCH 13/31] v0.9.4 dropped goose and requires Go 1.18 --- scripts/_common.sh | 2 +- scripts/install | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index cd22c33..439b020 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -7,7 +7,7 @@ # dependencies used by the app pkg_dependencies="postgresql postgresql-contrib" -GO_VERSION="1.16" +GO_VERSION="1.18" #================================================= # PERSONAL HELPERS diff --git a/scripts/install b/scripts/install index 2a44872..4809a8e 100644 --- a/scripts/install +++ b/scripts/install @@ -137,7 +137,6 @@ pushd "$final_path/build" export GOPATH="$final_path/build/go" export GOCACHE="$final_path/build/.cache" CGO_ENABLED=1 go build -trimpath -v -o "$final_path/bin/" ./cmd/dendrite-monolith-server > /dev/null 2>&1 - CGO_ENABLED=1 go build -trimpath -v -o "$final_path/bin/" ./cmd/goose > /dev/null 2>&1 CGO_ENABLED=1 go build -trimpath -v -o "$final_path/bin/" ./cmd/create-account > /dev/null 2>&1 CGO_ENABLED=1 go build -trimpath -v -o "$final_path/bin/" ./cmd/generate-keys > /dev/null 2>&1 popd From 6823fa7c8ed0318bdce35e91b5201a8b701b85df Mon Sep 17 00:00:00 2001 From: tituspijean Date: Thu, 25 Aug 2022 00:30:58 +0200 Subject: [PATCH 14/31] Implement server display name --- manifest.json | 14 +++++++++++++- scripts/backup | 6 ++++++ scripts/install | 8 ++++++++ scripts/restore | 28 +++++++++------------------- scripts/upgrade | 14 ++++++++++++++ 5 files changed, 50 insertions(+), 20 deletions(-) diff --git a/manifest.json b/manifest.json index efffde0..0159b2f 100644 --- a/manifest.json +++ b/manifest.json @@ -38,7 +38,19 @@ }, { "name": "domain", - "type": "domain" + "type": "domain", + "ask": { + "en": "Select the domain onto which Dendrite will be exclusively installed. It may be different than the displayed server name.", + "fr": "Sélectionnez le domaine exclusivement dédié à Dendrite. Il peut être différent du nom d'affichage du serveur." + } + }, + { + "name": "server_name", + "type": "domain", + "ask": { + "en": "If your Dendrite domain selected above is a subdomain, you can choose a different display name for your Dendrite server to have your Matrix user-ids looking like @user:domain.org instead of @user:dendrite.domain.org", + "fr": "Si votre domaine pour Dendrite sélectionné précedemment est un sous-domaine, vous pouvez choisir un nom d'affichage pour votre serveur Dendrite afin que vos identifiants Matrix soient @utilisateur:domain.org plutôt que @utilisateur:dendrite.domain.org" + } }, { "name": "is_public", diff --git a/scripts/backup b/scripts/backup index 7db41e5..da7f321 100644 --- a/scripts/backup +++ b/scripts/backup @@ -29,6 +29,7 @@ app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get --app=$app --key=final_path) domain=$(ynh_app_setting_get --app=$app --key=domain) +server_name=$(ynh_app_setting_get --app=$app --key=server_name) db_name=$(ynh_app_setting_get --app=$app --key=db_name) #================================================= @@ -62,6 +63,11 @@ ynh_backup --src_path="/etc/logrotate.d/$app" ynh_backup --src_path="/etc/systemd/system/$app.service" +if yunohost --output-as plain domain list | grep -q "^$server_name$" +then + ynh_backup --src_path="/etc/nginx/conf.d/${server_name}.d/${app}_server_name.conf" +fi + #================================================= # BACKUP VARIOUS FILES #================================================= diff --git a/scripts/install b/scripts/install index 4809a8e..b06a6c1 100644 --- a/scripts/install +++ b/scripts/install @@ -26,6 +26,7 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url="/" +server_name=$YNH_APP_ARG_SERVER_NAME is_public=$YNH_APP_ARG_IS_PUBLIC app=$YNH_APP_INSTANCE_NAME @@ -48,6 +49,7 @@ ynh_script_progression --message="Storing installation settings..." --weight=1 ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url +ynh_app_setting_set --app=$app --key=server_name --value=$server_name #================================================= # STANDARD MODIFICATIONS @@ -122,6 +124,12 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config +# Create .well-known redirection for access by federation +if yunohost --output-as plain domain list | grep -q "^$server_name$" +then + ynh_add_config --template="server_name.conf" --destination="/etc/nginx/conf.d/${server_name}.d/${app}_server_name.conf" +fi + #================================================= # SPECIFIC SETUP #================================================= diff --git a/scripts/restore b/scripts/restore index 86c1883..fdee7bc 100644 --- a/scripts/restore +++ b/scripts/restore @@ -29,6 +29,7 @@ ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) +server_name=$(ynh_app_setting_get --app=$app --key=server_name) path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) port=$(ynh_app_setting_get --app=$app --key=port) @@ -47,11 +48,14 @@ test ! -d $final_path \ #================================================= # STANDARD RESTORATION STEPS #================================================= -# RESTORE THE NGINX CONFIGURATION +# RESTORE ALL CONFIG AND DATA #================================================= -ynh_script_progression --message="Restoring the NGINX web server configuration..." +ynh_script_progression --message="Restoring directory and configuration..." --weight=10 -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +mkdir -p /var/log/$app +chown -R $app:root /var/log/$app + +ynh_restore #================================================= # RECREATE THE DEDICATED USER @@ -64,9 +68,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path" --groups="ssl-ce #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." --weight=1 - -ynh_restore_file --origin_path="$final_path" +ynh_script_progression --message="Restoring the app main directory permissions..." --weight=1 chmod 750 "$final_path" chmod -R o-rwx "$final_path" @@ -95,27 +97,15 @@ ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name #================================================= # RESTORE SYSTEMD #================================================= -ynh_script_progression --message="Restoring the systemd configuration..." --weight=1 +ynh_script_progression --message="Enabling the systemd service..." --weight=1 -ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable $app.service --quiet -#================================================= -# RESTORE THE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the logrotate configuration..." - -mkdir -p /var/log/$app -chown -R $app:root /var/log/$app - -ynh_restore_file --origin_path="/etc/logrotate.d/$app" - #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -ynh_use_go yunohost service add $app --description="Dendrite Matrix homeserver" --log="/var/log/$app/Monolith.log" --needs_exposed_ports "$tls_port" #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index a793ac1..e498d0e 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -18,6 +18,7 @@ ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) +server_name=$(ynh_app_setting_get --app=$app --key=server_name) path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) port=$(ynh_app_setting_get --app=$app --key=port) @@ -66,6 +67,13 @@ if ! groups $app | grep -q 'ssl-cert'; then adduser $app ssl-cert fi + +# Define $server_name if not already defined +if [ -z $server_name ]; then + server_name=$domain + ynh_app_setting_set --app=$app --key=server_name --value=$domain +fi + #================================================= # CREATE DEDICATED USER #================================================= @@ -98,6 +106,12 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." - # Create a dedicated NGINX config ynh_add_nginx_config +# Create .well-known redirection for access by federation +if yunohost --output-as plain domain list | grep -q "^$server_name$" +then + ynh_add_config --template="server_name.conf" --destination="/etc/nginx/conf.d/${server_name}.d/${app}_server_name.conf" +fi + #================================================= # CREATE DEDICATED USER #================================================= From 3db21f6be3a2e5d0811b603f358d44e44487c023 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Thu, 25 Aug 2022 09:56:13 +0200 Subject: [PATCH 15/31] Implement server display name in check_process --- check_process | 1 + 1 file changed, 1 insertion(+) diff --git a/check_process b/check_process index 0292645..24216b5 100644 --- a/check_process +++ b/check_process @@ -1,6 +1,7 @@ ;; Test complet ; Manifest domain="domain.tld" + server_name="domain.tld" is_public=1 port="666" ; Checks From 9aa7173819a6e0c637547c29ed15f1b609209313 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Thu, 25 Aug 2022 10:01:21 +0200 Subject: [PATCH 16/31] Implement server display name with its NGINX conf --- conf/server_name.conf | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 conf/server_name.conf diff --git a/conf/server_name.conf b/conf/server_name.conf new file mode 100644 index 0000000..951536b --- /dev/null +++ b/conf/server_name.conf @@ -0,0 +1,16 @@ +location /.well-known/matrix/server { + return 200 '{"m.server": "__DOMAIN__:__TLS_PORT__"}'; + add_header Content-Type application/json; + add_header Access-Control-Allow-Origin '*'; +} + +location /.well-known/matrix/client { + return 200 '{ + "m.homeserver": { "base_url": "https://__DOMAIN__" }, +# "im.vector.riot.jitsi": {"preferredDomain": "__JITSI_SERVER__"}, +# "im.vector.riot.e2ee": {"default": __E2E_ENABLED_BY_DEFAULT__ } + }'; + add_header Content-Type application/json; + add_header Access-Control-Allow-Origin '*'; +} + From 8363dd1c985e36dee8d68869c4aaa26c7c7ddd75 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Thu, 25 Aug 2022 10:20:06 +0200 Subject: [PATCH 17/31] Break unused variables placeholders for Jitsi and E2E --- conf/server_name.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/server_name.conf b/conf/server_name.conf index 951536b..5f827c2 100644 --- a/conf/server_name.conf +++ b/conf/server_name.conf @@ -7,8 +7,8 @@ location /.well-known/matrix/server { location /.well-known/matrix/client { return 200 '{ "m.homeserver": { "base_url": "https://__DOMAIN__" }, -# "im.vector.riot.jitsi": {"preferredDomain": "__JITSI_SERVER__"}, -# "im.vector.riot.e2ee": {"default": __E2E_ENABLED_BY_DEFAULT__ } +# "im.vector.riot.jitsi": {"preferredDomain": "##JITSI_SERVER__"}, +# "im.vector.riot.e2ee": {"default": ##E2E_ENABLED_BY_DEFAULT__ } }'; add_header Content-Type application/json; add_header Access-Control-Allow-Origin '*'; From 142aec7005b963ef3d359bceb85e7f98aa0f5a59 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Thu, 25 Aug 2022 14:42:45 +0200 Subject: [PATCH 18/31] Disable multi instance CI test --- check_process | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_process b/check_process index 24216b5..53be51c 100644 --- a/check_process +++ b/check_process @@ -14,7 +14,7 @@ upgrade=1 # upgrade=1 from_commit=CommitHash backup_restore=1 - multi_instance=1 + multi_instance=0 port_already_use=0 change_url=1 ;;; Options From a18dba43d3d7c869d9da6c896bc34831d4f011c9 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Thu, 25 Aug 2022 14:45:23 +0200 Subject: [PATCH 19/31] No need to use Go in restore and remove scripts --- scripts/remove | 4 ---- scripts/restore | 1 - 2 files changed, 5 deletions(-) diff --git a/scripts/remove b/scripts/remove index 016801e..090c95c 100644 --- a/scripts/remove +++ b/scripts/remove @@ -7,7 +7,6 @@ #================================================= source _common.sh -source ynh_install_go source /usr/share/yunohost/helpers #================================================= @@ -61,9 +60,6 @@ ynh_script_progression --message="Removing the PostgreSQL database" --weight=2 # Remove a database if it exists, along with the associated user ynh_psql_remove_db --db_user=$db_user --db_name=$db_name -# Remove Go -ynh_remove_go - #================================================= # REMOVE APP MAIN DIR #================================================= diff --git a/scripts/restore b/scripts/restore index fdee7bc..604d010 100644 --- a/scripts/restore +++ b/scripts/restore @@ -8,7 +8,6 @@ # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh -source ../settings/scripts/ynh_install_go source /usr/share/yunohost/helpers #================================================= From dce305c26b644b4834a1aeefe92b24fe34e5e0e1 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Thu, 25 Aug 2022 14:46:08 +0200 Subject: [PATCH 20/31] Restore user before any chmod command --- scripts/restore | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/restore b/scripts/restore index 604d010..7875645 100644 --- a/scripts/restore +++ b/scripts/restore @@ -46,6 +46,14 @@ test ! -d $final_path \ #================================================= # STANDARD RESTORATION STEPS +#================================================= +# RECREATE THE DEDICATED USER +#================================================= +ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 + +# Create the dedicated user (if not existing) +ynh_system_user_create --username=$app --home_dir="$final_path" --groups="ssl-cert" + #================================================= # RESTORE ALL CONFIG AND DATA #================================================= @@ -56,14 +64,6 @@ chown -R $app:root /var/log/$app ynh_restore -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 - -# Create the dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir="$final_path" --groups="ssl-cert" - #================================================= # RESTORE THE APP MAIN DIR #================================================= From de9b8d119e1df7b77ac2134033d0c0197c04b85b Mon Sep 17 00:00:00 2001 From: tituspijean Date: Thu, 25 Aug 2022 14:53:48 +0200 Subject: [PATCH 21/31] Update ynh_install_go helper --- scripts/ynh_install_go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ynh_install_go b/scripts/ynh_install_go index 4fbf4e9..e3ad06a 100644 --- a/scripts/ynh_install_go +++ b/scripts/ynh_install_go @@ -214,7 +214,7 @@ ynh_remove_go () { ynh_cleanup_go () { # List required Go versions - local installed_apps=$(yunohost app list | grep -oP 'id: \K.*$') + local installed_apps=$(yunohost app list --output-as json --quiet | jq -r .apps[].id) local required_go_versions="" for installed_app in $installed_apps do From f9535c62fd3fcd24dfb5e5cf123b4e3a31995e71 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Thu, 25 Aug 2022 15:01:12 +0200 Subject: [PATCH 22/31] Fix change_url --- scripts/change_url | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 9fcbc2a..21718ca 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -32,6 +32,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) # Add settings here as needed by your application domain=$YNH_APP_NEW_DOMAIN +server_name=$(ynh_app_setting_get --app=$app --key=server_name) port=$(ynh_app_setting_get --app=$app --key=port) tls_port=$(ynh_app_setting_get --app=$app --key=tls_port) @@ -67,6 +68,7 @@ change_path=0 if [ "$old_path" != "$new_path" ] then change_path=1 + ynh_die --message "The new URL needs to be at the root of a domain." fi #================================================= @@ -114,9 +116,6 @@ fi #================================================= ynh_script_progression --message="Updating systemd configuration..." --weight=1 -# Load the Go environment path -ynh_use_go - # Create a dedicated systemd config ynh_add_systemd_config From e1e17dca83feb81eec1900c24c4da111a774cde1 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Thu, 25 Aug 2022 16:19:34 +0200 Subject: [PATCH 23/31] No goose building needed anymore --- scripts/upgrade | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index e498d0e..da2e862 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -137,7 +137,6 @@ then export GOPATH="$final_path/build/go" export GOCACHE="$final_path/build/.cache" CGO_ENABLED=1 go build -trimpath -v -o "$final_path/bin/" ./cmd/dendrite-monolith-server > /dev/null 2>&1 - CGO_ENABLED=1 go build -trimpath -v -o "$final_path/bin/" ./cmd/goose > /dev/null 2>&1 CGO_ENABLED=1 go build -trimpath -v -o "$final_path/bin/" ./cmd/create-account > /dev/null 2>&1 CGO_ENABLED=1 go build -trimpath -v -o "$final_path/bin/" ./cmd/generate-keys > /dev/null 2>&1 popd From 4ce4697bc543b0f82744e334dc18b05d5889f1d4 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Thu, 25 Aug 2022 16:38:40 +0200 Subject: [PATCH 24/31] Avoid duplicate NGINX locations --- conf/nginx.conf | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 4d3d417..fb22fe4 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -4,17 +4,6 @@ location ~ ^/$ { return 200 "This is where Dendrite is installed."; } -location /.well-known/matrix/server { - default_type application/json; - return 200 '{ "m.server": "__DOMAIN__:443" }'; - more_set_headers "Access-Control-Allow-Origin: *"; -} - -location /.well-known/matrix/client { - return 200 '{ "m.homeserver": { "base_url": "https://__DOMAIN__" } }'; - more_set_headers "Access-Control-Allow-Origin: *"; -} - location /_matrix { proxy_pass http://localhost:__PORT__; proxy_set_header X-Forwarded-For $remote_addr; From acddee959104e677dd0c7830a8122b8348008197 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Thu, 25 Aug 2022 16:59:36 +0200 Subject: [PATCH 25/31] Appease linter --- manifest.json | 6 +++--- scripts/upgrade | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/manifest.json b/manifest.json index 0159b2f..ed2d06b 100644 --- a/manifest.json +++ b/manifest.json @@ -22,7 +22,7 @@ "requirements": { "yunohost": ">= 4.3.0" }, - "multi_instance": true, + "multi_instance": false, "services": [ "nginx" ], @@ -39,7 +39,7 @@ { "name": "domain", "type": "domain", - "ask": { + "help": { "en": "Select the domain onto which Dendrite will be exclusively installed. It may be different than the displayed server name.", "fr": "Sélectionnez le domaine exclusivement dédié à Dendrite. Il peut être différent du nom d'affichage du serveur." } @@ -47,7 +47,7 @@ { "name": "server_name", "type": "domain", - "ask": { + "help": { "en": "If your Dendrite domain selected above is a subdomain, you can choose a different display name for your Dendrite server to have your Matrix user-ids looking like @user:domain.org instead of @user:dendrite.domain.org", "fr": "Si votre domaine pour Dendrite sélectionné précedemment est un sous-domaine, vous pouvez choisir un nom d'affichage pour votre serveur Dendrite afin que vos identifiants Matrix soient @utilisateur:domain.org plutôt que @utilisateur:dendrite.domain.org" } diff --git a/scripts/upgrade b/scripts/upgrade index da2e862..d5ab64b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -91,7 +91,7 @@ then ynh_script_progression --message="Upgrading source files..." --weight=3 # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$final_path/build" --keep="$final_path/dendrite.yaml" + ynh_setup_source --dest_dir="$final_path/build" --keep="dendrite.yaml" fi chmod 750 "$final_path" From 89195f00ebfd92717c221775e48b879833da31e6 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Thu, 25 Aug 2022 23:09:18 +0200 Subject: [PATCH 26/31] Implement user registration in config panel and fix service status detection --- conf/dendrite.yaml | 2 +- conf/systemd.service | 2 +- config_panel.toml | 12 ++++++++++ doc/DISCLAIMER.md | 6 ++++- manifest.json | 8 +++++-- scripts/change_url | 2 +- scripts/config | 55 ++++++++++++++++++++++++++++++++++++++++++++ scripts/install | 24 +++++++++++-------- scripts/restore | 2 +- scripts/upgrade | 26 +++++++++++---------- 10 files changed, 110 insertions(+), 29 deletions(-) create mode 100644 config_panel.toml create mode 100644 scripts/config diff --git a/conf/dendrite.yaml b/conf/dendrite.yaml index 06de6b0..df29574 100644 --- a/conf/dendrite.yaml +++ b/conf/dendrite.yaml @@ -152,7 +152,7 @@ client_api: # Prevents new users from being able to register on this homeserver, except when # using the registration shared secret below. - registration_disabled: __REGISTRATION__ + registration_disabled: __REGISTRATION_DISABLED__ # Prevents new guest accounts from being created. Guest registration is also # disabled implicitly by setting 'registration_disabled' above. diff --git a/conf/systemd.service b/conf/systemd.service index 5ad0e2d..e961638 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -7,7 +7,7 @@ Type=simple User=__APP__ Group=__APP__ WorkingDirectory=__FINALPATH__/ -ExecStart=__FINALPATH__/bin/dendrite-monolith-server --tls-cert=/etc/yunohost/certs/__DOMAIN__/crt.pem --tls-key=/etc/yunohost/certs/__DOMAIN__/key.pem --config=dendrite.yaml --http-bind-address=:__PORT__ --https-bind-address=:__TLS_PORT__ +ExecStart=__FINALPATH__/bin/dendrite-monolith-server --tls-cert=/etc/yunohost/certs/__DOMAIN__/crt.pem --tls-key=/etc/yunohost/certs/__DOMAIN__/key.pem --config=dendrite.yaml --http-bind-address=:__PORT__ --https-bind-address=:__TLS_PORT__ __REALLY_ENABLE_OPEN_REGISTRATION__ StandardOutput=append:/var/log/__APP__/__APP__.log StandardError=inherit diff --git a/config_panel.toml b/config_panel.toml new file mode 100644 index 0000000..5f28876 --- /dev/null +++ b/config_panel.toml @@ -0,0 +1,12 @@ +version = "1.0" + +[main] +name = "Dendrite configuration" + + [main.registration] + name = "User registration" + + [main.registration.registration] + ask = "Should registration be enabled?" + type = "boolean" + default = false diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md index 765a28c..0a6bfe8 100644 --- a/doc/DISCLAIMER.md +++ b/doc/DISCLAIMER.md @@ -1,5 +1,9 @@ :warning: The upstream app is still in beta. Tread carefully. +## Features + +* Registration can be opened in the app config panel. + ## Limitations -* Upstream app still in beta. +* Dendrite does not implement secondary user registration schemes yet, so YunoHost users cannot be integrated at the moment. diff --git a/manifest.json b/manifest.json index ed2d06b..d990735 100644 --- a/manifest.json +++ b/manifest.json @@ -53,9 +53,13 @@ } }, { - "name": "is_public", + "name": "registration", "type": "boolean", - "default": false + "default": false, + "help": { + "en": "Should the server allow any visitor to register as a user?", + "fr": "Le serveur doit-il permettre à quiconque de s'enregistrer comme utilisateur?" + } } ] } diff --git a/scripts/change_url b/scripts/change_url index 21718ca..4932b26 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -127,7 +127,7 @@ ynh_add_systemd_config ynh_script_progression --message="Starting a systemd service..." --weight=1 # Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --line_match="Starting external Monolith listener" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app --action="start" --line_match="Starting external Monolith listener" --log_path="/var/log/$app/Monolith.log" #================================================= # RELOAD NGINX diff --git a/scripts/config b/scripts/config new file mode 100644 index 0000000..2ea3ea5 --- /dev/null +++ b/scripts/config @@ -0,0 +1,55 @@ +#!/bin/bash + +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh +source /usr/share/yunohost/helpers + +ynh_abort_if_errors + +#================================================= +# RETRIEVE ARGUMENTS +#================================================= + +domain=$(ynh_app_setting_get --app=$app --key=domain) +server_name=$(ynh_app_setting_get --app=$app --key=server_name) +path_url=$(ynh_app_setting_get --app=$app --key=path) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +port=$(ynh_app_setting_get --app=$app --key=port) +tls_port=$(ynh_app_setting_get --app=$app --key=tls_port) +db_name=$(ynh_app_setting_get --app=$app --key=db_name) +db_user=$db_name +db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) +#registration is not loaded since it's set up by the config panel + +#================================================= +# GENERIC FINALIZATION +#================================================= + +ynh_app_config_apply() { + _ynh_app_config_apply + + if [ "${changed[registration]}" == "true" ] + then + if [ $registration -eq 1 ] + then + registration_disabled="false" + really_enable_open_registration="--really-enable-open-registration" + else + registration_disabled="true" + really_enable_open_registration="" + fi + + ynh_add_config --template="../conf/dendrite.yaml" --destination="$final_path/dendrite.yaml" + ynh_add_systemd_config + ynh_systemd_action --service_name=$app --action="restart" --line_match="Starting external Monolith listener" --log_path="/var/log/$app/$app.log" + ynh_app_setting_set --app=$app --key=registration --value=$registration + + fi +} + +ynh_app_config_run $1 diff --git a/scripts/install b/scripts/install index b06a6c1..289e6e5 100644 --- a/scripts/install +++ b/scripts/install @@ -27,10 +27,20 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url="/" server_name=$YNH_APP_ARG_SERVER_NAME -is_public=$YNH_APP_ARG_IS_PUBLIC +registration=$YNH_APP_ARG_REGISTRATION app=$YNH_APP_INSTANCE_NAME +# Allow or deny registration based on is_public +if [ $registration -eq 1 ] +then + registration_disabled="false" + really_enable_open_registration="--really-enable-open-registration" +else + registration_disabled="true" + really_enable_open_registration="" +fi + #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= @@ -50,6 +60,7 @@ ynh_script_progression --message="Storing installation settings..." --weight=1 ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=server_name --value=$server_name +ynh_app_setting_set --app=$app --key=registration --value=$registration #================================================= # STANDARD MODIFICATIONS @@ -169,13 +180,6 @@ chown -R $app:root "$final_path" #================================================= ynh_script_progression --message="Adding a configuration file..." -# Allow or deny registration based of is_public -registration=false -if [ $is_public -eq 1 ] -then - registration=true -fi - # Copy and modify the config file ynh_add_config --template="../conf/dendrite.yaml" --destination="$final_path/dendrite.yaml" @@ -197,7 +201,7 @@ ynh_add_systemd_config #================================================= ynh_script_progression --message="Configuring permissions..." --weight=1 -ynh_permission_update --permission=main --show_tile=false --protected=true +ynh_permission_update --permission=main --show_tile=false ynh_permission_create --permission=server_api --url=$domain/_matrix \ --label="Server access for client apps." --show_tile=false --allowed=visitors \ @@ -235,7 +239,7 @@ yunohost service add $app --description="Dendrite Matrix homeserver" --log="/var ynh_script_progression --message="Starting a systemd service..." --weight=1 # Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --line_match="Starting external Monolith listener" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app --action="start" --line_match="Starting external Monolith listener" --log_path="/var/log/$app/Monolith.log" #================================================= # RELOAD NGINX diff --git a/scripts/restore b/scripts/restore index 7875645..6bf8a10 100644 --- a/scripts/restore +++ b/scripts/restore @@ -112,7 +112,7 @@ yunohost service add $app --description="Dendrite Matrix homeserver" --log="/var #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" --line_match="Starting external Monolith listener" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app --action="start" --line_match="Starting external Monolith listener" --log_path="/var/log/$app/Monolith.log" #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index d5ab64b..8019612 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -26,6 +26,7 @@ tls_port=$(ynh_app_setting_get --app=$app --key=tls_port) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) +registration=$(ynh_app_setting_get --app=$app --key=registration) #================================================= # CHECK VERSION @@ -56,7 +57,7 @@ ynh_abort_if_errors #================================================= ynh_script_progression --message="Stopping a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="stop" --line_match="Stopped Dendrite Matrix homeserver" --log_path="systemd" +ynh_systemd_action --service_name=$app --action="stop" --line_match="Stopped external Monolith listener" --log_path="systemd" #================================================= # ENSURE DOWNWARD COMPATIBILITY @@ -67,13 +68,23 @@ if ! groups $app | grep -q 'ssl-cert'; then adduser $app ssl-cert fi - # Define $server_name if not already defined if [ -z $server_name ]; then server_name=$domain ynh_app_setting_set --app=$app --key=server_name --value=$domain fi +# Load up registration variables +if [[ $registration -eq 1 ]] +then + registration_disabled="false" + really_enable_open_registration="--really-enable-open-registration" +else + registration_disabled="true" + really_enable_open_registration="" + ynh_app_setting_set --app=$app --key=registration --value=0 +fi + #================================================= # CREATE DEDICATED USER #================================================= @@ -152,13 +163,6 @@ chown -R $app:root "$final_path" #================================================= ynh_script_progression --message="Updating a configuration file..." -if ynh_permission_has_user --permission=main --user=visitors -then - registration="true" -else - registration="false" -fi - ynh_add_config --template="../conf/dendrite.yaml" --destination="$final_path/dendrite.yaml" chmod 400 "$final_path/dendrite.yaml" @@ -179,8 +183,6 @@ ynh_add_systemd_config #================================================= ynh_script_progression --message="Configuring permissions..." --weight=1 -ynh_permission_update --permission=main --show_tile=false --protected=true - if ! ynh_permission_exists --permission=server_api; then ynh_permission_create --permission=server_api --url=$domain/_matrix \ --label="Server access for client apps." --show_tile=false --allowed=visitors \ @@ -226,7 +228,7 @@ yunohost service add $app --description="Dendrite Matrix homeserver" --log="/var #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" --line_match="Starting external Monolith listener" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app --action="start" --line_match="Starting external Monolith listener" --log_path="/var/log/$app/Monolith.log" #================================================= # RELOAD NGINX From 65a6684715104bbb9724c76deb5210de3555e9b2 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Thu, 25 Aug 2022 21:14:31 +0000 Subject: [PATCH 27/31] Auto-update README --- README.md | 6 +++++- README_fr.md | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3ab949f..ccee6e3 100644 --- a/README.md +++ b/README.md @@ -30,9 +30,13 @@ Dendrite is a second-generation Matrix homeserver written in Go. It intends to p :warning: The upstream app is still in beta. Tread carefully. +## Features + +* Registration can be opened in the app config panel. + ## Limitations -* Upstream app still in beta. +* Dendrite does not implement secondary user registration schemes yet, so YunoHost users cannot be integrated at the moment. ## Documentation and resources diff --git a/README_fr.md b/README_fr.md index 8571ac6..7c3f84c 100644 --- a/README_fr.md +++ b/README_fr.md @@ -30,9 +30,13 @@ Dendrite is a second-generation Matrix homeserver written in Go. It intends to p :warning: The upstream app is still in beta. Tread carefully. +## Features + +* Registration can be opened in the app config panel. + ## Limitations -* Upstream app still in beta. +* Dendrite does not implement secondary user registration schemes yet, so YunoHost users cannot be integrated at the moment. ## Documentations et ressources From 186267f480a59b7395f5fa19e0f3dcd52b074cb3 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Thu, 25 Aug 2022 21:16:09 +0000 Subject: [PATCH 28/31] Upgrade to v0.9.5 --- conf/app.src | 4 ++-- manifest.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/app.src b/conf/app.src index f48afbe..b5c448b 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://api.github.com/repos/matrix-org/dendrite/tarball/v0.9.4 -SOURCE_SUM=0301fd8aa24b856ecc15feec5a31adca5c89f8040eaf9d5f4d844ad9abc4aa55 +SOURCE_URL=https://api.github.com/repos/matrix-org/dendrite/tarball/v0.9.5 +SOURCE_SUM=222c1dec7ea18f7f0d86651112933abb25738ef0c9493757569d5dc4301b0813 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/manifest.json b/manifest.json index d990735..74b1c2c 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Matrix homeserver of second generation", "fr": "Serveur Matrix de seconde génération" }, - "version": "0.9.4~ynh1", + "version": "0.9.5~ynh1", "url": "https://matrix.org/", "upstream": { "license": "Apache-2.0", From 2afa6f2da1b97b23b479936ade00246892776442 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Thu, 25 Aug 2022 21:16:12 +0000 Subject: [PATCH 29/31] Auto-update README --- README.md | 2 +- README_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ccee6e3..c059069 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Dendrite is a second-generation Matrix homeserver written in Go. It intends to p - Scalable: can run on multiple machines and eventually scale to massive homeserver deployments. -**Shipped version:** 0.9.4~ynh1 +**Shipped version:** 0.9.5~ynh1 ## Disclaimers / important information diff --git a/README_fr.md b/README_fr.md index 7c3f84c..976311a 100644 --- a/README_fr.md +++ b/README_fr.md @@ -24,7 +24,7 @@ Dendrite is a second-generation Matrix homeserver written in Go. It intends to p - Scalable: can run on multiple machines and eventually scale to massive homeserver deployments. -**Version incluse :** 0.9.4~ynh1 +**Version incluse :** 0.9.5~ynh1 ## Avertissements / informations importantes From 61701a90d600dd7041569357d0c521fcdbed0dc3 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Thu, 25 Aug 2022 23:45:18 +0200 Subject: [PATCH 30/31] Appease linter, again --- manifest.json | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/manifest.json b/manifest.json index 74b1c2c..50dc6cc 100644 --- a/manifest.json +++ b/manifest.json @@ -40,23 +40,27 @@ "name": "domain", "type": "domain", "help": { - "en": "Select the domain onto which Dendrite will be exclusively installed. It may be different than the displayed server name.", - "fr": "Sélectionnez le domaine exclusivement dédié à Dendrite. Il peut être différent du nom d'affichage du serveur." + "en": "Select the domain onto which Dendrite will be exclusively installed, e.g. dendrite.domain.tld", + "fr": "Sélectionnez le domaine exclusivement dédié à Dendrite, par exemple dendrite.domain.tld" } }, { "name": "server_name", "type": "domain", + "ask": { + "en": "Select the display name for your Dendrite server", + "fr": "Sélectionnez le nom d'affichage pour votre serveur Dendrite" + }, "help": { - "en": "If your Dendrite domain selected above is a subdomain, you can choose a different display name for your Dendrite server to have your Matrix user-ids looking like @user:domain.org instead of @user:dendrite.domain.org", - "fr": "Si votre domaine pour Dendrite sélectionné précedemment est un sous-domaine, vous pouvez choisir un nom d'affichage pour votre serveur Dendrite afin que vos identifiants Matrix soient @utilisateur:domain.org plutôt que @utilisateur:dendrite.domain.org" + "en": "If you choose domain.tld, your Matrix user-ids will be looking like @user:domain.tld instead of @user:dendrite.domain.tld", + "fr": "Si vous choisissez domain.tld, vos identifiants Matrix ressembleront à @utilisateur:domain.tld plutôt que @utilisateur:dendrite.domain.tld" } }, { "name": "registration", "type": "boolean", "default": false, - "help": { + "ask": { "en": "Should the server allow any visitor to register as a user?", "fr": "Le serveur doit-il permettre à quiconque de s'enregistrer comme utilisateur?" } From 86c734752576cc678abdf7849c0a5992f44e6436 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Fri, 26 Aug 2022 09:26:26 +0200 Subject: [PATCH 31/31] Load registration variables in change_url --- scripts/change_url | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/change_url b/scripts/change_url index 4932b26..8e07094 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -35,6 +35,17 @@ domain=$YNH_APP_NEW_DOMAIN server_name=$(ynh_app_setting_get --app=$app --key=server_name) port=$(ynh_app_setting_get --app=$app --key=port) tls_port=$(ynh_app_setting_get --app=$app --key=tls_port) +registration=$(ynh_app_setting_get --app=$app --key=registration) + +# Load up registration variables +if [[ $registration -eq 1 ]] +then + registration_disabled="false" + really_enable_open_registration="--really-enable-open-registration" +else + registration_disabled="true" + really_enable_open_registration="" +fi #================================================= # BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP