From c6389c112396089a89f2fb15099492422612094d Mon Sep 17 00:00:00 2001 From: tituspijean Date: Tue, 7 May 2024 21:16:37 +0200 Subject: [PATCH] Fix packaging v2 migration (#18) --- conf/nginx.conf | 2 +- manifest.toml | 1 - scripts/install | 2 +- scripts/upgrade | 9 +++++++++ tests.toml | 7 +++++-- 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 4195917..b6197c4 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -10,7 +10,7 @@ location __PATH__ { proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $http_connection; - # Allow the Radarr API + # Allow the Sonarr API location __PATH__/api { auth_request off; proxy_pass http://127.0.0.1:__PORT____PATH__/api; diff --git a/manifest.toml b/manifest.toml index 55aa865..065b9bf 100644 --- a/manifest.toml +++ b/manifest.toml @@ -57,7 +57,6 @@ ram.runtime = "50M" [resources.install_dir] [resources.data_dir] - dir = "/var/lib/__APP__" [resources.ports] diff --git a/scripts/install b/scripts/install index 1c52387..52b6579 100755 --- a/scripts/install +++ b/scripts/install @@ -32,7 +32,7 @@ chown -R "$app:$app" "$install_dir" #================================================= # ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Configuring Radarr..." --weight=2 +ynh_script_progression --message="Configuring Sonarr..." --weight=2 mkdir -p "/var/log/$app" ln -s "/var/log/$app" "$data_dir/logs" diff --git a/scripts/upgrade b/scripts/upgrade index 9950335..1e9125e 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -23,6 +23,15 @@ ynh_systemd_action --service_name="$app" --action="stop" --log_path="systemd" #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 +# Fixes specific to packaging v2 migration +if ynh_compare_current_package_version --comparison le --version 3.0.6.1196~ynh3 +then + # In packaging v1, final_path=/var/lib/$app but actually held the data. No data_dir was defined + # Upon migration, the core moves /var/lib/$app to /var/www/$app, so let's move it to the data_dir + ynh_print_warn --message="Fix manivest v2 migration: moving contents of $install_dir to $data_dir... (this may take a while)" + mv $install_dir/* $data_dir +fi + if [ ! -L "$data_dir/logs" ]; then ynh_secure_remove --file="$data_dir/logs" ln -s "/var/log/$app" "$data_dir/logs" diff --git a/tests.toml b/tests.toml index eecb3cf..466afa7 100644 --- a/tests.toml +++ b/tests.toml @@ -8,8 +8,11 @@ test_format = 1.0 # Default args to use for install # ------------------------------- - args.admin="john" - # ------------ # Tests to run # ------------ + + test_upgrade_from.768c1ce.name = "Upgrade from 3.0.6.1196~ynh3 (packaging v1)" + test_upgrade_from.768c1ce.args.domain = "domain.tld" + test_upgrade_from.768c1ce.args.path = "/sonarr" + test_upgrade_from.768c1ce.args.admin = "package_checker"