public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Fabian Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH storage 2/2] postinst: remove old file if new one is identical
Date: Thu, 17 Jun 2021 10:58:26 +0200	[thread overview]
Message-ID: <20210617085826.136788-2-f.ebner@proxmox.com> (raw)
In-Reply-To: <20210617085826.136788-1-f.ebner@proxmox.com>

Suggested-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
 debian/postinst | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/debian/postinst b/debian/postinst
index 963ad06..9dbb3b9 100644
--- a/debian/postinst
+++ b/debian/postinst
@@ -18,7 +18,12 @@ case "$1" in
                     base=$(basename --suffix=".cred" "$file")
                     target="/etc/pve/priv/storage/$base.pw"
                     if [ -f "$target" ]; then
-                        echo "Warning: not renaming $file, because $target already exists!" >&2
+                        if diff "$file" "$target" >&2 > /dev/null; then
+                            echo "Info: removing $file, because it is identical to $target" >&2
+                            rm "$file" || { echo "$warning" && continue; }
+                        else
+                            echo "Warning: not renaming $file, because $target already exists and differs!" >&2
+                        fi
                     else
                         echo "Info: renaming $file to $target" >&2
                         mv "$file" "$target" || { echo "$warning" && continue; }
-- 
2.30.2





  reply	other threads:[~2021-06-17  8:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-17  8:58 [pve-devel] [PATCH storage 1/2] postinst: avoid spawning subshell Fabian Ebner
2021-06-17  8:58 ` Fabian Ebner [this message]
2021-06-17  9:14   ` [pve-devel] applied: [PATCH storage 2/2] postinst: remove old file if new one is identical Fabian Grünbichler
2021-06-17  9:13 ` [pve-devel] applied: [PATCH storage 1/2] postinst: avoid spawning subshell Fabian Grünbichler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210617085826.136788-2-f.ebner@proxmox.com \
    --to=f.ebner@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal