From 214d1ce8fc14b2c1afb7a7852574d6853e9c5be0 Mon Sep 17 00:00:00 2001 From: Josue-T Date: Sun, 7 Apr 2019 11:27:38 +0200 Subject: [PATCH 1/3] Add support in restore script of ynh_setup_source Actually the path to the app.src file in the helper ynh_setup_source work only in install and upgrade script. Add the support for restore script. --- data/helpers.d/utils | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/data/helpers.d/utils b/data/helpers.d/utils index 5f5e61015..40e6fe045 100644 --- a/data/helpers.d/utils +++ b/data/helpers.d/utils @@ -166,15 +166,22 @@ ynh_setup_source () { ynh_handle_getopts_args "$@" source_id="${source_id:-app}" # If the argument is not given, source_id equals "app" + local src_file_path="$YNH_CWD/../conf/${src_id}.src" + # In case of restore script the src file is in an other path. + # So try to use the restore path if the general path point to no file. + if [[ ! -e "$src_file_path" ]]; then + src_file_path="$YNH_CWD/../settings/conf/${src_id}.src" + fi + # Load value from configuration file (see above for a small doc about this file # format) - local src_url=$(grep 'SOURCE_URL=' "$YNH_CWD/../conf/${source_id}.src" | cut -d= -f2-) - local src_sum=$(grep 'SOURCE_SUM=' "$YNH_CWD/../conf/${source_id}.src" | cut -d= -f2-) - local src_sumprg=$(grep 'SOURCE_SUM_PRG=' "$YNH_CWD/../conf/${source_id}.src" | cut -d= -f2-) - local src_format=$(grep 'SOURCE_FORMAT=' "$YNH_CWD/../conf/${source_id}.src" | cut -d= -f2-) - local src_extract=$(grep 'SOURCE_EXTRACT=' "$YNH_CWD/../conf/${source_id}.src" | cut -d= -f2-) - local src_in_subdir=$(grep 'SOURCE_IN_SUBDIR=' "$YNH_CWD/../conf/${source_id}.src" | cut -d= -f2-) - local src_filename=$(grep 'SOURCE_FILENAME=' "$YNH_CWD/../conf/${source_id}.src" | cut -d= -f2-) + local src_url=$(grep 'SOURCE_URL=' "$src_file_path" | cut -d= -f2-) + local src_sum=$(grep 'SOURCE_SUM=' "$src_file_path" | cut -d= -f2-) + local src_sumprg=$(grep 'SOURCE_SUM_PRG=' "$src_file_path" | cut -d= -f2-) + local src_format=$(grep 'SOURCE_FORMAT=' "$src_file_path" | cut -d= -f2-) + local src_extract=$(grep 'SOURCE_EXTRACT=' "$src_file_path" | cut -d= -f2-) + local src_in_subdir=$(grep 'SOURCE_IN_SUBDIR=' "$src_file_path" | cut -d= -f2-) + local src_filename=$(grep 'SOURCE_FILENAME=' "$src_file_path" | cut -d= -f2-) # Default value src_sumprg=${src_sumprg:-sha256sum} From e9aed65b0c1e8029d4a7980292bb3b4dd009e43e Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Tue, 9 Apr 2019 19:12:05 +0200 Subject: [PATCH 2/3] [Fix] src_id doesn't exist --- data/helpers.d/utils | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/helpers.d/utils b/data/helpers.d/utils index 40e6fe045..be2972e49 100644 --- a/data/helpers.d/utils +++ b/data/helpers.d/utils @@ -166,11 +166,11 @@ ynh_setup_source () { ynh_handle_getopts_args "$@" source_id="${source_id:-app}" # If the argument is not given, source_id equals "app" - local src_file_path="$YNH_CWD/../conf/${src_id}.src" + local src_file_path="$YNH_CWD/../conf/${source_id}.src" # In case of restore script the src file is in an other path. # So try to use the restore path if the general path point to no file. if [[ ! -e "$src_file_path" ]]; then - src_file_path="$YNH_CWD/../settings/conf/${src_id}.src" + src_file_path="$YNH_CWD/../settings/conf/${source_id}.src" fi # Load value from configuration file (see above for a small doc about this file From 55f8ffb2c9f3f5b96d2e6e5e020c9f3350ba31bb Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Tue, 9 Apr 2019 19:13:14 +0200 Subject: [PATCH 3/3] [enh] Double brackets not needed --- data/helpers.d/utils | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/helpers.d/utils b/data/helpers.d/utils index be2972e49..7d943c9df 100644 --- a/data/helpers.d/utils +++ b/data/helpers.d/utils @@ -169,7 +169,7 @@ ynh_setup_source () { local src_file_path="$YNH_CWD/../conf/${source_id}.src" # In case of restore script the src file is in an other path. # So try to use the restore path if the general path point to no file. - if [[ ! -e "$src_file_path" ]]; then + if [ ! -e "$src_file_path" ]; then src_file_path="$YNH_CWD/../settings/conf/${source_id}.src" fi