]> git.proxmox.com Git - pve-storage.git/commitdiff
postinst: move cifs credential files into subdirectory upon update
authorFabian Ebner <f.ebner@proxmox.com>
Wed, 16 Jun 2021 07:26:56 +0000 (09:26 +0200)
committerFabian Grünbichler <f.gruenbichler@proxmox.com>
Wed, 16 Jun 2021 11:20:35 +0000 (13:20 +0200)
and drop the compat code.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
PVE/Storage/CIFSPlugin.pm
debian/postinst [new file with mode: 0644]

index be06cc761e4e7244358ce72379ef50d7e2a93edd..9d69b01f16b12697a810ba4eb8c1d1c098d74954 100644 (file)
@@ -59,9 +59,6 @@ sub get_cred_file {
 
     if (-e $cred_file) {
        return $cred_file;
-    } elsif (-e "/etc/pve/priv/${storeid}.cred") {
-       # FIXME: remove fallback with 7.0 by doing a rename on upgrade from 6.x
-       return "/etc/pve/priv/${storeid}.cred";
     }
     return undef;
 }
diff --git a/debian/postinst b/debian/postinst
new file mode 100644 (file)
index 0000000..0630d49
--- /dev/null
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+set -e
+
+#DEBHELPER#
+
+case "$1" in
+  configure)
+    if test -n "$2"; then
+
+        # TODO: remove once PVE 8.0 is released
+        if dpkg --compare-versions "$2" 'lt' '7.0-3'; then
+            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)
+                    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)
+                    fi
+                fi
+            done
+        fi
+    fi
+    ;;
+
+esac
+
+exit 0