From 8c475d0a7b3acc7871e65256dd712d3aa953d517 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com> Date: Tue, 5 Dec 2023 19:01:17 +0100 Subject: [PATCH] Further simplify ynh_change_url_nginx_config --- helpers/nginx | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/helpers/nginx b/helpers/nginx index cf58c3f1a..600c70a49 100644 --- a/helpers/nginx +++ b/helpers/nginx @@ -44,33 +44,22 @@ ynh_remove_nginx_config() { } -# Move / regen the nginx config in a change url context +# Regen the nginx config in a change url context # # usage: ynh_change_url_nginx_config # # Requires YunoHost version 11.1.9 or higher. ynh_change_url_nginx_config() { + + # Make a backup of the original NGINX config file if manually modified + # (nb: this is possibly different from the same instruction called by + # ynh_add_config inside ynh_add_nginx_config because the path may have + # changed if we're changing the domain too...) local old_nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf - local new_nginx_conf_path=/etc/nginx/conf.d/$new_domain.d/$app.conf + ynh_backup_if_checksum_is_different --file="$old_nginx_conf_path" + ynh_delete_file_checksum --file="$old_nginx_conf_path" + ynh_secure_remove --file="$old_nginx_conf_path" - # Change the domain for NGINX - if [ $change_domain -eq 1 ] - then - ynh_delete_file_checksum --file="$old_nginx_conf_path" - mv "$old_nginx_conf_path" "$new_nginx_conf_path" - ynh_store_file_checksum --file="$new_nginx_conf_path" - fi - - # Change the path in the NGINX config file - if [ $change_path -eq 1 ] - then - # Make a backup of the original NGINX config file if modified - ynh_backup_if_checksum_is_different --file="$old_nginx_conf_path" - # Set global variables for NGINX helper - path="$new_path" - path_url="$new_path" - # Create a dedicated NGINX config - ynh_add_nginx_config - fi - ynh_systemd_action --service_name=nginx --action=reload + # Regen the nginx conf + ynh_add_nginx_config }