diff --git a/scripts/backup b/scripts/backup index 05535cb..9c9880f 100755 --- a/scripts/backup +++ b/scripts/backup @@ -29,6 +29,7 @@ ynh_print_info --message="Loading installation settings..." app="$YNH_APP_INSTANCE_NAME" domain=$(ynh_app_setting_get --app="$app" --key=domain) +account_domain=$(ynh_app_setting_get --app="$app" --key=account_domain) db_name=$(ynh_app_setting_get --app="$app" --key=db_name) @@ -63,6 +64,7 @@ ynh_backup --src_path="$datadir" --is_big #================================================= ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_backup --src_path="/etc/nginx/conf.d/$account_domain.d/$app.conf" #================================================= # SPECIFIC BACKUP diff --git a/scripts/install b/scripts/install index 70d4884..35cdb81 100755 --- a/scripts/install +++ b/scripts/install @@ -210,9 +210,22 @@ chown -R "$app:www-data" "$final_path" #================================================= ynh_script_progression --message="Configuring NGINX web server..." --weight=1 -# Create a dedicated NGINX config +# Create a dedicated NGINX config for the main domain ynh_add_nginx_config +# Create a dedicated NGINX config for the account domain, if applicable +if [ "$domain" != "$account_domain" ] && [ -n "$account_domain" ]; then + + # switching domain name for tricking ynh_add_nginx_config (who supports only the 'domain' variable) + domain="$account_domain" + + ynh_add_nginx_config + + # undo the trick + account_domain="$domain" +fi + + #================================================= # CREATE DATA DIRECTORY #================================================= diff --git a/scripts/remove b/scripts/remove index 88ddc19..eebe7a3 100755 --- a/scripts/remove +++ b/scripts/remove @@ -17,6 +17,7 @@ ynh_script_progression --message="Loading installation settings..." --weight=1 app="$YNH_APP_INSTANCE_NAME" domain=$(ynh_app_setting_get --app="$app" --key=domain) +account_domain=$(ynh_app_setting_get --app="$app" --key=account_domain) port=$(ynh_app_setting_get --app="$app" --key=port) db_name=$(ynh_app_setting_get --app="$app" --key=db_name) db_user=$(ynh_app_setting_get --app="$app" --key=db_user) @@ -81,9 +82,21 @@ ynh_secure_remove --file="$datadir" #================================================= ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1 -# Remove the dedicated NGINX config +# Remove the dedicated NGINX config of the main domain ynh_remove_nginx_config +# Remove the dedicated NGINX config for the account domain, if applicable +if [ "$domain" != "$account_domain" ] && [ -n "$account_domain" ]; then + + # switching domain name for tricking ynh_add_nginx_config (who supports only the 'domain' variable) + domain="$account_domain" + + ynh_remove_nginx_config + + # undo the trick + account_domain="$domain" +fi + #================================================= # REMOVE LOGROTATE CONFIGURATION #================================================= diff --git a/scripts/restore b/scripts/restore index 455ecbb..c7f5a5e 100755 --- a/scripts/restore +++ b/scripts/restore @@ -96,6 +96,7 @@ test ! -d "$final_path" \ ynh_script_progression --message="Restoring the NGINX configuration..." --weight=1 ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_restore_file --origin_path="/etc/nginx/conf.d/$account_domain.d/$app.conf" #================================================= # RECREATE THE DEDICATED USER diff --git a/scripts/upgrade b/scripts/upgrade index a8ed52a..def92ae 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -21,6 +21,7 @@ final_path=$(ynh_app_setting_get --app="$app" --key=final_path) landing_page_user=$(ynh_app_setting_get --app="$app" --key=landing_page_user) domain=$(ynh_app_setting_get --app="$app" --key=domain) +account_domain=$(ynh_app_setting_get --app="$app" --key=account_domain) port=$(ynh_app_setting_get --app="$app" --key=port) path_url=$(ynh_app_setting_get --app="$app" --key=path_url) @@ -277,9 +278,21 @@ chown -R "$app:www-data" "$final_path" #================================================= ynh_script_progression --message="Upgrading NGINX web server configuration..." -# Create a dedicated NGINX config +# Create a dedicated NGINX config for the main domain ynh_add_nginx_config +# Create a dedicated NGINX config for the account domain, if applicable +if [ "$domain" != "$account_domain" ] && [ -n "$account_domain" ]; then + + # switching domain name for tricking ynh_add_nginx_config (who supports only the 'domain' variable) + domain="$account_domain" + + ynh_add_nginx_config + + # undo the trick + account_domain="$domain" +fi + #================================================= # UPGRADE DEPENDENCIES #=================================================