public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Subject: [pve-devel] applied: [PATCH storage 2/2] postinst: remove old file if new one is identical
Date: Thu, 17 Jun 2021 11:14:00 +0200	[thread overview]
Message-ID: <1623921227.q6yt88zydn.astroid@nora.none> (raw)
In-Reply-To: <20210617085826.136788-2-f.ebner@proxmox.com>

On June 17, 2021 10:58 am, Fabian Ebner wrote:
> 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
> 
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
> 
> 
> 




  reply	other threads:[~2021-06-17  9:14 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 ` [pve-devel] [PATCH storage 2/2] postinst: remove old file if new one is identical Fabian Ebner
2021-06-17  9:14   ` Fabian Grünbichler [this message]
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=1623921227.q6yt88zydn.astroid@nora.none \
    --to=f.gruenbichler@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