From dc9e7cef8b07f2d1f0383015b4ebc14e2f4f51f0 Mon Sep 17 00:00:00 2001 From: nouts Date: Sat, 4 May 2019 13:49:19 +0200 Subject: [PATCH 01/12] first working install --- conf/homeserver.yaml | 2 +- manifest.json | 9 +++++++++ scripts/install | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/conf/homeserver.yaml b/conf/homeserver.yaml index c866bf7..c6224d3 100644 --- a/conf/homeserver.yaml +++ b/conf/homeserver.yaml @@ -50,7 +50,7 @@ tls_fingerprints: [] # This is used by remote servers to connect to this server, # e.g. matrix.org, localhost:8080, etc. # This is also the last part of your UserID. -server_name: "__DOMAIN__" +server_name: "__SERVER_NAME__" # When running as a daemon, the file to store the pid in pid_file: "/var/run/matrix-__APP__.pid" diff --git a/manifest.json b/manifest.json index 9ba3cb1..1530096 100644 --- a/manifest.json +++ b/manifest.json @@ -29,6 +29,15 @@ "en": "Choose a domain for Synapse", "fr": "Choisissez un domaine pour Synapse" }, + "example": "matrix.domain.org" + }, + { + "name": "server_name", + "type": "string", + "ask": { + "en": "Choose a name for Matrix accounts", + "fr": "Choisissez un nom pour les comptes Matrix" + }, "example": "domain.org" }, { diff --git a/scripts/install b/scripts/install index 1cf481b..8d20035 100644 --- a/scripts/install +++ b/scripts/install @@ -32,6 +32,7 @@ report_stats="False" #================================================= domain=$YNH_APP_ARG_DOMAIN +server_name=$YNH_APP_ARG_SERVER_NAME is_public=$YNH_APP_ARG_IS_PUBLIC path_url="/_matrix" final_path="/opt/yunohost/matrix-$app" @@ -228,6 +229,7 @@ cp ../conf/log.yaml /etc/matrix-$app/log.yaml ynh_replace_string __APP__ $app "$homeserver_config_path" ynh_replace_string __DOMAIN__ $domain "$homeserver_config_path" +ynh_replace_string __SERVER_NAME__ $server_name "$homeserver_config_path" ynh_replace_string __SYNAPSE_DB_USER__ $synapse_db_user "$homeserver_config_path" ynh_replace_string __SYNAPSE_DB_PWD__ $synapse_db_pwd "$homeserver_config_path" ynh_replace_string __PORT__ $port "$homeserver_config_path" From ca6619eb71a8b8591605e602b6a39dcdce77078f Mon Sep 17 00:00:00 2001 From: Nouts Date: Sat, 11 May 2019 14:45:00 +0200 Subject: [PATCH 02/12] several improvements from feedback --- README.md | 4 ++-- manifest.json | 6 +++--- scripts/config | 2 ++ scripts/install | 3 ++- scripts/upgrade | 3 ++- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index b54d1ba..c5068f9 100644 --- a/README.md +++ b/README.md @@ -41,11 +41,11 @@ If your server name is identical to the domain on which synapse is installed, an If not, you may need to put the following line in the dns configuration: ``` -_matrix._tcp. IN SRV 10 0 +_matrix._tcp. IN SRV 10 0 ``` for example ``` -_matrix._tcp.example.com. 3600 IN SRV 10 0 SYNAPSE_PORT example.com. +_matrix._tcp.example.com. 3600 IN SRV 10 0 SYNAPSE_PORT synapse.example.com. ``` You need to replace SYNAPSE_PORT by the real port. This port can be obtained by the command: `yunohost app setting SYNAPSE_INSTANCE_NAME synapse_tls_port` diff --git a/manifest.json b/manifest.json index 1530096..7e032f5 100644 --- a/manifest.json +++ b/manifest.json @@ -29,14 +29,14 @@ "en": "Choose a domain for Synapse", "fr": "Choisissez un domaine pour Synapse" }, - "example": "matrix.domain.org" + "example": "synapse.domain.org" }, { "name": "server_name", "type": "string", "ask": { - "en": "Choose a name for Matrix accounts", - "fr": "Choisissez un nom pour les comptes Matrix" + "en": "If your synapse domain is a subdomain, you can choose a name for your Synapse server to have your matrix user-ids looking like @user:domain.org instead of @user:synapse.domain.org", + "fr": "Si votre domaine pour synapse est un sous-domaine, vous pouvez choisir un nom pour votre serveur Synapse afin que vos identifiants matrix soient @utilisateur:domain.org plutôt que @utilisateur:synapse.domain.org" }, "example": "domain.org" }, diff --git a/scripts/config b/scripts/config index ea60910..820793b 100644 --- a/scripts/config +++ b/scripts/config @@ -69,6 +69,7 @@ apply_config() { fi domain=$(ynh_app_setting_get $app special_domain) + server_name=$(ynh_app_setting_get $app server_name) synapse_db_pwd=$(ynh_app_setting_get $app synapse_db_pwd) is_public=$(ynh_app_setting_get $app is_public) port=$(ynh_app_setting_get $app synapse_port) @@ -96,6 +97,7 @@ apply_config() { ynh_replace_string __APP__ $app "$homeserver_config_path" ynh_replace_string __DOMAIN__ $domain "$homeserver_config_path" + ynh_replace_string __SERVER_NAME__ $server_name "$homeserver_config_path" ynh_replace_string __SYNAPSE_DB_USER__ $synapse_db_user "$homeserver_config_path" ynh_replace_string __SYNAPSE_DB_PWD__ $synapse_db_pwd "$homeserver_config_path" ynh_replace_string __PORT__ $port "$homeserver_config_path" diff --git a/scripts/install b/scripts/install index 8d20035..f96a4fa 100644 --- a/scripts/install +++ b/scripts/install @@ -57,6 +57,7 @@ test ! -e "$final_path" || ynh_die "This path already contains a folder" # This hack solve the issue : https://github.com/YunoHost-Apps/synapse_ynh/issues/14 ynh_app_setting_set $app special_domain $domain ynh_app_setting_set $app special_path $path_url +ynh_app_setting_set $app server_name $server_name ynh_app_setting_set $app final_path $final_path ynh_app_setting_set $app synapse_version $upstream_version ynh_app_setting_set $app is_public $is_public @@ -179,7 +180,7 @@ PS1=${PS1:-} source $final_path/bin/activate # Generate config -python -m synapse.app.homeserver --keys-directory /etc/matrix-$app/ --generate-config --generate-keys --server-name $domain --report-stats=no -c homeserver.yml +python -m synapse.app.homeserver --keys-directory /etc/matrix-$app/ --generate-config --generate-keys --server-name $server_name --report-stats=no -c homeserver.yml # This function was defined when we called "source $final_path/bin/activate". With this function we undo what "$final_path/bin/activate" does deactivate diff --git a/scripts/upgrade b/scripts/upgrade index fd9e4f4..6ac210b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -31,6 +31,7 @@ upstream_version=$(ynh_app_upstream_version) #================================================= domain=$(ynh_app_setting_get $app special_domain) +server_name=$(ynh_app_setting_get $app server_name) path_url=$(ynh_app_setting_get $app special_path) final_path=$(ynh_app_setting_get $app final_path) synapse_old_version=$(ynh_app_setting_get $app synapse_version) @@ -126,7 +127,7 @@ then source $final_path/bin/activate # Generate config and keys - python -m synapse.app.homeserver --keys-directory /etc/matrix-$app/ --generate-config --generate-keys --server-name $domain --report-stats=no -c homeserver.yml + python -m synapse.app.homeserver --keys-directory /etc/matrix-$app/ --generate-config --generate-keys --server-name $server_name --report-stats=no -c homeserver.yml # This function was defined when we called "source $final_path/bin/activate". With this function we undo what "$final_path/bin/activate" does deactivate From 13d9025a110e237344c0e08341071647926d0fb6 Mon Sep 17 00:00:00 2001 From: Nouts Date: Sat, 11 May 2019 15:01:17 +0200 Subject: [PATCH 03/12] rename signing.key by server_name --- scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index f96a4fa..89a64c8 100644 --- a/scripts/install +++ b/scripts/install @@ -332,7 +332,7 @@ chown $synapse_user:root -R /var/lib/matrix-$app chown $synapse_user:root -R /var/log/matrix-$app chown $synapse_user:root -R /etc/matrix-$app chmod u=rwX,g=rX,o= -R /etc/matrix-$app -chmod 600 /etc/matrix-$app/$domain.signing.key +chmod 600 /etc/matrix-$app/$server_name.signing.key setfacl -R -m user:turnserver:rX /etc/matrix-$app setfacl -R -m user:turnserver:rwX /var/log/matrix-$app diff --git a/scripts/restore b/scripts/restore index 8b940dc..0144f83 100644 --- a/scripts/restore +++ b/scripts/restore @@ -192,7 +192,7 @@ chown $synapse_user:root -R /var/lib/matrix-$app chown $synapse_user:root -R /var/log/matrix-$app chown $synapse_user:root -R /etc/matrix-$app chmod u=rwX,g=rX,o= -R /etc/matrix-$app -chmod 600 /etc/matrix-$app/$domain.signing.key +chmod 600 /etc/matrix-$app/$server_name.signing.key setfacl -R -m user:turnserver:rX /etc/matrix-$app setfacl -R -m user:turnserver:rwX /var/log/matrix-$app diff --git a/scripts/upgrade b/scripts/upgrade index 6ac210b..0d9e5e2 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -331,7 +331,7 @@ chown $synapse_user:root -R /var/lib/matrix-$app chown $synapse_user:root -R /var/log/matrix-$app chown $synapse_user:root -R /etc/matrix-$app chmod u=rwX,g=rX,o= -R /etc/matrix-$app -chmod 600 /etc/matrix-$app/$domain.signing.key +chmod 600 /etc/matrix-$app/$server_name.signing.key setfacl -R -m user:turnserver:rX /etc/matrix-$app setfacl -R -m user:turnserver:rwX /var/log/matrix-$app From 4cea4d86abecb6eebfb8bf2da7ec71780ed8546e Mon Sep 17 00:00:00 2001 From: Nouts Date: Wed, 31 Jul 2019 19:32:38 +0200 Subject: [PATCH 04/12] add server_name, try fix upgrade/restore --- scripts/restore | 1 + scripts/upgrade | 1 + 2 files changed, 2 insertions(+) diff --git a/scripts/restore b/scripts/restore index 0144f83..1ffef46 100644 --- a/scripts/restore +++ b/scripts/restore @@ -106,6 +106,7 @@ cp ../settings/conf/turnserver.conf "$coturn_config_path" ynh_replace_string __APP__ $app "$coturn_config_path" ynh_replace_string __TURNPWD__ $turnserver_pwd "$coturn_config_path" ynh_replace_string __DOMAIN__ $domain "$coturn_config_path" + ynh_replace_string __SERVER_NAME__ $server_name "$homeserver_config_path" ynh_replace_string __TLS_PORT__ $turnserver_tls_port "$coturn_config_path" ynh_replace_string __TLS_ALT_PORT__ $turnserver_alt_tls_port "$coturn_config_path" ynh_replace_string __CLI_PORT__ $cli_port "$coturn_config_path" diff --git a/scripts/upgrade b/scripts/upgrade index 0d9e5e2..182d2cb 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -158,6 +158,7 @@ cp ../conf/log.yaml /etc/matrix-$app/log.yaml ynh_replace_string __APP__ $app "$homeserver_config_path" ynh_replace_string __DOMAIN__ $domain "$homeserver_config_path" +ynh_replace_string __SERVER_NAME__ $server_name "$homeserver_config_path" ynh_replace_string __SYNAPSE_DB_USER__ $synapse_db_user "$homeserver_config_path" ynh_replace_string __SYNAPSE_DB_PWD__ $synapse_db_pwd "$homeserver_config_path" ynh_replace_string __PORT__ $port "$homeserver_config_path" From bb47e1f7d768b9979c305dea593ee44d4c79598b Mon Sep 17 00:00:00 2001 From: Nouts Date: Wed, 31 Jul 2019 20:21:41 +0200 Subject: [PATCH 05/12] fix typo --- scripts/restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/restore b/scripts/restore index 1ffef46..59c82a8 100644 --- a/scripts/restore +++ b/scripts/restore @@ -106,7 +106,7 @@ cp ../settings/conf/turnserver.conf "$coturn_config_path" ynh_replace_string __APP__ $app "$coturn_config_path" ynh_replace_string __TURNPWD__ $turnserver_pwd "$coturn_config_path" ynh_replace_string __DOMAIN__ $domain "$coturn_config_path" - ynh_replace_string __SERVER_NAME__ $server_name "$homeserver_config_path" +ynh_replace_string __SERVER_NAME__ $server_name "$homeserver_config_path" ynh_replace_string __TLS_PORT__ $turnserver_tls_port "$coturn_config_path" ynh_replace_string __TLS_ALT_PORT__ $turnserver_alt_tls_port "$coturn_config_path" ynh_replace_string __CLI_PORT__ $cli_port "$coturn_config_path" From dd552c8a141ce02feccd3aae09553a65d502c0dd Mon Sep 17 00:00:00 2001 From: Nouts Date: Wed, 31 Jul 2019 20:34:09 +0200 Subject: [PATCH 06/12] remove server_name from restore as not needed --- scripts/restore | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/restore b/scripts/restore index 59c82a8..0144f83 100644 --- a/scripts/restore +++ b/scripts/restore @@ -106,7 +106,6 @@ cp ../settings/conf/turnserver.conf "$coturn_config_path" ynh_replace_string __APP__ $app "$coturn_config_path" ynh_replace_string __TURNPWD__ $turnserver_pwd "$coturn_config_path" ynh_replace_string __DOMAIN__ $domain "$coturn_config_path" -ynh_replace_string __SERVER_NAME__ $server_name "$homeserver_config_path" ynh_replace_string __TLS_PORT__ $turnserver_tls_port "$coturn_config_path" ynh_replace_string __TLS_ALT_PORT__ $turnserver_alt_tls_port "$coturn_config_path" ynh_replace_string __CLI_PORT__ $cli_port "$coturn_config_path" From f3abdeedfabbd092a503b62d1d19895b821c816f Mon Sep 17 00:00:00 2001 From: Nouts Date: Wed, 31 Jul 2019 20:56:37 +0200 Subject: [PATCH 07/12] FIX add server_name variable --- scripts/restore | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/restore b/scripts/restore index 01fab88..2d835ea 100644 --- a/scripts/restore +++ b/scripts/restore @@ -31,6 +31,7 @@ upstream_version=$(ynh_app_upstream_version) #================================================= domain=$(ynh_app_setting_get $app special_domain) +server_name=$(ynh_app_setting_get $app server_name) path_url=$(ynh_app_setting_get $app special_path) final_path=$(ynh_app_setting_get $app final_path) synapse_db_pwd=$(ynh_app_setting_get $app synapse_db_pwd) From 0f7b1e3dff7a47a649c22d5a7d1ac24972602ae9 Mon Sep 17 00:00:00 2001 From: gnouts Date: Thu, 1 Aug 2019 17:02:48 +0200 Subject: [PATCH 08/12] add retrocompatibility --- scripts/upgrade | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index cc28cec..2e07065 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -32,6 +32,10 @@ upstream_version=$(ynh_app_upstream_version) domain=$(ynh_app_setting_get $app special_domain) server_name=$(ynh_app_setting_get $app server_name) +if [ -z $server_name ]; then # for retro compatibility + server_name=$domain + ynh_app_setting_set $app server_name $domain +fi path_url=$(ynh_app_setting_get $app special_path) final_path=$(ynh_app_setting_get $app final_path) synapse_old_version=$(ynh_app_setting_get $app synapse_version) From 9a0a03f2f809138d1d59b777efdc514b9a5771b2 Mon Sep 17 00:00:00 2001 From: Nouts Date: Sat, 24 Aug 2019 15:38:14 +0200 Subject: [PATCH 09/12] set default domain name --- manifest.json | 3 ++- scripts/install | 6 +++++- scripts/upgrade | 8 ++++---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/manifest.json b/manifest.json index f88c51f..ce1f164 100644 --- a/manifest.json +++ b/manifest.json @@ -38,7 +38,8 @@ "en": "If your synapse domain is a subdomain, you can choose a name for your Synapse server to have your matrix user-ids looking like @user:domain.org instead of @user:synapse.domain.org", "fr": "Si votre domaine pour synapse est un sous-domaine, vous pouvez choisir un nom pour votre serveur Synapse afin que vos identifiants matrix soient @utilisateur:domain.org plutôt que @utilisateur:synapse.domain.org" }, - "example": "domain.org" + "example": "domain.org", + "default": "Same than the domain" }, { "name": "is_public", diff --git a/scripts/install b/scripts/install index ea600a0..1b9f447 100644 --- a/scripts/install +++ b/scripts/install @@ -32,7 +32,11 @@ report_stats="False" #================================================= domain=$YNH_APP_ARG_DOMAIN -server_name=$YNH_APP_ARG_SERVER_NAME +if [ $server_name == "Same than the domain" ]; then + server_name=$domain +else + server_name=$YNH_APP_ARG_SERVER_NAME +fi is_public=$YNH_APP_ARG_IS_PUBLIC path_url="/_matrix" final_path="/opt/yunohost/matrix-$app" diff --git a/scripts/upgrade b/scripts/upgrade index 2e07065..9a4a421 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -32,10 +32,6 @@ upstream_version=$(ynh_app_upstream_version) domain=$(ynh_app_setting_get $app special_domain) server_name=$(ynh_app_setting_get $app server_name) -if [ -z $server_name ]; then # for retro compatibility - server_name=$domain - ynh_app_setting_set $app server_name $domain -fi path_url=$(ynh_app_setting_get $app special_path) final_path=$(ynh_app_setting_get $app final_path) synapse_old_version=$(ynh_app_setting_get $app synapse_version) @@ -61,6 +57,10 @@ then ynh_die "Update from this synapse version is not available. You need to remove this package and reinstall the new package version." fi +if [ -z $server_name ]; then + server_name=$domain + ynh_app_setting_set $app server_name $domain +fi #================================================= # BACKUP BEFORE UPGRADE #================================================= From b7b465e245db4751b57640142d866adf920d39ea Mon Sep 17 00:00:00 2001 From: Nouts Date: Sat, 24 Aug 2019 15:49:44 +0200 Subject: [PATCH 10/12] fix wrong if set variable --- scripts/install | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index 1b9f447..18f64a2 100644 --- a/scripts/install +++ b/scripts/install @@ -32,10 +32,9 @@ report_stats="False" #================================================= domain=$YNH_APP_ARG_DOMAIN +server_name=$YNH_APP_ARG_SERVER_NAME if [ $server_name == "Same than the domain" ]; then - server_name=$domain -else - server_name=$YNH_APP_ARG_SERVER_NAME + server_name=$domain fi is_public=$YNH_APP_ARG_IS_PUBLIC path_url="/_matrix" From 0dd1b0a09c672f62b92b38582584073daa8aefe4 Mon Sep 17 00:00:00 2001 From: Nouts Date: Sat, 24 Aug 2019 15:59:03 +0200 Subject: [PATCH 11/12] add variable for default domain --- scripts/install | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 18f64a2..b2ce07b 100644 --- a/scripts/install +++ b/scripts/install @@ -26,6 +26,7 @@ synapse_db_name="matrix_$app" synapse_db_user="matrix_$app" upstream_version=$(ynh_app_upstream_version) report_stats="False" +default_domain_value="Same than the domain" #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST @@ -33,7 +34,7 @@ report_stats="False" domain=$YNH_APP_ARG_DOMAIN server_name=$YNH_APP_ARG_SERVER_NAME -if [ $server_name == "Same than the domain" ]; then +if [[ "$server_name" == "$default_domain_value" ]]; then server_name=$domain fi is_public=$YNH_APP_ARG_IS_PUBLIC From 3b96760518b9f828c7f5b93d883630c670d44f80 Mon Sep 17 00:00:00 2001 From: nouts Date: Sun, 27 Oct 2019 15:48:34 +0100 Subject: [PATCH 12/12] Update README.md Co-Authored-By: Josue-T --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0aea322..87d7150 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ If your server name is identical to the domain on which synapse is installed, an If not, you may need to put the following line in the dns configuration: ``` -_matrix._tcp. IN SRV 10 0 +_matrix._tcp. IN SRV 10 0 ``` for example ```