]> git.proxmox.com Git - pve-storage.git/commitdiff
postinst: remove old file if new one is identical
authorFabian Ebner <f.ebner@proxmox.com>
Thu, 17 Jun 2021 08:58:26 +0000 (10:58 +0200)
committerFabian Grünbichler <f.gruenbichler@proxmox.com>
Thu, 17 Jun 2021 09:12:15 +0000 (11:12 +0200)
Suggested-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
debian/postinst

index 963ad0637950a1b73281bf18eb75e490c8b2a2ac..9dbb3b92addb716a0a568b793220cb02a95f865a 100644 (file)
@@ -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; }