[Pkg-nagios-changes] [pkg-check-mk] 02/02: migrate multisite conffile, fix logic

Matt Taggart taggart at moszumanska.debian.org
Wed Jun 24 18:10:56 UTC 2015


This is an automated email from the git hooks/post-receive script.

taggart pushed a commit to branch master
in repository pkg-check-mk.

commit 8228d4a8e310606e3e430cc9a6ac90c01d7ecd5a
Author: Matt Taggart <taggart at debian.org>
Date:   Wed Jun 24 11:02:59 2015 -0700

    migrate multisite conffile, fix logic
    
    The current logic for migrating the multisite apache conffile had a
    corner case that was hit when upgrading from very old releases, adjust
    to cover that case and also migrate the conffile in that old case
---
 debian/check-mk-config-icinga.postinst  | 23 +++++++++++++++++++++--
 debian/check-mk-config-icinga.postrm    | 10 ++++++++++
 debian/check-mk-config-nagios3.postinst | 22 +++++++++++++++++++++-
 debian/check-mk-config-nagios3.postrm   | 10 ++++++++++
 4 files changed, 62 insertions(+), 3 deletions(-)

diff --git a/debian/check-mk-config-icinga.postinst b/debian/check-mk-config-icinga.postinst
index 459742c..3e8ccbf 100644
--- a/debian/check-mk-config-icinga.postinst
+++ b/debian/check-mk-config-icinga.postinst
@@ -21,6 +21,16 @@ dpkg-maintscript-helper mv_conffile \
     /etc/icinga/objects/check_mk/check_mk_templates.cfg \
     1.1.10-2 -- "$@"
 
+# older releases (1.1.12p7-1 at least) delivered the multisite conffile to
+# /etc/apache2/conf.d. If it exists we need to move it to conf-available
+# once it's moved then the code below will setup the conf.d symlink.
+# This code wasn't in place until 1.2.6p4-2, so we need to check everything
+# before that.
+dpkg-maintscript-helper mv_conffile \
+    /etc/apache2/conf.d/check_mk_multisite.cfg \
+    /etc/apache2/conf-available/check_mk_multisite.cfg \
+    1.2.6p4-2 -- "$@"
+
 if [ -e '/etc/icinga/objects/check_mk_objects.cfg' ];
 then
     echo 'Migrate /etc/icinga/objects/check_mk_objects.cfg to /etc/icinga/objects/check_mk/check_mk_objects.cfg'
@@ -48,9 +58,18 @@ case "$1" in
                         . /usr/share/apache2/apache2-maintscript-helper
                         apache2_invoke enconf $CONF || exit $?
                 elif [ "$COMMON_STATE" = "installed" ] || [ "$COMMON_STATE" = "unpacked" ] ; then
-                        [ -d /etc/apache2/conf.d/ ] && [ ! -L /etc/apache2/conf.d/$CONF.conf ] && ln -s ../conf-available/$CONF.conf /etc/apache2/conf.d/$CONF.conf
+                        if [ -d /etc/apache2/conf.d/ ]; then
+                                if [ -L /etc/apache2/conf.d/$CONF.conf ]; then
+                                        # it's a symlink, all is well
+                                elif [ -e /etc/apache2/conf.d/$CONF.conf ]; then
+                                        # it's not a symlink, error
+                                        echo "ERROR: /etc/apache2/conf.d/$CONF.conf is not a symlink, please investigate" 1>&2
+                                else
+                                        # we need to create the symlink
+                                        ln -s ../conf-available/$CONF.conf /etc/apache2/conf.d/$CONF.conf
+                                fi
+                        fi
                 fi
-
     ;;
   abort-upgrade|abort-remove|abort-deconfigure)
     ;;
diff --git a/debian/check-mk-config-icinga.postrm b/debian/check-mk-config-icinga.postrm
index 071d8bf..5d46ec3 100644
--- a/debian/check-mk-config-icinga.postrm
+++ b/debian/check-mk-config-icinga.postrm
@@ -7,6 +7,16 @@ dpkg-maintscript-helper mv_conffile \
     /etc/icinga/objects/check_mk/check_mk_templates.cfg \
     1.1.10-2 -- "$@"
 
