[pve-devel] [PATCH cluster] build: fix sysctl.d install path

Fabian Grünbichler f.gruenbichler at proxmox.com
Wed Dec 6 20:39:49 CET 2017


and remove the directory before installing the snippet when upgrading
from a broken version (and if the incorrect directory exists).

Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
bump + upload to pve-no-subscription after review and applying!

 debian/install                            |  2 +-
 debian/pve-cluster.preinst                | 34 +++++++++++++++++++++++++++++++
 debian/{sysctl.conf => sysctl.d/pve.conf} |  0
 3 files changed, 35 insertions(+), 1 deletion(-)
 create mode 100644 debian/pve-cluster.preinst
 rename debian/{sysctl.conf => sysctl.d/pve.conf} (100%)

diff --git a/debian/install b/debian/install
index 6498f69..c1ec5ec 100644
--- a/debian/install
+++ b/debian/install
@@ -1 +1 @@
-debian/sysctl.conf etc/sysctl.d/pve.conf
+debian/sysctl.d/pve.conf etc/sysctl.d
diff --git a/debian/pve-cluster.preinst b/debian/pve-cluster.preinst
new file mode 100644
index 0000000..1c3eb87
--- /dev/null
+++ b/debian/pve-cluster.preinst
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+# abort if any command returns an error value 
+set -e
+
+# handle incorrectly installed sysctl.d snippet (pve-cluster 5.0-16 and -17)
+# TODO: remove in PVE 6.0
+function sysctlcleanup {
+  if test -z "$1"; then
+    # no old version, nothing to do
+    true
+  else
+    if dpkg --compare-versions "$1" '<=' '5.0-17'; then
+      # remove directory if it exists
+      # otherwise we can't install our actual pve.conf file
+      if test -d '/etc/sysctl.d/pve.conf'; then
+        rm -rf '/etc/sysctl.d/pve.conf'
+      fi
+    fi
+  fi
+}
+
+case "$1" in
+  upgrade)
+    sysctlcleanup "$2"
+    ;;
+
+  install)
+    sysctlcleanup "$2"
+    ;;
+
+esac
+
+#DEBHELPER#
diff --git a/debian/sysctl.conf b/debian/sysctl.d/pve.conf
similarity index 100%
rename from debian/sysctl.conf
rename to debian/sysctl.d/pve.conf
-- 
2.14.2





More information about the pve-devel mailing list