]> git.proxmox.com Git - pve-storage.git/commitdiff
postinst: avoid spawning subshell
authorFabian Ebner <f.ebner@proxmox.com>
Thu, 17 Jun 2021 08:58:25 +0000 (10:58 +0200)
committerFabian Grünbichler <f.gruenbichler@proxmox.com>
Thu, 17 Jun 2021 09:12:15 +0000 (11:12 +0200)
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

index 0630d496e11204e51300e16b46841435802a00ef..963ad0637950a1b73281bf18eb75e490c8b2a2ac 100644 (file)
@@ -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