From f3b89ccce4df15a93d2475109143c26523606c8c Mon Sep 17 00:00:00 2001 From: Josue-T Date: Mon, 9 Jan 2023 12:01:04 +0100 Subject: [PATCH 1/4] Update _common.sh --- scripts/_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index d3ca72f..7e7b82d 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -53,7 +53,7 @@ install_sources() { fi chown $synapse_user:root -R $final_path - sudo -u $synapse_user env PATH=$PATH pip3 install --upgrade 'cryptography>=3.4.7' + sudo -u $synapse_user env PATH=$PATH pip3 install --upgrade 'cryptography>=3.4.7' 'pyOpenSSL>=22.1.0' pip3 install --upgrade cffi ndg-httpsclient psycopg2 lxml jinja2 # Fix issue https://github.com/YunoHost-Apps/synapse_ynh/issues/248 pip3 install --upgrade 'Twisted>=21' 'treq>=21.1.0' matrix-synapse==$upstream_version matrix-synapse-ldap3 From d3694bcc55717bea63c5b54c47d3648895dae20e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Sol=C3=ADs?= Date: Mon, 9 Jan 2023 11:12:22 -0600 Subject: [PATCH 2/4] Fix issue with user creation script In recent versions, YunoHost has deprecated the parameters "-f FIRSTNAME" and "-l LASTNAME", substituting them with "-F FULLNAME" instead. Without this patch, newer versions of YunoHost will output an error message, "WARNING - Not a tty, can't do interactive prompts", and fail installing or upgrading. --- 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 f620003..727f48f 100644 --- a/scripts/install +++ b/scripts/install @@ -146,7 +146,7 @@ ynh_exec_warn_less ynh_install_app_dependencies $dependances ynh_script_progression --message="Configuring system user..." --weight=3 ynh_system_user_create --username=$synapse_user --home_dir=$final_path -yunohost user create $synapse_user_app -f Synapse -l Application -d $domain -p "$synapse_user_app_pwd" +yunohost user create $synapse_user_app -f Synapse -l Application -F "Synapse Application" -d $domain -p "$synapse_user_app_pwd" adduser $synapse_user ssl-cert adduser turnserver ssl-cert diff --git a/scripts/restore b/scripts/restore index a393098..2365c22 100644 --- a/scripts/restore +++ b/scripts/restore @@ -80,7 +80,7 @@ ynh_script_progression --message="Recreating the dedicated system user..." --wei # Create the dedicated user (if not existing) ynh_system_user_create --username=$synapse_user --home_dir=$final_path -yunohost user create $synapse_user_app -f Synapse -l Application -d $domain -p "$synapse_user_app_pwd" +yunohost user create $synapse_user_app -f Synapse -l Application -F "Synapse Application" -d $domain -p "$synapse_user_app_pwd" adduser $synapse_user ssl-cert adduser turnserver ssl-cert diff --git a/scripts/upgrade b/scripts/upgrade index e108011..abd5412 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -141,7 +141,7 @@ fi if [ -z $synapse_user_app_pwd ]; then synapse_user_app_pwd="$(ynh_string_random --length=30)" ynh_app_setting_set --app=$app --key=synapse_user_app_pwd --value=$synapse_user_app_pwd - yunohost user create $synapse_user_app -f Synapse -l Application -d $domain -p "$synapse_user_app_pwd" + yunohost user create $synapse_user_app -f Synapse -l Application -F "Synapse Application" -d $domain -p "$synapse_user_app_pwd" fi #================================================= From 39ffead3a9a68d54f2bbe1e6d2a75743d08f87c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Sol=C3=ADs?= Date: Tue, 10 Jan 2023 09:56:15 -0600 Subject: [PATCH 3/4] Make user creation script depend on YNH version The format used to create a new user on YunoHost 11.1 and above is different than the one used beforehand. This change is intended to detect which version is currently installed and use the correct format. --- scripts/install | 8 +++++++- scripts/restore | 8 +++++++- scripts/upgrade | 8 +++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index 727f48f..9a7b3a1 100644 --- a/scripts/install +++ b/scripts/install @@ -146,7 +146,13 @@ ynh_exec_warn_less ynh_install_app_dependencies $dependances ynh_script_progression --message="Configuring system user..." --weight=3 ynh_system_user_create --username=$synapse_user --home_dir=$final_path -yunohost user create $synapse_user_app -f Synapse -l Application -F "Synapse Application" -d $domain -p "$synapse_user_app_pwd" +# The format to create an user account varies depending on the version of YunoHost currently installed. +ynh_current_version=$(dpkg-query --showformat='${Version}' --show yunohost) +if $(dpkg --compare-versions "$ynh_current_version" ge "11.1"); then + yunohost user create $synapse_user_app -F "Synapse Application" -d $domain -p "$synapse_user_app_pwd" +else + yunohost user create $synapse_user_app -f Synapse -l Application -d $domain -p "$synapse_user_app_pwd" +fi adduser $synapse_user ssl-cert adduser turnserver ssl-cert diff --git a/scripts/restore b/scripts/restore index 2365c22..8f424f8 100644 --- a/scripts/restore +++ b/scripts/restore @@ -80,7 +80,13 @@ ynh_script_progression --message="Recreating the dedicated system user..." --wei # Create the dedicated user (if not existing) ynh_system_user_create --username=$synapse_user --home_dir=$final_path -yunohost user create $synapse_user_app -f Synapse -l Application -F "Synapse Application" -d $domain -p "$synapse_user_app_pwd" +# The format to create an user account varies depending on the version of YunoHost currently installed. +ynh_current_version=$(dpkg-query --showformat='${Version}' --show yunohost) +if $(dpkg --compare-versions "$ynh_current_version" ge "11.1"); then + yunohost user create $synapse_user_app -F "Synapse Application" -d $domain -p "$synapse_user_app_pwd" +else + yunohost user create $synapse_user_app -f Synapse -l Application -d $domain -p "$synapse_user_app_pwd" +fi adduser $synapse_user ssl-cert adduser turnserver ssl-cert diff --git a/scripts/upgrade b/scripts/upgrade index abd5412..d530f6b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -141,7 +141,13 @@ fi if [ -z $synapse_user_app_pwd ]; then synapse_user_app_pwd="$(ynh_string_random --length=30)" ynh_app_setting_set --app=$app --key=synapse_user_app_pwd --value=$synapse_user_app_pwd - yunohost user create $synapse_user_app -f Synapse -l Application -F "Synapse Application" -d $domain -p "$synapse_user_app_pwd" + # The format to create an user account varies depending on the version of YunoHost currently installed. + ynh_current_version=$(dpkg-query --showformat='${Version}' --show yunohost) + if $(dpkg --compare-versions "$ynh_current_version" ge "11.1"); then + yunohost user create $synapse_user_app -F "Synapse Application" -d $domain -p "$synapse_user_app_pwd" + else + yunohost user create $synapse_user_app -f Synapse -l Application -d $domain -p "$synapse_user_app_pwd" + fi fi #================================================= From 500bb6538a31b083f895442ef0e93bbb74e97a61 Mon Sep 17 00:00:00 2001 From: Josue-T Date: Fri, 13 Jan 2023 08:16:02 +0100 Subject: [PATCH 4/4] force attrs version too --- scripts/_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 7e7b82d..b754169 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -53,7 +53,7 @@ install_sources() { fi chown $synapse_user:root -R $final_path - sudo -u $synapse_user env PATH=$PATH pip3 install --upgrade 'cryptography>=3.4.7' 'pyOpenSSL>=22.1.0' + sudo -u $synapse_user env PATH=$PATH pip3 install --upgrade 'cryptography>=3.4.7' 'pyOpenSSL>=22.1.0' 'attrs>=22.1.0' pip3 install --upgrade cffi ndg-httpsclient psycopg2 lxml jinja2 # Fix issue https://github.com/YunoHost-Apps/synapse_ynh/issues/248 pip3 install --upgrade 'Twisted>=21' 'treq>=21.1.0' matrix-synapse==$upstream_version matrix-synapse-ldap3