[pve-devel] applied: [PATCH storage 2/2] postinst: remove old file if new one is identical
Fabian Grünbichler
f.gruenbichler at proxmox.com
Thu Jun 17 11:14:00 CEST 2021
On June 17, 2021 10:58 am, Fabian Ebner wrote:
> Suggested-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
> Signed-off-by: Fabian Ebner <f.ebner at 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 at lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
>
>
>
More information about the pve-devel
mailing list