From: Fabian Ebner Date: Thu, 17 Jun 2021 08:58:26 +0000 (+0200) Subject: postinst: remove old file if new one is identical X-Git-Url: https://git.proxmox.com/?p=pve-storage.git;a=commitdiff_plain;h=d3c3c114c319666ac08d3bb4e0bf522281cdf2f9 postinst: remove old file if new one is identical Suggested-by: Thomas Lamprecht Signed-off-by: Fabian Ebner --- 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; }