From 2f6ab236a5eb1b843737a9bc2093780e8069f5f6 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Thu, 10 Feb 2011 13:03:39 +0100 Subject: [PATCH] Make Apache2 configuration optional using debconf. Also, use po-debconf for internationalization support. --- debian/changelog | 3 +- debian/control | 3 +- debian/pnp4nagios-web.config | 40 ++++++++++++++++++++++++ debian/pnp4nagios-web.postinst | 55 ++++++++++++++++++++++----------- debian/pnp4nagios-web.templates | 9 ++++++ debian/po/POTFILES.in | 1 + debian/po/templates.pot | 38 +++++++++++++++++++++++ debian/rules | 3 ++ 8 files changed, 132 insertions(+), 20 deletions(-) create mode 100644 debian/pnp4nagios-web.config create mode 100644 debian/pnp4nagios-web.templates create mode 100644 debian/po/POTFILES.in create mode 100644 debian/po/templates.pot diff --git a/debian/changelog b/debian/changelog index 4f0f54f..a7ca00d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -27,5 +27,6 @@ pnp4nagios (0.6.11-1) unstable; urgency=low - pnp4nagios-web: web interface - pnp4nagios: metapackage depending on the other two * debian/watch: mange upstream version to replace ".rc" with "~rc". + * Make Apache2 configuration optional using debconf. - -- Sebastian Harl Wed, 09 Feb 2011 17:22:47 +0100 + -- Sebastian Harl Thu, 10 Feb 2011 13:03:06 +0100 diff --git a/debian/control b/debian/control index 2967297..fb277f6 100644 --- a/debian/control +++ b/debian/control @@ -3,7 +3,8 @@ Section: net Priority: optional Maintainer: Sven Velt Uploaders: Sebastian Harl -Build-Depends: autotools-dev, debhelper (>= 7), rrdtool, librrds-perl, quilt +Build-Depends: autotools-dev, debhelper (>= 7), po-debconf, quilt, + rrdtool, librrds-perl Standards-Version: 3.9.1 Homepage: http://www.pnp4nagios.org/ diff --git a/debian/pnp4nagios-web.config b/debian/pnp4nagios-web.config new file mode 100644 index 0000000..5ecb5d3 --- /dev/null +++ b/debian/pnp4nagios-web.config @@ -0,0 +1,40 @@ +#! /bin/sh +# config script for pnp4nagios-web +# +# see: dh_installdebconf(1) + +set -e + +# summary of how this script can be called: +# * `configure' +# * `configure' +# * `reconfigure' + +. /usr/share/debconf/confmodule + +case "$1" in + configure|reconfigure) + default_servers="" + if test -d /etc/apache2/conf.d; then + default_servers="apache2" + fi + + db_fget pnp4nagios-web/httpd seen + if [ "$RET" = "false" ]; then + db_set pnp4nagios-web/httpd "$default_servers" + fi + + db_input medium pnp4nagios-web/httpd || true + db_go || true + ;; + + *) + echo "config called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +db_stop + +exit 0 + diff --git a/debian/pnp4nagios-web.postinst b/debian/pnp4nagios-web.postinst index d2fd8aa..9e35d76 100644 --- a/debian/pnp4nagios-web.postinst +++ b/debian/pnp4nagios-web.postinst @@ -17,6 +17,8 @@ set -e # for details, see http://www.debian.org/doc/debian-policy/ or # the debian-policy package +. /usr/share/debconf/confmodule + setperm() { user="$1" group="$2" @@ -30,6 +32,28 @@ setperm() { fi } +configure_apache2() { + a2reload="false" + + if [ -d /etc/apache2/conf.d/ ]; then + if [ ! -e /etc/apache2/conf.d/pnp4nagios.conf ]; then + ln -s /etc/pnp4nagios/apache.conf /etc/apache2/conf.d/pnp4nagios.conf + a2reload="true" + fi + fi + + if [ -d /etc/apache2/mods-enabled ]; then + if [ ! -e /etc/apache2/mods-enabled/rewrite.load ]; then + a2enmod rewrite + a2reload="true" + fi + fi + + if [ "$a2reload" = "true" ]; then + invoke-rc.d apache2 reload + fi +} + case "$1" in configure) if ! getent passwd nagios > /dev/null ; then @@ -42,25 +66,20 @@ case "$1" in setperm nagios www-data 750 /var/log/pnp4nagios setperm nagios nagios 750 /var/log/pnp4nagios/stats - a2reload="false" - - if [ -d /etc/apache2/conf.d/ ]; then - if [ ! -e /etc/apache2/conf.d/pnp4nagios.conf ]; then - ln -s /etc/pnp4nagios/apache.conf /etc/apache2/conf.d/pnp4nagios.conf - a2reload="true" - fi - fi - - if [ -d /etc/apache2/mods-enabled ]; then - if [ ! -e /etc/apache2/mods-enabled/rewrite.load ]; then - a2enmod rewrite - a2reload="true" - fi - fi + db_get pnp4nagios-web/httpd + http_servers=`echo $RET | sed -e 's/,/ /g'` - if [ "$a2reload" = "true" ]; then - invoke-rc.d apache2 reload - fi + for httpd in $http_servers; do + case "$httpd" in + apache2) + configure_apache2 + ;; + # WISHLIST: configure other web servers as well + *) + echo "Don't know how to configure web server $httpd" >&2 + ;; + esac + done ;; abort-upgrade|abort-remove|abort-deconfigure) diff --git a/debian/pnp4nagios-web.templates b/debian/pnp4nagios-web.templates new file mode 100644 index 0000000..38aac58 --- /dev/null +++ b/debian/pnp4nagios-web.templates @@ -0,0 +1,9 @@ +Template: pnp4nagios-web/httpd +Type: multiselect +Choices: apache2 +Default: apache2 +_Description: Web servers to configure for PNP4Nagios: + Please select which web servers should be configured for PNP4Nagios. + . + If you would prefer to perform configuration manually, leave all + servers unselected. diff --git a/debian/po/POTFILES.in b/debian/po/POTFILES.in new file mode 100644 index 0000000..02081d5 --- /dev/null +++ b/debian/po/POTFILES.in @@ -0,0 +1 @@ +[type: gettext/rfc822deb] pnp4nagios-web.templates diff --git a/debian/po/templates.pot b/debian/po/templates.pot new file mode 100644 index 0000000..d7a231b --- /dev/null +++ b/debian/po/templates.pot @@ -0,0 +1,38 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: pnp4nagios@packages.debian.org\n" +"POT-Creation-Date: 2011-02-10 12:58+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: multiselect +#. Description +#: ../pnp4nagios-web.templates:1001 +msgid "Web servers to configure for PNP4Nagios:" +msgstr "" + +#. Type: multiselect +#. Description +#: ../pnp4nagios-web.templates:1001 +msgid "Please select which web servers should be configured for PNP4Nagios." +msgstr "" + +#. Type: multiselect +#. Description +#: ../pnp4nagios-web.templates:1001 +msgid "" +"If you would prefer to perform configuration manually, leave all servers " +"unselected." +msgstr "" diff --git a/debian/rules b/debian/rules index 7675dad..3eb49de 100755 --- a/debian/rules +++ b/debian/rules @@ -71,6 +71,7 @@ clean: unpatch [ ! -f Makefile ] || $(MAKE) distclean dh_clean + debconf-updatepo install: build dh_testdir @@ -161,6 +162,7 @@ binary-indep: build install dh_installchangelogs -i ChangeLog dh_installdocs -A -i AUTHORS README debian/README.Debian dh_installexamples -i + dh_installdebconf -i dh_installinit -i dh_installman -i dh_link -i @@ -178,6 +180,7 @@ binary-arch: build install dh_installchangelogs -a ChangeLog dh_installdocs -A -a AUTHORS README debian/README.Debian dh_installexamples -a + dh_installdebconf -a dh_installinit -ppnp4nagios-bin --name=npcd dh_installinit -a -Npnp4nagios-bin dh_installman -a man/npcd.8 -- 2.30.2