From b2f70fdafac8e1d9b6cf6b3f6ef1f4c1da06978e Mon Sep 17 00:00:00 2001 From: Gredin67 Date: Mon, 31 Jul 2023 13:09:53 +0200 Subject: [PATCH 01/15] expose more settings in config_panel.toml --- config_panel.toml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/config_panel.toml b/config_panel.toml index 5f28876..4fe0466 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -9,4 +9,40 @@ name = "Dendrite configuration" [main.registration.registration] ask = "Should registration be enabled?" type = "boolean" + yes = true + no = false + help = "Allows registration of standard accounts. If your server is federated, reCAPTCHA verification should be activated to avoid spamming the whole Matrix network." default = false + + [main.registration.disable_federation] + ask = "Disable Federation." + type = "boolean" + yes = true + no = false + help = "Do not communicate with other homeservers of the Matrix Federation." + bind = ":/opt/yunohost/__APP__/dendrite.yaml" + default = true + + [main.registration.guests_disabled] + ask = "Disable guests registration." + type = "boolean" + yes = true + no = false + help = "Guest registration is also disabled implicitly if registration is disabled." + bind = ":/opt/yunohost/__APP__/dendrite.yaml" + default = true + + [main.registration.registration_shared_secret] + ask = "Shared Secret for Registration." + type = "string" + help = "Allows registration of standard or admin accounts, even if Registration disabled. See instructions https://matrix-org.github.io/synapse/latest/admin_api/register_api.html" + bind = ":/opt/yunohost/__APP__/dendrite.yaml" + + [main.registration.enable_registration_captcha] + ask = "Disable Federation." + type = "boolean" + yes = true + no = false + help = "ReCaptcha API should be configured. See instructions https://matrix-org.github.io/dendrite/administration/registration#recaptcha-verification" + bind = ":/opt/yunohost/__APP__/dendrite.yaml" + default = true From 0230a72b19ff1129ca4e626cebaa6d423a92a688 Mon Sep 17 00:00:00 2001 From: Gredin67 Date: Mon, 31 Jul 2023 13:52:24 +0200 Subject: [PATCH 02/15] add_systemd_config --- scripts/config | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/scripts/config b/scripts/config index cc18266..c56dc29 100644 --- a/scripts/config +++ b/scripts/config @@ -9,30 +9,29 @@ source _common.sh source /usr/share/yunohost/helpers +# Stop script if errors +ynh_abort_if_errors +final_path=$(ynh_app_setting_get --app=$app --key=final_path) + +get_registration_disabled() { + registration_disabled=$(ynh_app_setting_get --app $app --key registration_disabled) + echo "${registration_disabled}" +} + +set__registration_disabled() { + if [ $registration_disabled ] + then + really_enable_open_registration="" + else + really_enable_open_registration="--really-enable-open-registration" + fi + + ynh_write_var_in_file --file=$final_path/dendrite.yaml --key=registration_disabled --value="${registration_disabled}" + ynh_add_systemd_config + ynh_app_setting_set --app=$app --key=registration_disabled --value=$registration_disabled +} #================================================= # 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="$install_dir/dendrite.yaml" - ynh_add_systemd_config - ynh_systemd_action --service_name=$app --action="restart" --line_match="Starting external listener" --log_path="systemd" - ynh_app_setting_set --app=$app --key=registration --value=$registration - - fi -} - ynh_app_config_run $1 From 2f44c0c38fa896d9283eae72c5befd48bb07e7ad Mon Sep 17 00:00:00 2001 From: Gredin67 Date: Mon, 31 Jul 2023 14:38:36 +0200 Subject: [PATCH 03/15] handle init and upgrade --- config_panel.toml | 14 ++++++------ scripts/config | 3 +-- scripts/install | 15 ++++++++++++- scripts/upgrade | 55 ++++++++++++++++++++++++++++++++++++++++++----- 4 files changed, 72 insertions(+), 15 deletions(-) diff --git a/config_panel.toml b/config_panel.toml index 4fe0466..a05a1e8 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -6,13 +6,13 @@ name = "Dendrite configuration" [main.registration] name = "User registration" - [main.registration.registration] - ask = "Should registration be enabled?" + [main.registration.registration_disabled] + ask = "Should registration be disabled?" type = "boolean" yes = true no = false - help = "Allows registration of standard accounts. If your server is federated, reCAPTCHA verification should be activated to avoid spamming the whole Matrix network." - default = false + help = "Disallows registration of standard accounts. If your server is federated, reCAPTCHA verification should be activated to avoid spamming the whole Matrix network." + default = true [main.registration.disable_federation] ask = "Disable Federation." @@ -21,7 +21,7 @@ name = "Dendrite configuration" no = false help = "Do not communicate with other homeservers of the Matrix Federation." bind = ":/opt/yunohost/__APP__/dendrite.yaml" - default = true + default = false [main.registration.guests_disabled] ask = "Disable guests registration." @@ -39,10 +39,10 @@ name = "Dendrite configuration" bind = ":/opt/yunohost/__APP__/dendrite.yaml" [main.registration.enable_registration_captcha] - ask = "Disable Federation." + ask = "Enable CAPTCHA for registration." type = "boolean" yes = true no = false - help = "ReCaptcha API should be configured. See instructions https://matrix-org.github.io/dendrite/administration/registration#recaptcha-verification" + help = "ReCAPTCHA API should be configured. See instructions https://matrix-org.github.io/dendrite/administration/registration#recaptcha-verification" bind = ":/opt/yunohost/__APP__/dendrite.yaml" default = true diff --git a/scripts/config b/scripts/config index c56dc29..a4d62c3 100644 --- a/scripts/config +++ b/scripts/config @@ -11,7 +11,6 @@ source /usr/share/yunohost/helpers # Stop script if errors ynh_abort_if_errors -final_path=$(ynh_app_setting_get --app=$app --key=final_path) get_registration_disabled() { registration_disabled=$(ynh_app_setting_get --app $app --key registration_disabled) @@ -26,7 +25,7 @@ set__registration_disabled() { really_enable_open_registration="--really-enable-open-registration" fi - ynh_write_var_in_file --file=$final_path/dendrite.yaml --key=registration_disabled --value="${registration_disabled}" + ynh_write_var_in_file --file=$install_dir/dendrite.yaml --key=registration_disabled --value="${registration_disabled}" ynh_add_systemd_config ynh_app_setting_set --app=$app --key=registration_disabled --value=$registration_disabled } diff --git a/scripts/install b/scripts/install index fb8aaac..c3ed8a5 100644 --- a/scripts/install +++ b/scripts/install @@ -19,9 +19,11 @@ if [ $registration -eq 1 ] then registration_disabled="false" really_enable_open_registration="--really-enable-open-registration" + enable_registration_captcha="true" else registration_disabled="true" really_enable_open_registration="" + enable_registration_captcha="false" fi #================================================= @@ -29,7 +31,6 @@ fi #================================================= ynh_app_setting_set --app=$app --key=server_name --value=$server_name -ynh_app_setting_set --app=$app --key=registration --value=$registration #================================================= # ADD USER TO THE SSL-CERT GROUP @@ -103,6 +104,18 @@ popd # Set permissions to app files chown -R $app:root "$install_dir" +#================================================= +## SET STANDARD SETTINGS FROM DEFAULT CONFIG +#================================================= +disable_federation="false" +guests_disabled="true" +registration_shared_secret="" +ynh_app_setting_set --app=$app --key=registration_disabled --value=$registration_disabled +ynh_app_setting_set --app=$app --key=disable_federation --value=$disable_federation +ynh_app_setting_set --app=$app --key=guests_disabled --value=$guests_disabled +ynh_app_setting_set --app=$app --key=registration_shared_secret --value=$registration_shared_secret +ynh_app_setting_set --app=$app --key=enable_registration_captcha --value=$enable_registration_captcha + #================================================= # ADD A CONFIGURATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 8545259..bb6399b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -34,21 +34,66 @@ if ! groups $app | grep -q 'ssl-cert'; then adduser $app ssl-cert fi +#================================================= +# GET CONFIG PANEL SETTINGS +#================================================= + +server_name=$(ynh_app_setting_get --app=$app --key=server_name) +registration_disabled=$(ynh_app_setting_get --app=$app --key=registration_disabled) +disable_federation=$(ynh_app_setting_get --app=$app --key=disable_federation) +guests_disabled=$(ynh_app_setting_get --app=$app --key=guests_disabled) +registration_shared_secret=$(ynh_app_setting_get --app=$app --key=registration_shared_secret) +enable_registration_captcha=$(ynh_app_setting_get --app=$app --key=enable_registration_captcha) + +#================================================= +# STANDARD UPGRADE STEPS +#================================================= +# MIGRATION : Manage old settings +#================================================= + +domain=$(ynh_app_setting_get --app=$app --key=domain) +ynh_app_setting_delete --app=$app --key=domain + # 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 +# Define $disable_federation if not already defined +if [ -z $disable_federation ]; then + disable_federation="false" + ynh_app_setting_set --app=$app --key=disable_federation --value=$disable_federation +fi + +# Define $guests_disabled if not already defined +if [ -z $guests_disabled ]; then + guests_disabled="true" + ynh_app_setting_set --app=$app --key=guests_disabled --value=$guests_disabled +fi + +# Define $registration_shared_secret if not already defined +if [ -z $registration_shared_secret ]; then + registration_shared_secret="" + ynh_app_setting_set --app=$app --key=registration_shared_secret --value=$registration_shared_secret +fi + # Load up registration variables if [[ $registration -eq 1 ]] then - registration_disabled="false" - really_enable_open_registration="--really-enable-open-registration" + registration_disabled="false" + really_enable_open_registration="--really-enable-open-registration" + enable_registration_captcha="true" + ynh_app_setting_set --app=$app --key=registration_disabled --value=$registration_disabled + ynh_app_setting_set --app=$app --key=enable_registration_captcha --value=$enable_registration_captcha + ynh_app_setting_delete --app=$app --key=registration else - registration_disabled="true" - really_enable_open_registration="" - ynh_app_setting_set --app=$app --key=registration --value=0 + registration_disabled="true" + really_enable_open_registration="" + enable_registration_captcha="false" + ynh_app_setting_set --app=$app --key=registration_disabled --value=$registration_disabled + ynh_app_setting_set --app=$app --key=enable_registration_captcha --value=$enable_registration_captcha + ynh_app_setting_delete --app=$app --key=registration fi #================================================= From 859d655ed3fb73b8607ba82efcd87b54538c73ad Mon Sep 17 00:00:00 2001 From: Gredin67 Date: Mon, 31 Jul 2023 14:59:09 +0200 Subject: [PATCH 04/15] load registration --- scripts/upgrade | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index bb6399b..ff9fbd6 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -79,23 +79,25 @@ if [ -z $registration_shared_secret ]; then fi # Load up registration variables -if [[ $registration -eq 1 ]] -then - registration_disabled="false" - really_enable_open_registration="--really-enable-open-registration" - enable_registration_captcha="true" - ynh_app_setting_set --app=$app --key=registration_disabled --value=$registration_disabled - ynh_app_setting_set --app=$app --key=enable_registration_captcha --value=$enable_registration_captcha - ynh_app_setting_delete --app=$app --key=registration +registration=$(ynh_app_setting_get --app=$app --key=registration) +if [ -z $registration ]; then else - registration_disabled="true" - really_enable_open_registration="" - enable_registration_captcha="false" - ynh_app_setting_set --app=$app --key=registration_disabled --value=$registration_disabled - ynh_app_setting_set --app=$app --key=enable_registration_captcha --value=$enable_registration_captcha ynh_app_setting_delete --app=$app --key=registration + if [[ $registration -eq 1 ]] + then + registration_disabled="false" + really_enable_open_registration="--really-enable-open-registration" + enable_registration_captcha="true" + ynh_app_setting_set --app=$app --key=registration_disabled --value=$registration_disabled + ynh_app_setting_set --app=$app --key=enable_registration_captcha --value=$enable_registration_captcha + else + registration_disabled="true" + really_enable_open_registration="" + enable_registration_captcha="false" + ynh_app_setting_set --app=$app --key=registration_disabled --value=$registration_disabled + ynh_app_setting_set --app=$app --key=enable_registration_captcha --value=$enable_registration_captcha + fi fi - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= From aed63757171c13a6e06fd8125b393581ac329432 Mon Sep 17 00:00:00 2001 From: Gredin67 Date: Mon, 31 Jul 2023 15:02:28 +0200 Subject: [PATCH 05/15] typo --- scripts/upgrade | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index ff9fbd6..b8ef5ac 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -80,24 +80,22 @@ fi # Load up registration variables registration=$(ynh_app_setting_get --app=$app --key=registration) -if [ -z $registration ]; then +ynh_app_setting_delete --app=$app --key=registration +if [[ $registration -eq 1 ]] +then + registration_disabled="false" + really_enable_open_registration="--really-enable-open-registration" + enable_registration_captcha="true" + ynh_app_setting_set --app=$app --key=registration_disabled --value=$registration_disabled + ynh_app_setting_set --app=$app --key=enable_registration_captcha --value=$enable_registration_captcha else - ynh_app_setting_delete --app=$app --key=registration - if [[ $registration -eq 1 ]] - then - registration_disabled="false" - really_enable_open_registration="--really-enable-open-registration" - enable_registration_captcha="true" - ynh_app_setting_set --app=$app --key=registration_disabled --value=$registration_disabled - ynh_app_setting_set --app=$app --key=enable_registration_captcha --value=$enable_registration_captcha - else - registration_disabled="true" - really_enable_open_registration="" - enable_registration_captcha="false" - ynh_app_setting_set --app=$app --key=registration_disabled --value=$registration_disabled - ynh_app_setting_set --app=$app --key=enable_registration_captcha --value=$enable_registration_captcha - fi + registration_disabled="true" + really_enable_open_registration="" + enable_registration_captcha="false" + ynh_app_setting_set --app=$app --key=registration_disabled --value=$registration_disabled + ynh_app_setting_set --app=$app --key=enable_registration_captcha --value=$enable_registration_captcha fi + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= From deea77a7925ac04e075898f4bde1f8d783396015 Mon Sep 17 00:00:00 2001 From: Gredin67 Date: Mon, 31 Jul 2023 15:37:29 +0200 Subject: [PATCH 06/15] unbound variable --- scripts/upgrade | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index b8ef5ac..b71bfb0 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -80,20 +80,24 @@ fi # Load up registration variables registration=$(ynh_app_setting_get --app=$app --key=registration) -ynh_app_setting_delete --app=$app --key=registration -if [[ $registration -eq 1 ]] -then - registration_disabled="false" - really_enable_open_registration="--really-enable-open-registration" - enable_registration_captcha="true" - ynh_app_setting_set --app=$app --key=registration_disabled --value=$registration_disabled - ynh_app_setting_set --app=$app --key=enable_registration_captcha --value=$enable_registration_captcha +if [ -z $registration ]; then +registration=$registration_disabled else - registration_disabled="true" - really_enable_open_registration="" - enable_registration_captcha="false" - ynh_app_setting_set --app=$app --key=registration_disabled --value=$registration_disabled - ynh_app_setting_set --app=$app --key=enable_registration_captcha --value=$enable_registration_captcha + ynh_app_setting_delete --app=$app --key=registration + if [[ $registration -eq 1 ]] + then + registration_disabled="false" + really_enable_open_registration="--really-enable-open-registration" + enable_registration_captcha="true" + ynh_app_setting_set --app=$app --key=registration_disabled --value=$registration_disabled + ynh_app_setting_set --app=$app --key=enable_registration_captcha --value=$enable_registration_captcha + else + registration_disabled="true" + really_enable_open_registration="" + enable_registration_captcha="false" + ynh_app_setting_set --app=$app --key=registration_disabled --value=$registration_disabled + ynh_app_setting_set --app=$app --key=enable_registration_captcha --value=$enable_registration_captcha + fi fi #================================================= From 7685f190c1db6550df86c708449ed36540e79e16 Mon Sep 17 00:00:00 2001 From: Gredin67 Date: Mon, 31 Jul 2023 15:47:25 +0200 Subject: [PATCH 07/15] add __FOOBAR__ in config --- conf/dendrite.yaml | 8 ++++---- scripts/upgrade | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/conf/dendrite.yaml b/conf/dendrite.yaml index ed247c7..6f7da7a 100644 --- a/conf/dendrite.yaml +++ b/conf/dendrite.yaml @@ -81,7 +81,7 @@ global: # Disables federation. Dendrite will not be able to communicate with other servers # in the Matrix federation and the federation API will not be exposed. - disable_federation: false + disable_federation: __DISABLE_FEDERATION__ # Configures the handling of presence events. Inbound controls whether we receive # presence events from other servers, outbound controls whether we send presence @@ -164,16 +164,16 @@ client_api: # Prevents new guest accounts from being created. Guest registration is also # disabled implicitly by setting 'registration_disabled' above. - guests_disabled: true + guests_disabled: __GUESTS_DISABLED__ # If set, allows registration by anyone who knows the shared secret, regardless # of whether registration is otherwise disabled. - registration_shared_secret: "" + registration_shared_secret: __REGISTRATION_SHARED_SECRET__ # Whether to require reCAPTCHA for registration. If you have enabled registration # then this is HIGHLY RECOMMENDED to reduce the risk of your homeserver being used # for coordinated spam attacks. - enable_registration_captcha: false + enable_registration_captcha: __ENABLE_REGISTRATION_CAPTCHA # Settings for ReCAPTCHA. recaptcha_public_key: "" diff --git a/scripts/upgrade b/scripts/upgrade index b71bfb0..d4f82be 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -81,7 +81,7 @@ fi # Load up registration variables registration=$(ynh_app_setting_get --app=$app --key=registration) if [ -z $registration ]; then -registration=$registration_disabled + registration=$registration_disabled else ynh_app_setting_delete --app=$app --key=registration if [[ $registration -eq 1 ]] From dfbdfca77e075cfe4b6e44d701823093c8c5165f Mon Sep 17 00:00:00 2001 From: Gredin67 Date: Mon, 31 Jul 2023 16:42:52 +0200 Subject: [PATCH 08/15] ynh_systemd_action --- conf/dendrite.yaml | 2 +- scripts/config | 2 ++ scripts/upgrade | 1 - 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/conf/dendrite.yaml b/conf/dendrite.yaml index 6f7da7a..d9ad595 100644 --- a/conf/dendrite.yaml +++ b/conf/dendrite.yaml @@ -173,7 +173,7 @@ client_api: # Whether to require reCAPTCHA for registration. If you have enabled registration # then this is HIGHLY RECOMMENDED to reduce the risk of your homeserver being used # for coordinated spam attacks. - enable_registration_captcha: __ENABLE_REGISTRATION_CAPTCHA + enable_registration_captcha: __ENABLE_REGISTRATION_CAPTCHA__ # Settings for ReCAPTCHA. recaptcha_public_key: "" diff --git a/scripts/config b/scripts/config index a4d62c3..e7991f5 100644 --- a/scripts/config +++ b/scripts/config @@ -14,6 +14,7 @@ ynh_abort_if_errors get_registration_disabled() { registration_disabled=$(ynh_app_setting_get --app $app --key registration_disabled) + domain=$(ynh_app_setting_get --app $app --key domain) echo "${registration_disabled}" } @@ -27,6 +28,7 @@ set__registration_disabled() { ynh_write_var_in_file --file=$install_dir/dendrite.yaml --key=registration_disabled --value="${registration_disabled}" ynh_add_systemd_config + ynh_systemd_action --service_name=$app --action="restart" --line_match="Starting external listener" --log_path="systemd" ynh_app_setting_set --app=$app --key=registration_disabled --value=$registration_disabled } #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index d4f82be..53c1ec2 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -52,7 +52,6 @@ enable_registration_captcha=$(ynh_app_setting_get --app=$app --key=enable_regist #================================================= domain=$(ynh_app_setting_get --app=$app --key=domain) -ynh_app_setting_delete --app=$app --key=domain # Define $server_name if not already defined if [ -z $server_name ]; then From e5a2f210b80c6216877f01cc16e4828dd5a3d78d Mon Sep 17 00:00:00 2001 From: Gredin67 Date: Mon, 31 Jul 2023 17:35:08 +0200 Subject: [PATCH 09/15] $domain not initialized --- scripts/config | 2 +- scripts/install | 1 + scripts/upgrade | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/config b/scripts/config index e7991f5..2fdc008 100644 --- a/scripts/config +++ b/scripts/config @@ -14,7 +14,6 @@ ynh_abort_if_errors get_registration_disabled() { registration_disabled=$(ynh_app_setting_get --app $app --key registration_disabled) - domain=$(ynh_app_setting_get --app $app --key domain) echo "${registration_disabled}" } @@ -27,6 +26,7 @@ set__registration_disabled() { fi ynh_write_var_in_file --file=$install_dir/dendrite.yaml --key=registration_disabled --value="${registration_disabled}" + domain=$(ynh_app_setting_get --app $app --key domain) ynh_add_systemd_config ynh_systemd_action --service_name=$app --action="restart" --line_match="Starting external listener" --log_path="systemd" ynh_app_setting_set --app=$app --key=registration_disabled --value=$registration_disabled diff --git a/scripts/install b/scripts/install index c3ed8a5..2e49951 100644 --- a/scripts/install +++ b/scripts/install @@ -31,6 +31,7 @@ fi #================================================= ynh_app_setting_set --app=$app --key=server_name --value=$server_name +ynh_app_setting_set --app=$app --key=domain --value=$domain #================================================= # ADD USER TO THE SSL-CERT GROUP diff --git a/scripts/upgrade b/scripts/upgrade index 53c1ec2..c8c0ea7 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -39,6 +39,8 @@ fi #================================================= server_name=$(ynh_app_setting_get --app=$app --key=server_name) +domain=$(ynh_app_setting_get --app=$app --key=domain) + registration_disabled=$(ynh_app_setting_get --app=$app --key=registration_disabled) disable_federation=$(ynh_app_setting_get --app=$app --key=disable_federation) guests_disabled=$(ynh_app_setting_get --app=$app --key=guests_disabled) @@ -51,7 +53,6 @@ enable_registration_captcha=$(ynh_app_setting_get --app=$app --key=enable_regist # MIGRATION : Manage old settings #================================================= -domain=$(ynh_app_setting_get --app=$app --key=domain) # Define $server_name if not already defined if [ -z $server_name ]; then From daebb34bebeaac0ca96cb792feb85f908f17d98e Mon Sep 17 00:00:00 2001 From: Gredin67 Date: Mon, 31 Jul 2023 20:07:49 +0200 Subject: [PATCH 10/15] get settings port etc --- scripts/config | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/config b/scripts/config index 2fdc008..fa5d733 100644 --- a/scripts/config +++ b/scripts/config @@ -27,6 +27,9 @@ set__registration_disabled() { ynh_write_var_in_file --file=$install_dir/dendrite.yaml --key=registration_disabled --value="${registration_disabled}" domain=$(ynh_app_setting_get --app $app --key domain) + port_tls=$(ynh_app_setting_get --app $app --key port_tls) + port=$(ynh_app_setting_get --app $app --key port) + psql_version=$(ynh_app_setting_get --app $app --key psql_version) ynh_add_systemd_config ynh_systemd_action --service_name=$app --action="restart" --line_match="Starting external listener" --log_path="systemd" ynh_app_setting_set --app=$app --key=registration_disabled --value=$registration_disabled From 4e7e853da680fb9bd103204887a99cacc70fa0cf Mon Sep 17 00:00:00 2001 From: Gredin67 Date: Mon, 31 Jul 2023 20:29:59 +0200 Subject: [PATCH 11/15] typo --- scripts/config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/config b/scripts/config index fa5d733..59b6269 100644 --- a/scripts/config +++ b/scripts/config @@ -18,7 +18,7 @@ get_registration_disabled() { } set__registration_disabled() { - if [ $registration_disabled ] + if [ $registration_disabled -eq "1" ] then really_enable_open_registration="" else From 54d31281e391c95a011c2f523631d29b2a130ff6 Mon Sep 17 00:00:00 2001 From: Gredin67 Date: Mon, 31 Jul 2023 23:20:52 +0200 Subject: [PATCH 12/15] typo add instructions --- config_panel.toml | 67 ++++++++++++++++++++++++++++------------------- scripts/config | 2 +- 2 files changed, 41 insertions(+), 28 deletions(-) diff --git a/config_panel.toml b/config_panel.toml index a05a1e8..3fd5a87 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -2,18 +2,55 @@ version = "1.0" [main] name = "Dendrite configuration" +services = ["__APP__"] [main.registration] name = "User registration" + [main.registration.registration_shared_secret] + ask = "Shared Secret for Registration." + type = "string" + help = "Allows registration of default user or admin accounts, even if Registration disabled. See instructions https://matrix-org.github.io/synapse/latest/admin_api/register_api.html" + bind = ":/opt/yunohost/__APP__/dendrite.yaml" + + [main.registration.helptext] + ask = ''' + HOW TO REGISTER AN ACCOUNT ? + * Provide a Registration Shared Secret. + * To register an **admin** account for the user `USERNAME`, connect to your server with ssh and type : + `/opt/yunohost/dendrite/bin/create-account -config /opt/yunohost/dendrite/dendrite.yaml -username USERNAME -admin` + * Remove `-admin` to register a default user account + ''' + type = "markdown" + [main.registration.registration_disabled] - ask = "Should registration be disabled?" + ask = "Disable Registration from Element ?" type = "boolean" yes = true no = false - help = "Disallows registration of standard accounts. If your server is federated, reCAPTCHA verification should be activated to avoid spamming the whole Matrix network." + help = "If True, Registration of default user accounts from a Client App is disabled. If false and your server is federated, reCAPTCHA verification should be activated to avoid spamming the whole Matrix network." default = true + [main.registration.enable_registration_captcha] + ask = "Require CAPTCHA verification for Registration." + type = "boolean" + yes = true + no = false + help = "ReCAPTCHA API should be configured. See instructions https://matrix-org.github.io/dendrite/administration/registration#recaptcha-verification" + bind = ":/opt/yunohost/__APP__/dendrite.yaml" + default = true + visible = "!registration_disabled" + + [main.registration.guests_disabled] + ask = "Disable guests registration." + type = "boolean" + yes = true + no = false + help = "Guest registration is also disabled implicitly if Registration from Element is disabled." + bind = ":/opt/yunohost/__APP__/dendrite.yaml" + default = true + visible = "!registration_disabled" + [main.registration.disable_federation] ask = "Disable Federation." type = "boolean" @@ -21,28 +58,4 @@ name = "Dendrite configuration" no = false help = "Do not communicate with other homeservers of the Matrix Federation." bind = ":/opt/yunohost/__APP__/dendrite.yaml" - default = false - - [main.registration.guests_disabled] - ask = "Disable guests registration." - type = "boolean" - yes = true - no = false - help = "Guest registration is also disabled implicitly if registration is disabled." - bind = ":/opt/yunohost/__APP__/dendrite.yaml" - default = true - - [main.registration.registration_shared_secret] - ask = "Shared Secret for Registration." - type = "string" - help = "Allows registration of standard or admin accounts, even if Registration disabled. See instructions https://matrix-org.github.io/synapse/latest/admin_api/register_api.html" - bind = ":/opt/yunohost/__APP__/dendrite.yaml" - - [main.registration.enable_registration_captcha] - ask = "Enable CAPTCHA for registration." - type = "boolean" - yes = true - no = false - help = "ReCAPTCHA API should be configured. See instructions https://matrix-org.github.io/dendrite/administration/registration#recaptcha-verification" - bind = ":/opt/yunohost/__APP__/dendrite.yaml" - default = true + default = false \ No newline at end of file diff --git a/scripts/config b/scripts/config index 59b6269..46a5252 100644 --- a/scripts/config +++ b/scripts/config @@ -18,7 +18,7 @@ get_registration_disabled() { } set__registration_disabled() { - if [ $registration_disabled -eq "1" ] + if [ "$registration_disabled" -eq "1" ] then really_enable_open_registration="" else From 3e0b90bf9e2097a5ca847d780974548a3d4755cf Mon Sep 17 00:00:00 2001 From: Gredin67 Date: Wed, 2 Aug 2023 18:26:08 +0200 Subject: [PATCH 13/15] no federation if no captcha --- config_panel.toml | 5 +---- manifest.toml | 2 ++ scripts/install | 6 +++--- scripts/upgrade | 14 +++++++------- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/config_panel.toml b/config_panel.toml index 3fd5a87..54b7aa6 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -29,7 +29,6 @@ services = ["__APP__"] yes = true no = false help = "If True, Registration of default user accounts from a Client App is disabled. If false and your server is federated, reCAPTCHA verification should be activated to avoid spamming the whole Matrix network." - default = true [main.registration.enable_registration_captcha] ask = "Require CAPTCHA verification for Registration." @@ -38,7 +37,6 @@ services = ["__APP__"] no = false help = "ReCAPTCHA API should be configured. See instructions https://matrix-org.github.io/dendrite/administration/registration#recaptcha-verification" bind = ":/opt/yunohost/__APP__/dendrite.yaml" - default = true visible = "!registration_disabled" [main.registration.guests_disabled] @@ -48,7 +46,6 @@ services = ["__APP__"] no = false help = "Guest registration is also disabled implicitly if Registration from Element is disabled." bind = ":/opt/yunohost/__APP__/dendrite.yaml" - default = true visible = "!registration_disabled" [main.registration.disable_federation] @@ -58,4 +55,4 @@ services = ["__APP__"] no = false help = "Do not communicate with other homeservers of the Matrix Federation." bind = ":/opt/yunohost/__APP__/dendrite.yaml" - default = false \ No newline at end of file + visible = "enable_registration_captcha" diff --git a/manifest.toml b/manifest.toml index 6b6eb05..dde6d63 100644 --- a/manifest.toml +++ b/manifest.toml @@ -44,6 +44,8 @@ ram.runtime = "50M" ask.en = "Should the server allow any visitor to register as a user?" ask.fr = "Le serveur doit-il permettre à quiconque de s'enregistrer comme utilisateur ?" type = "boolean" + help.en = "If no, accounts should be registered by an admin after defining a secret. If yes, to protect your server and the federation from spammer, federation will be deactived by default. You must Activate CAPTCHA verification before federation reactivation. See Config Panel for instructions" + help.fr = "Si non, les comptes seront créés par un admin après avoir défini un secret. Si oui, la fédération sera désactivée pour protéger la fédération et vous des spammeurs. Activez la vérification par CAPTCHA avant de réactiver la fédération ! Voir les instructions dans le Config Panel" default = false [resources] diff --git a/scripts/install b/scripts/install index 2e49951..9a23856 100644 --- a/scripts/install +++ b/scripts/install @@ -19,11 +19,11 @@ if [ $registration -eq 1 ] then registration_disabled="false" really_enable_open_registration="--really-enable-open-registration" - enable_registration_captcha="true" + disable_federation="true" else registration_disabled="true" really_enable_open_registration="" - enable_registration_captcha="false" + disable_federation="false" fi #================================================= @@ -108,9 +108,9 @@ chown -R $app:root "$install_dir" #================================================= ## SET STANDARD SETTINGS FROM DEFAULT CONFIG #================================================= -disable_federation="false" guests_disabled="true" registration_shared_secret="" +enable_registration_captcha="false" ynh_app_setting_set --app=$app --key=registration_disabled --value=$registration_disabled ynh_app_setting_set --app=$app --key=disable_federation --value=$disable_federation ynh_app_setting_set --app=$app --key=guests_disabled --value=$guests_disabled diff --git a/scripts/upgrade b/scripts/upgrade index c8c0ea7..81de766 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -61,9 +61,9 @@ if [ -z $server_name ]; then fi # Define $disable_federation if not already defined -if [ -z $disable_federation ]; then - disable_federation="false" - ynh_app_setting_set --app=$app --key=disable_federation --value=$disable_federation +if [ -z $enable_registration_captcha ]; then + enable_registration_captcha="false" + ynh_app_setting_set --app=$app --key=enable_registration_captcha --value=$enable_registration_captcha fi # Define $guests_disabled if not already defined @@ -88,15 +88,15 @@ else then registration_disabled="false" really_enable_open_registration="--really-enable-open-registration" - enable_registration_captcha="true" + disable_federation="true" ynh_app_setting_set --app=$app --key=registration_disabled --value=$registration_disabled - ynh_app_setting_set --app=$app --key=enable_registration_captcha --value=$enable_registration_captcha + ynh_app_setting_set --app=$app --key=disable_federation --value=$disable_federation else registration_disabled="true" really_enable_open_registration="" - enable_registration_captcha="false" + disable_federation="false" ynh_app_setting_set --app=$app --key=registration_disabled --value=$registration_disabled - ynh_app_setting_set --app=$app --key=enable_registration_captcha --value=$enable_registration_captcha + ynh_app_setting_set --app=$app --key=disable_federation --value=$disable_federation fi fi From d1d30097b2c675c6bdb063f73f25369c320124ee Mon Sep 17 00:00:00 2001 From: Gredin67 Date: Fri, 11 Aug 2023 11:39:04 +0200 Subject: [PATCH 14/15] init really_enable_open_registration --- scripts/upgrade | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 81de766..ab3cec1 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -81,7 +81,12 @@ fi # Load up registration variables registration=$(ynh_app_setting_get --app=$app --key=registration) if [ -z $registration ]; then - registration=$registration_disabled + if [ $registration_disabled -eq 1 ] + then + really_enable_open_registration="--really-enable-open-registration" + else + really_enable_open_registration="" + fi else ynh_app_setting_delete --app=$app --key=registration if [[ $registration -eq 1 ]] From e2197f675acbdad6119a4393b4656ffc083b581b Mon Sep 17 00:00:00 2001 From: Gredin67 Date: Sun, 13 Aug 2023 18:41:16 +0200 Subject: [PATCH 15/15] double quotes --- config_panel.toml | 16 ++++++++-------- scripts/install | 2 +- scripts/upgrade | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/config_panel.toml b/config_panel.toml index 54b7aa6..6f464ea 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -26,15 +26,15 @@ services = ["__APP__"] [main.registration.registration_disabled] ask = "Disable Registration from Element ?" type = "boolean" - yes = true - no = false + yes = "true" + no = "false" help = "If True, Registration of default user accounts from a Client App is disabled. If false and your server is federated, reCAPTCHA verification should be activated to avoid spamming the whole Matrix network." [main.registration.enable_registration_captcha] ask = "Require CAPTCHA verification for Registration." type = "boolean" - yes = true - no = false + yes = "true" + no = "false" help = "ReCAPTCHA API should be configured. See instructions https://matrix-org.github.io/dendrite/administration/registration#recaptcha-verification" bind = ":/opt/yunohost/__APP__/dendrite.yaml" visible = "!registration_disabled" @@ -42,8 +42,8 @@ services = ["__APP__"] [main.registration.guests_disabled] ask = "Disable guests registration." type = "boolean" - yes = true - no = false + yes = "true" + no = "false" help = "Guest registration is also disabled implicitly if Registration from Element is disabled." bind = ":/opt/yunohost/__APP__/dendrite.yaml" visible = "!registration_disabled" @@ -51,8 +51,8 @@ services = ["__APP__"] [main.registration.disable_federation] ask = "Disable Federation." type = "boolean" - yes = true - no = false + yes = "true" + no = "false" help = "Do not communicate with other homeservers of the Matrix Federation." bind = ":/opt/yunohost/__APP__/dendrite.yaml" visible = "enable_registration_captcha" diff --git a/scripts/install b/scripts/install index 9a23856..d921150 100644 --- a/scripts/install +++ b/scripts/install @@ -15,7 +15,7 @@ source /usr/share/yunohost/helpers #================================================= # Allow or deny registration based on is_public -if [ $registration -eq 1 ] +if [ "$registration" -eq "1" ] then registration_disabled="false" really_enable_open_registration="--really-enable-open-registration" diff --git a/scripts/upgrade b/scripts/upgrade index ab3cec1..a3a486c 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -81,7 +81,7 @@ fi # Load up registration variables registration=$(ynh_app_setting_get --app=$app --key=registration) if [ -z $registration ]; then - if [ $registration_disabled -eq 1 ] + if [ "$registration_disabled" -eq "1" ] then really_enable_open_registration="--really-enable-open-registration" else @@ -89,7 +89,7 @@ if [ -z $registration ]; then fi else ynh_app_setting_delete --app=$app --key=registration - if [[ $registration -eq 1 ]] + if [[ "$registration" -eq "1" ]] then registration_disabled="false" really_enable_open_registration="--really-enable-open-registration"