+# older releases (1.1.12p7-1 at least) delivered the multisite conffile to
+# /etc/apache2/conf.d. If it exists we need to move it to conf-available
+# once it's moved then the code below will setup the conf.d symlink.
+# This code wasn't in place until 1.2.6p4-2, so we need to check everything
+# before that.
+dpkg-maintscript-helper mv_conffile \
+    /etc/apache2/conf.d/check_mk_multisite.cfg \
+    /etc/apache2/conf-available/check_mk_multisite.cfg \
+    1.2.6p4-2 -- "$@"
+
 if [ "$1" = "remove" ] || [ "$1" = "purge" ] ; then
         CONF="check-mk-multisite"
         COMMON_STATE=$(dpkg-query -f '${Status}' -W 'apache2.2-common' 2>/dev/null | awk '{print $3}' || true)
diff --git a/debian/check-mk-config-nagios3.postinst b/debian/check-mk-config-nagios3.postinst
index 5bc6769..a3a0e1e 100644
--- a/debian/check-mk-config-nagios3.postinst
+++ b/debian/check-mk-config-nagios3.postinst
@@ -21,6 +21,16 @@ dpkg-maintscript-helper mv_conffile \
     /etc/nagios3/conf.d/check_mk/check_mk_templates.cfg \
     1.1.10-2 -- "$@"
 
+# older releases (1.1.12p7-1 at least) delivered the multisite conffile to
+# /etc/apache2/conf.d. If it exists we need to move it to conf-available
+# once it's moved then the code below will setup the conf.d symlink.
+# This code wasn't in place until 1.2.6p4-2, so we need to check everything
+# before that.
+dpkg-maintscript-helper mv_conffile \
+    /etc/apache2/conf.d/check_mk_multisite.cfg \
+    /etc/apache2/conf-available/check_mk_multisite.cfg \
+    1.2.6p4-2 -- "$@"
+
 if [ -e '/etc/nagios3/conf.d/check_mk_objects.cfg' ];
 then
     echo 'Migrate /etc/nagios3/conf.d/check_mk_objects.cfg to /etc/nagios3/conf.d/objects/check_mk/check_mk_objects.cfg'
@@ -48,7 +58,17 @@ case "$1" in
                         . /usr/share/apache2/apache2-maintscript-helper
                         apache2_invoke enconf $CONF || exit $?
                 elif [ "$COMMON_STATE" = "installed" ] || [ "$COMMON_STATE" = "unpacked" ] ; then
-                        [ -d /etc/apache2/conf.d/ ] && [ ! -L /etc/apache2/conf.d/$CONF.conf ] && ln -s ../conf-available/$CONF.conf /etc/apache2/conf.d/$CONF.conf
+                        if [ -d /etc/apache2/conf.d/ ]; then
+                                if [ -L /etc/apache2/conf.d/$CONF.conf ]; then
+                                        # it's a symlink, all is well
+                                elif [ -e /etc/apache2/conf.d/$CONF.conf ]; then
+                                        # it's not a symlink, error
+                                        echo "ERROR: /etc/apache2/conf.d/$CONF.conf is not a symlink, please investigate" 1>&2
+                                else
+                                        # we need to create the symlink
+                                        ln -s ../conf-available/$CONF.conf /etc/apache2/conf.d/$CONF.conf
+                                fi
+                        fi
                 fi
     ;;
   abort-upgrade|abort-remove|abort-deconfigure)
diff --git a/debian/check-mk-config-nagios3.postrm b/debian/check-mk-config-nagios3.postrm
index 92883b3..1bfd02e 100644
--- a/debian/check-mk-config-nagios3.postrm
+++ b/debian/check-mk-config-nagios3.postrm
@@ -7,6 +7,16 @@ dpkg-maintscript-helper mv_conffile \
     /etc/nagios3/conf.d/check_mk/check_mk_templates.cfg \
     1.1.10-2 -- "$@"
 
+# older releases (1.1.12p7-1 at least) delivered the multisite conffile to
+# /etc/apache2/conf.d. If it exists we need to move it to conf-available
+# once it's moved then the code below will setup the conf.d symlink.
+# This code wasn't in place until 1.2.6p4-2, so we need to check everything
+# before that.
+dpkg-maintscript-helper mv_conffile \
+    /etc/apache2/conf.d/check_mk_multisite.cfg \
+    /etc/apache2/conf-available/check_mk_multisite.cfg \
+    1.2.6p4-2 -- "$@"
+
 if [ "$1" = "remove" ] || [ "$1" = "purge" ] ; then
         CONF="check-mk-multisite"
         COMMON_STATE=$(dpkg-query -f '${Status}' -W 'apache2.2-common' 2>/dev/null | awk '{print $3}' || true)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-nagios/pkg-check-mk.git



More information about the Pkg-nagios-changes mailing list