From cf01d3f9ab2f307fce610fe39aa0f271340bd763 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9rard=20Collin?= Date: Thu, 28 Sep 2023 11:28:10 +0200 Subject: [PATCH] Better fix by creating expected file --- scripts/upgrade | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index ff0d7e5..73aad75 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -38,18 +38,25 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -# There is an issue in previous backup file in case of non public_key, so backup only in case of public_key -if [ -n "$public_key" ] +# There is an issue in previous backup file in case of non public_key, so we create the missing directory +if [ ! -f "/etc/sudoers.d/$app-sudoers" ] then + touch "/etc/sudoers.d/$app-sudoers" +fi - ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1 +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1 - # Backup the current version of the app - ynh_backup_before_upgrade - ynh_clean_setup () { - # Restore it if the upgrade fails - ynh_restore_upgradebackup - } +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # Restore it if the upgrade fails + ynh_restore_upgradebackup +} + +# Removes the directory created only for backup if not necessary +if [ ! -n "$public_key" ] +then + rm "/etc/sudoers.d/$app-sudoers" fi # Exit if an error occurs during the execution of the script