5
0
mirror of git://git.proxmox.com/git/pve-storage.git synced 2024-12-22 13:34:16 +03:00

postinst: remove old file if new one is identical

Suggested-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
This commit is contained in:
Fabian Ebner 2021-06-17 10:58:26 +02:00 committed by Fabian Grünbichler
parent cd48e1632c
commit d3c3c114c3

7
debian/postinst vendored
View 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; }