From f2ce62c8b4df24106626db021da0dc3c480ae1a1 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 12 May 2021 08:41:51 +0200 Subject: [PATCH] Fix --- scripts/backup | 3 ++- scripts/change_url | 2 +- scripts/install | 1 + scripts/remove | 3 ++- scripts/restore | 5 +++-- scripts/upgrade | 14 ++++++++++---- 6 files changed, 19 insertions(+), 9 deletions(-) diff --git a/scripts/backup b/scripts/backup index 60b4845..9c7fc73 100755 --- a/scripts/backup +++ b/scripts/backup @@ -26,6 +26,7 @@ app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get --app=$app --key=final_path) domain=$(ynh_app_setting_get --app=$app --key=domain) +data_path=$(ynh_app_setting_get --app=$app --key=data_path) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP @@ -54,7 +55,7 @@ ynh_backup --src_path="/etc/logrotate.d/$app" # BACKUP DATADIR DIRECTORY #================================================= -ynh_backup --src_path="/home/yunohost.app/$app" +ynh_backup --src_path="$data_path" #================================================= # BACKUP BINARY diff --git a/scripts/change_url b/scripts/change_url index aac1a25..b1655f3 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -17,7 +17,7 @@ old_domain=$YNH_APP_OLD_DOMAIN old_path=$YNH_APP_OLD_PATH new_domain=$YNH_APP_NEW_DOMAIN -new_path=$YNH_APP_NEW_PATH +new_path="/" app=$YNH_APP_INSTANCE_NAME diff --git a/scripts/install b/scripts/install index a56291a..8d254b7 100755 --- a/scripts/install +++ b/scripts/install @@ -119,6 +119,7 @@ data_path="/home/yunohost.app/${app}" # Create app folders mkdir -p "$data_path" +ynh_app_setting_set --app=$app --key=data_path --value=$data_path #================================================= # CONFIGURE HASTE diff --git a/scripts/remove b/scripts/remove index 8ea90bb..e9b14d8 100755 --- a/scripts/remove +++ b/scripts/remove @@ -18,6 +18,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) final_path=$(ynh_app_setting_get --app=$app --key=final_path) +data_path=$(ynh_app_setting_get --app=$app --key=data_path) #================================================= # STANDARD REMOVE @@ -75,7 +76,7 @@ ynh_secure_remove --file="/usr/bin/$app" # REMOVE DATADIR DIRECTORY #================================================= -ynh_secure_remove --file="/home/yunohost.app/$app" +ynh_secure_remove --file="$data_path" #================================================= # REMOVE NODEJS diff --git a/scripts/restore b/scripts/restore index 8fbcb19..9d68823 100755 --- a/scripts/restore +++ b/scripts/restore @@ -26,6 +26,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) +data_path=$(ynh_app_setting_get --app=$app --key=data_path) #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -72,7 +73,7 @@ ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version # RESTORE VARIOUS FILES #================================================= -ynh_restore_file "/home/yunohost.app/$app" +ynh_restore_file "$data_path" #================================================= # RESTORE BINARY @@ -87,7 +88,7 @@ ynh_restore_file --origin_path="/usr/bin/$app" chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" -chown -R $app: "/home/yunohost.app/$app" +chown -R $app: "$data_path" chmod +x /usr/bin/$app #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index e6e8bd6..e8e797d 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -19,6 +19,7 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path_url) final_path=$(ynh_app_setting_get --app=$app --key=final_path) port=$(ynh_app_setting_get --app=$app --key=port) +data_path=$(ynh_app_setting_get --app=$app --key=data_path) #================================================= # CHECK VERSION @@ -37,6 +38,13 @@ if [ -z "$final_path" ]; then ynh_app_setting_set --app=$app --key=final_path --value=$final_path fi +# If data_path doesn't exist, create it +if [ -z "$data_path" ]; then + data_path="/home/yunohost.app/${app}" + mkdir -p "$data_path" + ynh_app_setting_set --app=$app --key=data_path --value=$data_path +fi + # Cleaning legacy permissions if ynh_legacy_permissions_exists; then ynh_legacy_permissions_delete_all @@ -135,7 +143,6 @@ ynh_add_systemd_config #================================================= # Define app's data directory -data_path="/home/yunohost.app/$app" ynh_add_config --template="../conf/config.js" --destination="$final_path/config.js" # Replace ajax.googleapis by local file @@ -147,9 +154,8 @@ ynh_replace_string --match_string="https://ajax.googleapis.com/ajax/libs/jquery/ # UPGRADE HASTE BINARY #================================================= -ynh_replace_string --match_string="__YNH_HASTE_URL__" --replace_string="${domain}${path_url}" --target_file="../conf/haste.sh" - -cp ../conf/haste.sh /usr/bin/$app +haste_url="${domain}${path_url}" +ynh_add_config --template="../conf/haste.sh" --destination="/usr/bin/$app" #================================================= # GENERIC FINALIZATION