* [pve-devel] [PATCH storage 1/2] postinst: avoid spawning subshell
@ 2021-06-17 8:58 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:13 ` [pve-devel] applied: [PATCH storage 1/2] postinst: avoid spawning subshell Fabian Grünbichler
0 siblings, 2 replies; 4+ messages in thread
From: Fabian Ebner @ 2021-06-17 8:58 UTC (permalink / raw)
To: pve-devel
which makes the continue not behave as intended.
Reported by shellcheck: SC2106: This [i.e. continue] only exits the subshell
caused by the (..) group
Also factor out long message for readability.
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
debian/postinst | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/debian/postinst b/debian/postinst
index 0630d49..963ad06 100644
--- a/debian/postinst
+++ b/debian/postinst
@@ -10,17 +10,18 @@ case "$1" in
# TODO: remove once PVE 8.0 is released
if dpkg --compare-versions "$2" 'lt' '7.0-3'; then
+ warning="Warning: failed to move old CIFS credential file, cluster not quorate?"
for file in /etc/pve/priv/*.cred; do
if [ -f "$file" ]; then
echo "Info: found CIFS credentials using old path: $file" >&2
- mkdir -p "/etc/pve/priv/storage" || (echo "Warning: failed to move old CIFS credential file, cluster not quorate?" && continue)
+ mkdir -p "/etc/pve/priv/storage" || { echo "$warning" && continue; }
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
else
echo "Info: renaming $file to $target" >&2
- mv "$file" "$target" || (echo "Warning: failed to move old CIFS credential file, cluster not quorate?" && continue)
+ mv "$file" "$target" || { echo "$warning" && continue; }
fi
fi
done
--
2.30.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* [pve-devel] [PATCH storage 2/2] postinst: remove old file if new one is identical
2021-06-17 8:58 [pve-devel] [PATCH storage 1/2] postinst: avoid spawning subshell Fabian Ebner
@ 2021-06-17 8:58 ` Fabian Ebner
2021-06-17 9:14 ` [pve-devel] applied: " Fabian Grünbichler
2021-06-17 9:13 ` [pve-devel] applied: [PATCH storage 1/2] postinst: avoid spawning subshell Fabian Grünbichler
1 sibling, 1 reply; 4+ messages in thread
From: Fabian Ebner @ 2021-06-17 8:58 UTC (permalink / raw)
To: pve-devel
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* [pve-devel] applied: [PATCH storage 2/2] postinst: remove old file if new one is identical
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
0 siblings, 0 replies; 4+ messages in thread
From: Fabian Grünbichler @ 2021-06-17 9:14 UTC (permalink / raw)
To: Proxmox VE development discussion
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
>
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [pve-devel] applied: [PATCH storage 1/2] postinst: avoid spawning subshell
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:13 ` Fabian Grünbichler
1 sibling, 0 replies; 4+ messages in thread
From: Fabian Grünbichler @ 2021-06-17 9:13 UTC (permalink / raw)
To: Proxmox VE development discussion
thanks for catching (serves me right for testing with break initially
and only a single file ;))
On June 17, 2021 10:58 am, Fabian Ebner wrote:
> which makes the continue not behave as intended.
>
> Reported by shellcheck: SC2106: This [i.e. continue] only exits the subshell
> caused by the (..) group
>
> Also factor out long message for readability.
>
> Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
> ---
> debian/postinst | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/debian/postinst b/debian/postinst
> index 0630d49..963ad06 100644
> --- a/debian/postinst
> +++ b/debian/postinst
> @@ -10,17 +10,18 @@ case "$1" in
>
> # TODO: remove once PVE 8.0 is released
> if dpkg --compare-versions "$2" 'lt' '7.0-3'; then
> + warning="Warning: failed to move old CIFS credential file, cluster not quorate?"
> for file in /etc/pve/priv/*.cred; do
> if [ -f "$file" ]; then
> echo "Info: found CIFS credentials using old path: $file" >&2
> - mkdir -p "/etc/pve/priv/storage" || (echo "Warning: failed to move old CIFS credential file, cluster not quorate?" && continue)
> + mkdir -p "/etc/pve/priv/storage" || { echo "$warning" && continue; }
> 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
> else
> echo "Info: renaming $file to $target" >&2
> - mv "$file" "$target" || (echo "Warning: failed to move old CIFS credential file, cluster not quorate?" && continue)
> + mv "$file" "$target" || { echo "$warning" && continue; }
> fi
> fi
> done
> --
> 2.30.2
>
>
>
> _______________________________________________
> pve-devel mailing list
> pve-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
>
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-06-17 9:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [pve-devel] applied: " Fabian Grünbichler
2021-06-17 9:13 ` [pve-devel] applied: [PATCH storage 1/2] postinst: avoid spawning subshell Fabian Grünbichler
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox