From 2639ddd8a894cf34523c5e701a4bff70b84daf3c Mon Sep 17 00:00:00 2001 From: Yunohost-Bot <> Date: Sat, 31 Aug 2024 03:04:35 +0200 Subject: [PATCH] [autopatch] Automatic patch attempt for helpers 2.1 --- manifest.toml | 4 +++- scripts/_common.sh | 8 ++++---- scripts/backup | 19 +++++------------ scripts/change_url | 12 +++-------- scripts/install | 21 +++++++------------ scripts/remove | 16 +++++---------- scripts/restore | 29 +++++++++----------------- scripts/upgrade | 51 ++++++++++++++++++++-------------------------- 8 files changed, 59 insertions(+), 101 deletions(-) diff --git a/manifest.toml b/manifest.toml index c36d49e..dc1deec 100644 --- a/manifest.toml +++ b/manifest.toml @@ -16,7 +16,8 @@ license = "Apache-2.0" code = "https://github.com/Awesome-Technologies/synapse-admin" [integration] -yunohost = ">= 11.2" +yunohost = ">= 11.2.18" +helpers_version = "2.1" architectures = "all" multi_instance = false @@ -57,6 +58,7 @@ ram.runtime = "50M" [resources.system_user] [resources.install_dir] + group = "www-data:r-x" [resources.permissions] main.url = "/" diff --git a/scripts/_common.sh b/scripts/_common.sh index edc963b..f9f0f34 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -10,7 +10,7 @@ _add_synapse_endpoint_nginx_config() { synapse_port=$(ynh_app_setting_get --app="$synapse_app" --key=synapse_port) if [[ -z "$synapse_port" ]] then - ynh_die --message="Unable to find synapse port ?!" + ynh_die "Unable to find synapse port ?!" fi fi @@ -18,9 +18,9 @@ _add_synapse_endpoint_nginx_config() { old_endpoint_confs_for_this_app="$(ls /etc/nginx/conf.d/*.d/$app.endpoint.conf 2>/dev/null | grep -v "$synapse_domain.d" || true)" for FILE in $old_endpoint_confs_for_this_app do - ynh_delete_file_checksum --file="$FILE" - ynh_secure_remove --file="$FILE" + ynh_delete_file_checksum "$FILE" + ynh_safe_rm "$FILE" done - ynh_add_config --template="endpoint.nginx.conf" --destination="/etc/nginx/conf.d/${synapse_domain}.d/$app.endpoint.conf" + ynh_config_add --template="endpoint.nginx.conf" --destination="/etc/nginx/conf.d/${synapse_domain}.d/$app.endpoint.conf" } diff --git a/scripts/backup b/scripts/backup index f3775a8..030370c 100644 --- a/scripts/backup +++ b/scripts/backup @@ -1,24 +1,15 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# DECLARE DATA AND CONF FILES TO BACKUP -#================================================= -ynh_print_info --message="Declaring files to be backed up..." +ynh_print_info "Declaring files to be backed up..." #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$install_dir" +ynh_backup "$install_dir" #================================================= # BACKUP THE NGINX CONFIGURATION @@ -26,11 +17,11 @@ ynh_backup --src_path="$install_dir" synapse_domain=$(ynh_app_setting_get --app="$synapse_app" --key=domain) -ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" -ynh_backup --src_path="/etc/nginx/conf.d/${synapse_domain}.d/$app.endpoint.conf" +ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_backup "/etc/nginx/conf.d/${synapse_domain}.d/$app.endpoint.conf" #================================================= # END OF SCRIPT #================================================= -ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." +ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/change_url b/scripts/change_url index 7564745..5dd1ad1 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -1,24 +1,18 @@ #!/bin/bash -#================================================= -# GENERIC STARTING -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 +ynh_script_progression "Updating NGINX web server configuration..." -ynh_change_url_nginx_config +ynh_config_change_url_nginx _add_synapse_endpoint_nginx_config #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Change of URL completed for $app" --last +ynh_script_progression "Change of URL completed for $app" diff --git a/scripts/install b/scripts/install index 70d2692..de9afb7 100644 --- a/scripts/install +++ b/scripts/install @@ -1,41 +1,34 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers #================================================= # GET SYNAPSE SETTINGS #================================================= -ynh_script_progression --message="Getting settings from Synapse..." --weight=2 +ynh_script_progression "Getting settings from Synapse..." #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." --weight=2 +ynh_script_progression "Setting up source files..." # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir=$install_dir -chmod -R o-rwx "$install_dir" -chown -R $app:www-data "$install_dir" - +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir" +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:www-data "$install_dir" #================================================= # SYSTEM CONFIGURATION #================================================= -ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 +ynh_script_progression "Adding system configurations related to $app..." # Create a dedicated NGINX config -ynh_add_nginx_config +ynh_config_add_nginx _add_synapse_endpoint_nginx_config #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" --last +ynh_script_progression "Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index 7de46d5..0a5c7af 100644 --- a/scripts/remove +++ b/scripts/remove @@ -1,29 +1,23 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers - + synapse_domain=$(ynh_app_setting_get --app="$synapse_app" --key=domain) #================================================= # REMOVE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 +ynh_script_progression "Removing system configurations related to $app..." # Remove the dedicated NGINX config -ynh_remove_nginx_config +ynh_config_remove_nginx # Remove NGINX config that enabled /_synapse/admin endpoint -ynh_secure_remove --file="/etc/nginx/conf.d/${synapse_domain}.d/$app.endpoint.conf" +ynh_safe_rm "/etc/nginx/conf.d/${synapse_domain}.d/$app.endpoint.conf" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" --last +ynh_script_progression "Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index 33cf871..e6216bc 100644 --- a/scripts/restore +++ b/scripts/restore @@ -1,45 +1,36 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." --weight=1 +ynh_script_progression "Restoring the app main directory..." -ynh_restore_file --origin_path="$install_dir" - -chmod -R o-rwx "$install_dir" -chown -R $app:www-data "$install_dir" +ynh_restore "$install_dir" +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir" +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:www-data "$install_dir" #================================================= # RESTORE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 +ynh_script_progression "Restoring system configurations related to $app..." synapse_domain=$(ynh_app_setting_get --app="$synapse_app" --key=domain) -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" -ynh_restore_file --origin_path="/etc/nginx/conf.d/${synapse_domain}.d/$app.endpoint.conf" +ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_restore "/etc/nginx/conf.d/${synapse_domain}.d/$app.endpoint.conf" -#================================================= -# GENERIC FINALIZATION #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 +ynh_script_progression "Reloading NGINX web server..." -ynh_systemd_action --service_name=nginx --action=reload +ynh_systemctl --service=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for $app" --last +ynh_script_progression "Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index e68534c..8a66247 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,72 +1,65 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers -upgrade_type=$(ynh_check_app_version_changed) - #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 +ynh_script_progression "Ensuring downward compatibility..." -if ynh_compare_current_package_version --comparison le --version 0.8.3~ynh2; then - ynh_die --message="Upgrade from version 0.8.3 is not possible. You must uninstall and reinstall Synapse-admin package manually" +if ynh_app_upgrading_from_version_before_or_equal_to 0.8.3~ynh2; then + ynh_die "Upgrade from version 0.8.3 is not possible. You must uninstall and reinstall Synapse-admin package manually" fi # If synapse_app doesn't exist, create it and assume it is `synapse` +# FIXMEhelpers2.1: maybe replace with: ynh_app_setting_set_default --key=synapse_app --value="synapse" if [ -z "${synapse_app:-}" ]; then synapse_app="synapse" - ynh_app_setting_set --app=$app --key=synapse_app --value=$synapse_app + ynh_app_setting_set --key=synapse_app --value=$synapse_app fi # Delete service and nodejs dependencies -if ynh_compare_current_package_version --comparison lt --version 0.8.7~ynh1; then +if ynh_app_upgrading_from_version_before 0.8.7~ynh1; then yunohost service remove $app - ynh_remove_systemd_config + ynh_config_remove_systemd - ynh_remove_nodejs - ynh_remove_logrotate + ynh_nodejs_remove + ynh_config_remove_logrotate - ynh_app_setting_delete --app=$app --key=synapse_port - ynh_app_setting_delete --app=$app --key=port + ynh_app_setting_delete --key=synapse_port + ynh_app_setting_delete --key=port fi -if ynh_compare_current_package_version --comparison lt --version 0.8.7~ynh3; then - ynh_app_setting_delete --app=$app --key=synapse_domain - ynh_app_setting_delete --app=$app --key=synapse_port +if ynh_app_upgrading_from_version_before 0.8.7~ynh3; then + ynh_app_setting_delete --key=synapse_domain + ynh_app_setting_delete --key=synapse_port fi #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -if [ "$upgrade_type" == "UPGRADE_APP" ]; then - ynh_script_progression --message="Upgrading source files..." --weight=2 +# FIXME: this is still supported but the recommendation is now to *always* re-setup the app sources wether or not the upstream sources changed +if ynh_app_upstream_version_changed; then + ynh_script_progression "Upgrading source files..." ynh_setup_source --dest_dir="$install_dir" fi -chmod -R o-rwx "$install_dir" -chown -R $app:www-data "$install_dir" - +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir" +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:www-data "$install_dir" #================================================= # REAPPLY SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 +ynh_script_progression "Upgrading system configurations related to $app..." # Create a dedicated nginx config -ynh_add_nginx_config +ynh_config_add_nginx _add_synapse_endpoint_nginx_config #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --last +ynh_script_progression "Upgrade of $app completed"