From 00086a445f16453ea953ce97025c94e11a6b43dc Mon Sep 17 00:00:00 2001 From: ljf Date: Thu, 4 May 2017 14:24:02 +0200 Subject: [PATCH] [enh] Add a test for ynh_restore helper --- backup_recommended_app_ynh/manifest.json | 8 ++++++++ backup_recommended_app_ynh/scripts/install | 4 ++++ backup_recommended_app_ynh/scripts/restore | 19 +++++++++++++------ 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/backup_recommended_app_ynh/manifest.json b/backup_recommended_app_ynh/manifest.json index 48f7419..4278be7 100644 --- a/backup_recommended_app_ynh/manifest.json +++ b/backup_recommended_app_ynh/manifest.json @@ -30,6 +30,14 @@ }, "example": "/", "default": "/" + }, + { + "name": "helper_to_test", + "ask": { + "en": "Choose the restore helper to use for the test" + }, + "example": "ynh_restore", + "default": "ynh_restore_file" } ] } diff --git a/backup_recommended_app_ynh/scripts/install b/backup_recommended_app_ynh/scripts/install index 616fec6..794859a 100644 --- a/backup_recommended_app_ynh/scripts/install +++ b/backup_recommended_app_ynh/scripts/install @@ -5,6 +5,7 @@ app=$YNH_APP_INSTANCE_NAME number=$YNH_APP_INSTANCE_NUMBER domain=$YNH_APP_ARG_DOMAIN path=$YNH_APP_ARG_PATH +helper_to_test=$YNH_APP_ARG_HELPER_TO_TEST # Source app helpers source /usr/share/yunohost/helpers @@ -12,6 +13,9 @@ source /usr/share/yunohost/helpers # Check domain/path availability sudo yunohost app checkurl $domain/$path -a $app +# Register mode of restoration +ynh_app_setting_set $app helper_to_test $helper_to_test + # Add config for nginx sudo sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf sudo sed -i "s@FOLDER@$app/@g" ../conf/nginx.conf diff --git a/backup_recommended_app_ynh/scripts/restore b/backup_recommended_app_ynh/scripts/restore index c38ffbc..ffd4c86 100644 --- a/backup_recommended_app_ynh/scripts/restore +++ b/backup_recommended_app_ynh/scripts/restore @@ -10,15 +10,22 @@ app=$2 # Get old parameter of the app domain=$(ynh_app_setting_get $app domain) path=$(ynh_app_setting_get $app path) +helper_to_test=$(ynh_app_setting_get $app helper_to_test) -# Restore www directory -ynh_restore_file /var/www/$app +# Test the 2 alternatives to restore +if [ "$helper_to_test" == "ynh_restore" ]; then + # Restore all backuped files + ynh_restore +else + # Restore www directory + ynh_restore_file /var/www/$app -# Restore nginx conf -ynh_restore_file /etc/nginx/conf.d/$domain.d/$app.conf + # Restore nginx conf + ynh_restore_file /etc/nginx/conf.d/$domain.d/$app.conf -# Restore custom file (with different source/destinations) -ynh_restore_file /etc/yoloswag /etc/importantfile + # Restore custom file (with different source/destinations) + ynh_restore_file /etc/yoloswag /etc/importantfile +fi # Restore the database db_user=$app