From 939193edabe0436ed10c60b2f6794a7e7b1012f6 Mon Sep 17 00:00:00 2001 From: Jeremy Vagnet Date: Thu, 23 Apr 2020 16:34:45 +0200 Subject: [PATCH 1/5] Remove old generated files before copying the new ones when upgrading --- scripts/upgrade | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index 3e2da5a..c65510b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -139,6 +139,11 @@ then sudo -u "$app" env PATH="$PATH" cargo build --features sqlite --release popd + # Remove old generated files before copying the new ones + ynh_secure_remove --file="$final_path/live/build" + ynh_secure_remove --file="$final_path/live/deps" + ynh_secure_remove --file="$final_path/live/.fingerprint" + # Install bitwarden_rs cp -a "$final_path"/build/target/release/. "$final_path"/live/. From d1b3e2d01ff08ce6e5083d77e2ef7d85c2dbd7a8 Mon Sep 17 00:00:00 2001 From: Jeremy Vagnet Date: Thu, 23 Apr 2020 16:36:27 +0200 Subject: [PATCH 2/5] fix indentation --- scripts/upgrade | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index c65510b..b50bc58 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -140,9 +140,9 @@ then popd # Remove old generated files before copying the new ones - ynh_secure_remove --file="$final_path/live/build" - ynh_secure_remove --file="$final_path/live/deps" - ynh_secure_remove --file="$final_path/live/.fingerprint" + ynh_secure_remove --file="$final_path/live/build" + ynh_secure_remove --file="$final_path/live/deps" + ynh_secure_remove --file="$final_path/live/.fingerprint" # Install bitwarden_rs cp -a "$final_path"/build/target/release/. "$final_path"/live/. From 795b6a85dbf2f0726c4e1b7ba6355b36141ab621 Mon Sep 17 00:00:00 2001 From: Jeremy Vagnet Date: Sun, 26 Apr 2020 13:56:38 +0200 Subject: [PATCH 3/5] backup config file before upgrade, and restore it when it's done --- scripts/upgrade | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index b50bc58..2f4df2f 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -139,6 +139,12 @@ then sudo -u "$app" env PATH="$PATH" cargo build --features sqlite --release popd + # Backup config file + tmpdir="$(mktemp -d)" + if [ -f $final_path/live/bitwarden_rs.env ]; then + cp -af "$final_path/live/bitwarden_rs.env" "$tmpdir/." + fi + # Remove old generated files before copying the new ones ynh_secure_remove --file="$final_path/live/build" ynh_secure_remove --file="$final_path/live/deps" @@ -147,6 +153,12 @@ then # Install bitwarden_rs cp -a "$final_path"/build/target/release/. "$final_path"/live/. + # Restore config file + if [ -f $tmpdir/bitwarden_rs.env ]; then + cp -af "$tmpdir/bitwarden_rs.env" "$final_path/live/." + fi + ynh_secure_remove --file="$tmpdir" + # Remove build files and rustup ynh_secure_remove --file="$final_path/build" ynh_secure_remove --file="$final_path/.cargo" From 88ba5261a1f0598a96a96091f159c60acf691ab5 Mon Sep 17 00:00:00 2001 From: Jeremy Vagnet Date: Mon, 27 Apr 2020 12:16:30 +0200 Subject: [PATCH 4/5] revert useless backup/restore operation --- scripts/upgrade | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 2f4df2f..89d0cc8 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -139,12 +139,6 @@ then sudo -u "$app" env PATH="$PATH" cargo build --features sqlite --release popd - # Backup config file - tmpdir="$(mktemp -d)" - if [ -f $final_path/live/bitwarden_rs.env ]; then - cp -af "$final_path/live/bitwarden_rs.env" "$tmpdir/." - fi - # Remove old generated files before copying the new ones ynh_secure_remove --file="$final_path/live/build" ynh_secure_remove --file="$final_path/live/deps" @@ -153,13 +147,7 @@ then # Install bitwarden_rs cp -a "$final_path"/build/target/release/. "$final_path"/live/. - # Restore config file - if [ -f $tmpdir/bitwarden_rs.env ]; then - cp -af "$tmpdir/bitwarden_rs.env" "$final_path/live/." - fi - ynh_secure_remove --file="$tmpdir" - - # Remove build files and rustup + # Remove build files and rustup ynh_secure_remove --file="$final_path/build" ynh_secure_remove --file="$final_path/.cargo" ynh_secure_remove --file="$final_path/.rustup" From d195d7ba4d5d9740947daedc67fd404ca342ecfb Mon Sep 17 00:00:00 2001 From: Jeremy Vagnet Date: Mon, 27 Apr 2020 12:18:31 +0200 Subject: [PATCH 5/5] enforce copy --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 89d0cc8..499e5b8 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -145,7 +145,7 @@ then ynh_secure_remove --file="$final_path/live/.fingerprint" # Install bitwarden_rs - cp -a "$final_path"/build/target/release/. "$final_path"/live/. + cp -af "$final_path"/build/target/release/. "$final_path"/live/. # Remove build files and rustup ynh_secure_remove --file="$final_path/build"