[Pkg-nagios-changes] [pkg-nagvis] 07/08: Implemented Apache 2.4 support, with moving conf file to /etc/nagvis

Markus Frosch lazyfrosch-guest at moszumanska.debian.org
Thu Dec 12 19:51:12 UTC 2013


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

lazyfrosch-guest pushed a commit to branch master
in repository pkg-nagvis.

commit 4e45ce0f953fe6ca547a259bb62a065241011f9d
Author: Markus Frosch <markus at lazyfrosch.de>
Date:   Thu Dec 12 20:48:54 2013 +0100

    Implemented Apache 2.4 support, with moving conf file to /etc/nagvis
    
    Closes: #669819
---
 debian/control                  |  1 +
 debian/nagvis.links             |  1 +
 debian/nagvis.lintian-overrides |  6 +++++
 debian/nagvis.postinst          | 57 +++++++++++++++++++++++++++++------------
 debian/nagvis.postrm            | 15 +++++++++++
 debian/nagvis.preinst           | 38 +++++++++++++++++++++++++++
 6 files changed, 101 insertions(+), 17 deletions(-)

diff --git a/debian/control b/debian/control
index 970978e..785c4c2 100644
--- a/debian/control
+++ b/debian/control
@@ -13,6 +13,7 @@ Vcs-Browser: http://anonscm.debian.org/git/pkg-nagios/pkg-nagvis.git
 
 Package: nagvis
 Architecture: all
+Pre-Depends: dpkg (>= 1.15.7.2)
 Depends: ${misc:Depends}, php5-common (>= 5.3.0), libapache2-mod-php5, php5-gd, ucf, graphviz, php5-sqlite, php-net-socket, php-gettext, check-mk-livestatus
 Suggests: nagvis-demos
 Description: visualization addon for Nagios or Icinga
diff --git a/debian/nagvis.links b/debian/nagvis.links
index 3cd8d8e..c3f1347 100644
--- a/debian/nagvis.links
+++ b/debian/nagvis.links
@@ -6,3 +6,4 @@
 /usr/share/php/php-gettext /usr/share/nagvis/share/server/core/ext/php-gettext-1.0.9
 /usr/share/nagvis/defaults/nagvis.ini.php-sample /usr/share/doc/nagvis/nagvis.ini.php-sample
 /usr/share/nagvis/defaults/apache2-nagvis.conf-sample /usr/share/doc/nagvis/apache2-nagvis.conf-sample
+etc/nagvis/apache2.conf etc/apache2/conf-available/nagvis.conf
diff --git a/debian/nagvis.lintian-overrides b/debian/nagvis.lintian-overrides
index 15ac89c..ff8caeb 100644
--- a/debian/nagvis.lintian-overrides
+++ b/debian/nagvis.lintian-overrides
@@ -1,3 +1,9 @@
+# ignoring apache2 warning
+# this is actually not a problem, because the handling is backwards compatible
+apache2-reverse-dependency-calls-invoke-rc.d postrm
+apache2-reverse-dependency-calls-wrapper-script postinst a2enmod
+apache2-reverse-dependency-calls-invoke-rc.d postinst
+
 nagvis: file-in-unusual-dir var/cache/nagvis/userfiles/gadgets/gadgets_core.php
 nagvis: file-in-unusual-dir var/cache/nagvis/userfiles/gadgets/std_bar.php
 nagvis: file-in-unusual-dir var/cache/nagvis/userfiles/gadgets/std_html_bar.php
diff --git a/debian/nagvis.postinst b/debian/nagvis.postinst
index 6512d9f..dc0ba78 100644
--- a/debian/nagvis.postinst
+++ b/debian/nagvis.postinst
@@ -17,7 +17,6 @@ set -e
 # for details, see http://www.debian.org/doc/debian-policy/ or
 # the debian-policy package
 
-
 case "$1" in
     configure)
         # Source debconf library.
@@ -45,21 +44,16 @@ case "$1" in
                 ucfr nagvis /etc/nagvis/nagvis.ini.php
                 rm -f "$nagvis_tmp"
                 ## Creating Configuration snipplet for Apache
-		apache_tmp=$(mktemp)
+                apache_tmp=$(mktemp)
                 sed -e "s#@NAGVIS_PATH@#/usr/share/nagvis/share/#g" \
                   -e "s#@NAGVIS_WEB@#/nagvis#g" \
                   -e "s#@NAGIOS_PATH@/etc#/etc/icinga#g" \
                   < /usr/share/nagvis/defaults/apache2-nagvis.conf-sample \
                   > "$apache_tmp"
                 chmod go+r "$apache_tmp"
-                ucf --debconf-ok "$apache_tmp" /etc/apache2/conf.d/nagvis.conf
-                ucfr nagvis /etc/apache2/conf.d/nagvis.conf
+                ucf --debconf-ok "$apache_tmp" /etc/nagvis/apache2.conf
+                ucfr nagvis /etc/nagvis/apache2.conf
                 rm -f "$apache_tmp"
-                # When the use removed the configuration file, we don't
-                # have to reload apache; might confuse users (or even fail)
-                if [ -f /etc/apache2/conf.d/nagvis.conf ] ; then 
-                    invoke-rc.d apache2 reload
-                fi
             ;;
             "nagios")
                 ## Creating Configuration file for Nagvis
@@ -81,26 +75,51 @@ case "$1" in
                 ucfr nagvis /etc/nagvis/nagvis.ini.php
                 rm -f "$nagvis_tmp"
                 ## Creating Configuration snipplet for Apache
