From 97ca65f3aa50b4d6b83be8e01aa152699da5a749 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 4 Jan 2021 00:58:31 +0100 Subject: [PATCH] Deprecated practice of using to fetch script arguments --- backup_recommended_app_ynh/scripts/backup | 12 ++---------- backup_recommended_app_ynh/scripts/restore | 15 +++++---------- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/backup_recommended_app_ynh/scripts/backup b/backup_recommended_app_ynh/scripts/backup index 19894f8..f22a525 100644 --- a/backup_recommended_app_ynh/scripts/backup +++ b/backup_recommended_app_ynh/scripts/backup @@ -1,27 +1,19 @@ #!/bin/bash set -eu -# Source app helpers source /usr/share/yunohost/helpers -# Retrieve parameters - -# Backup directory (location dedicated to the app) -backup_dir=$1 -# App instance name -app=$2 +app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) # Backup the app files -#sudo mkdir -p "${backup_dir}/var/www" ynh_backup /var/www/$app # Backup the conf files -#sudo mkdir -p "${backup_dir}/conf" ynh_backup /etc/nginx/conf.d/$domain.d/$app.conf # Backup the custom file to a different location ynh_backup /etc/importantfile /etc/yoloswag # Backup db -ynh_mysql_dump_db $app > "${backup_dir}/db.sql" +ynh_mysql_dump_db $app > db.sql diff --git a/backup_recommended_app_ynh/scripts/restore b/backup_recommended_app_ynh/scripts/restore index ffd4c86..b31401a 100644 --- a/backup_recommended_app_ynh/scripts/restore +++ b/backup_recommended_app_ynh/scripts/restore @@ -1,13 +1,9 @@ #!/bin/bash set -eu -# Source app helpers source /usr/share/yunohost/helpers -restore_dir=$1 -app=$2 - -# Get old parameter of the app +app=$YNH_APP_INSTANCE_NAME 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) @@ -29,10 +25,9 @@ fi # Restore the database db_user=$app +db_name=$app db_pwd=$(ynh_app_setting_get $app mysqlpwd) -ynh_mysql_create_db $db_user $db_user $db_pwd -sudo su -c "mysql -u $db_user -p$db_pwd $app < ${restore_dir}/db.sql" +ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name --db_pwd=$db_pwd +ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name < ./db.sql -# Reload/reconfigure services -sudo service nginx reload -sudo yunohost app ssowatconf +systemctl reload nginx