diff --git a/scripts/_common.sh b/scripts/_common.sh index bc0e388..de751a4 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,19 +1,21 @@ #!/bin/bash -synapse_domain=$(ynh_app_setting_get --app="$synapse_app" --key=domain) -synapse_port=$(ynh_app_setting_get --app="$synapse_app" --key=port_synapse) -if [[ -z "$synapse_port" ]] -then - # The setting was synapse_port in older versions of the app - synapse_port=$(ynh_app_setting_get --app="$synapse_app" --key=synapse_port) - if [[ -z "$synapse_port" ]] - ynh_die --message="Unable to find synapse port ?!" - fi -fi - _add_synapse_endpoint_nginx_config() { + + synapse_domain=$(ynh_app_setting_get --app="$synapse_app" --key=domain) + synapse_port=$(ynh_app_setting_get --app="$synapse_app" --key=port_synapse) + if [[ -z "$synapse_port" ]] + then + # The setting was synapse_port in older versions of the app + 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 ?!" + fi + fi + # In case the domain changed for some reason - old_endpoint_confs_for_this_app="$(ls /etc/nginx/conf.d/!($synapse_domain).d/$app.endpoint.conf)" + old_endpoint_confs_for_this_app="$(ls /etc/nginx/conf.d/!($synapse_domain).d/$app.endpoint.conf 2>/dev/null)" for FILE in $old_endpoint_confs_for_this_app do ynh_delete_file_checksum --file="$FILE" diff --git a/scripts/backup b/scripts/backup index 1b290e6..f3775a8 100644 --- a/scripts/backup +++ b/scripts/backup @@ -24,6 +24,8 @@ ynh_backup --src_path="$install_dir" # BACKUP THE NGINX CONFIGURATION #================================================= +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" diff --git a/scripts/remove b/scripts/remove index 1e11c2e..7de46d5 100644 --- a/scripts/remove +++ b/scripts/remove @@ -8,6 +8,8 @@ source _common.sh source /usr/share/yunohost/helpers + +synapse_domain=$(ynh_app_setting_get --app="$synapse_app" --key=domain) #================================================= # REMOVE SYSTEM CONFIGURATIONS diff --git a/scripts/restore b/scripts/restore index 45fd866..33cf871 100644 --- a/scripts/restore +++ b/scripts/restore @@ -24,6 +24,8 @@ chown -R $app:www-data "$install_dir" #================================================= ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 +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"