-		apache_tmp=$(mktemp)
+                apache_tmp=$(mktemp)
                 sed -e "s#@NAGVIS_PATH@#/usr/share/nagvis/share/#g" \
                   -e "s#@NAGVIS_WEB@#/nagvis#g" \
                   -e "s#@NAGIOS_PATH@/etc#/etc/nagios3#g" \
                   < /usr/share/nagvis/defaults/apache2-nagvis.conf-sample \
                   > "$apache_tmp"
                 chmod go+r "$apache_tmp"
-                ucf --debconf-ok "$apache_tmp" /etc/apache2/conf.d/nagvis.conf
-                ucfr nagvis /etc/apache2/conf.d/nagvis.conf
+                ucf --debconf-ok "$apache_tmp" /etc/nagvis/apache2.conf
+                ucfr nagvis /etc/nagvis/apache2.conf
                 rm -f "$apache_tmp"
-                # When the use removed the configuration file, we don't
-                # have to reload apache; might confuse users (or even fail)
-                if [ -f /etc/apache2/conf.d/nagvis.conf ] ; then 
-                    invoke-rc.d apache2 reload
-                fi
             ;;
             "other")
                  # nothing to be done for others
             ;;
         esac
+
+        # enable apache when file exists and we are on autoconfigure
+        if [ -f /etc/nagvis/apache2.conf ] && ( [ "$MONITORING" = "nagios" ] || [ "$MONITORING" = "icinga" ] ); then
+            echo "enabling Apache2 config..."
+
+            COMMON_STATE=$(dpkg-query -f '${Status}' -W 'apache2.2-common' 2>/dev/null | awk '{print $3}' || true)
+
+            # NEW method for Apache >= 2.4
+            if [ -e /usr/share/apache2/apache2-maintscript-helper ]; then
+                . /usr/share/apache2/apache2-maintscript-helper
+
+                apache2_invoke enmod rewrite
+                apache2_invoke enconf nagvis
+
+                # remove OLD Apache 2.2 link
+                [ -L /etc/apache2/conf.d/nagvis.conf ] && rm /etc/apache2/conf.d/nagvis.conf
+
+            # OLD methods for Apache < 2.4
+            elif [ "$COMMON_STATE" = "installed" ] || [ "$COMMON_STATE" = "unpacked" ] ; then
+                # enable mod rewrite
+                [ -f /etc/apache2/mods-enabled/rewrite.load ] || a2enmod rewrite
+
+                # create symlink if not existing
+                [ -f /etc/apache2/conf.d/nagvis.conf ] || ln -vs ../../nagvis/apache2.conf /etc/apache2/conf.d/nagvis.conf
+
+                # reload webserver
+                [ -x $(which invoke-rc.d) ] && invoke-rc.d apache2 reload
+            fi
+
+        fi
     ;;
 
     abort-upgrade|abort-remove|abort-deconfigure)
@@ -112,6 +131,10 @@ case "$1" in
     ;;
 esac
 
+# move /etc/apache2/conf.d/nagvis.conf to /etc/nagvis/apache2.conf
+dpkg-maintscript-helper mv_conffile \
+    /etc/apache2/conf.d/nagvis.conf /etc/nagvis/apache2.conf "1:1.6.6+dfsg.1-3" nagvis -- "$@"
+
 # dh_installdeb will replace this with shell code automatically
 # generated by other debhelper scripts.
 
diff --git a/debian/nagvis.postrm b/debian/nagvis.postrm
index e25ef16..ad77b28 100644
--- a/debian/nagvis.postrm
+++ b/debian/nagvis.postrm
@@ -18,6 +18,21 @@ set -e
 # for details, see http://www.debian.org/doc/debian-policy/ or
 # the debian-policy package
 
+# move /etc/apache2/conf.d/nagvis.conf to /etc/nagvis/apache2.conf
+dpkg-maintscript-helper mv_conffile \
+    /etc/apache2/conf.d/nagvis.conf /etc/nagvis/apache2.conf "1:1.6.6+dfsg.1-3" nagvis -- "$@"
+
+# Apache2
+if [ -e /usr/share/apache2/apache2-maintscript-helper ] ; then
+    . /usr/share/apache2/apache2-maintscript-helper
+    apache2_invoke disconf nagvis
+fi
+if [ -L /etc/apache2/conf.d/nagvis.conf ]; then
+    # remove link to config
+    rm -f /etc/apache2/conf.d/nagvis.conf
+    # reload webserver
+    [ -x $(which invoke-rc.d) ] && invoke-rc.d apache2 reload || true
+fi
 
 case "$1" in
     purge)
diff --git a/debian/nagvis.preinst b/debian/nagvis.preinst
new file mode 100644
index 0000000..22c0bfd
--- /dev/null
+++ b/debian/nagvis.preinst
@@ -0,0 +1,38 @@
+#!/bin/sh
+# preinst script for nagvis
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <new-preinst> `install'
+#        * <new-preinst> `install' <old-version>
+#        * <new-preinst> `upgrade' <old-version>
+#        * <old-preinst> `abort-upgrade' <new-version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+# move /etc/apache2/conf.d/nagvis.conf to /etc/nagvis/apache2.conf
+dpkg-maintscript-helper mv_conffile \
+    /etc/apache2/conf.d/nagvis.conf /etc/nagvis/apache2.conf "1:1.6.6+dfsg.1-3" nagvis -- "$@"
+
+case "$1" in
+    install|upgrade)
+    ;;
+
+    abort-upgrade)
+    ;;
+
+    *)
+        echo "preinst called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0

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



More information about the Pkg-nagios-changes mailing list