mirror of
https://github.com/YunoHost/test_apps.git
synced 2024-09-03 20:06:29 +02:00
[enh] Add a test for ynh_restore helper
This commit is contained in:
parent
0507ab1aa4
commit
00086a445f
3 changed files with 25 additions and 6 deletions
|
@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue