From 8639f6be74799196ac2fe775417d11d1ce6a4b80 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fabian=20Gr=C3=BCnbichler?= Date: Wed, 6 Dec 2017 20:39:49 +0100 Subject: [PATCH] build: fix sysctl.d install path MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- 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.39.2