From 3d29f0c1da31fa233b61b93717c36fb8f3488c3e Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Fri, 3 Jun 2011 23:55:47 +0200 Subject: [PATCH] collection4.*: Make Apache configuration configurable using debconf. --- debian/changelog | 4 +- debian/collection4.config | 40 ++++++++++++++++++ debian/collection4.postinst | 82 ++++++++++++++++++++++++++++++++++++ debian/collection4.postrm | 49 +++++++++++++++++++++ debian/collection4.templates | 9 ++++ debian/control | 3 +- debian/po/POTFILES.in | 1 + debian/po/templates.pot | 38 +++++++++++++++++ debian/rules | 2 + 9 files changed, 226 insertions(+), 2 deletions(-) create mode 100644 debian/collection4.config create mode 100644 debian/collection4.postinst create mode 100644 debian/collection4.postrm create mode 100644 debian/collection4.templates create mode 100644 debian/po/POTFILES.in create mode 100644 debian/po/templates.pot diff --git a/debian/changelog b/debian/changelog index d2e2154..0bf4575 100644 --- a/debian/changelog +++ b/debian/changelog @@ -13,5 +13,7 @@ collection4 (4.0.0-1) experimental; urgency=low - Use format 1.0 for now. * debian/apache.conf: - Added configuration for Apache. + * debian/collection4.{config,postinst,postrm,templates}: + - Make Apache configuration configurable using debconf. - -- Sebastian Harl Fri, 03 Jun 2011 23:50:37 +0200 + -- Sebastian Harl Fri, 03 Jun 2011 23:52:51 +0200 diff --git a/debian/collection4.config b/debian/collection4.config new file mode 100644 index 0000000..3d17b79 --- /dev/null +++ b/debian/collection4.config @@ -0,0 +1,40 @@ +#! /bin/sh +# config script for collection4 +# +# 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 collection4/httpd seen + if [ "$RET" = "false" ]; then + db_set collection4/httpd "$default_servers" + fi + + db_input medium collection4/httpd || true + db_go || true + ;; + + *) + echo "config called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +db_stop + +exit 0 + diff --git a/debian/collection4.postinst b/debian/collection4.postinst new file mode 100644 index 0000000..afa35e5 --- /dev/null +++ b/debian/collection4.postinst @@ -0,0 +1,82 @@ +#!/bin/sh +# postinst script for collection4 +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `configure' +# * `abort-upgrade' +# * `abort-remove' `in-favour' +# +# * `abort-remove' +# * `abort-deconfigure' `in-favour' +# `removing' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + +. /usr/share/debconf/confmodule + +configure_apache2() { + a2reload="false" + + if [ -d /etc/apache2/conf.d/ ]; then + if [ ! -e /etc/apache2/conf.d/collection4.conf ]; then + ln -s /etc/collection4/apache.conf /etc/apache2/conf.d/collection4.conf + a2reload="true" + fi + fi + + if [ -d /etc/apache2/mods-enabled ]; then + if [ ! -e /etc/apache2/mods-enabled/fcgid.load -a + -e /etc/apache2/mods-available/fcgid.load ]; then + a2enmod fcgid + a2reload="true" + else if [ ! -e /etc/apache2/mods-enabled/fastcgi.load -a + -e /etc/apache2/mods-available/fastcgi.load ]; then + a2enmod fastcgi + a2reload="true" + fi; fi + fi + + if [ "$a2reload" = "true" ]; then + invoke-rc.d apache2 reload + fi +} + +case "$1" in + configure) + db_get collection4/httpd + http_servers=`echo $RET | sed -e 's/,/ /g'` + + 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) + ;; + + *) + echo "postinst 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 + diff --git a/debian/collection4.postrm b/debian/collection4.postrm new file mode 100644 index 0000000..235cfb9 --- /dev/null +++ b/debian/collection4.postrm @@ -0,0 +1,49 @@ +#!/bin/sh +# postrm script for collection4 +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `remove' +# * `purge' +# * `upgrade' +# * `failed-upgrade' +# * `abort-install' +# * `abort-install' +# * `abort-upgrade' +# * `disappear' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + purge|remove) + if [ -d /etc/apache2/conf.d/ ]; then + if [ -L /etc/apache2/conf.d/collection4.conf ]; then + ls -l /etc/apache2/conf.d/collection4.conf \ + | grep -q /etc/collection4/apache.conf + if [ $? -eq 0 ]; then + rm -f /etc/apache2/conf.d/collection4.conf + fi + fi + fi + ;; + upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) + ;; + + *) + echo "postrm 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 + diff --git a/debian/collection4.templates b/debian/collection4.templates new file mode 100644 index 0000000..50f445f --- /dev/null +++ b/debian/collection4.templates @@ -0,0 +1,9 @@ +Template: collection4/httpd +Type: multiselect +Choices: apache2 +Default: apache2 +_Description: Web servers to configure for collection4: + Please select which web servers should be configured for collection4. + . + If you would prefer to perform configuration manually, leave all + servers unselected. diff --git a/debian/control b/debian/control index c50b2a3..00f13e6 100644 --- a/debian/control +++ b/debian/control @@ -2,7 +2,8 @@ Source: collection4 Section: web Priority: optional Maintainer: Sebastian Harl -Build-Depends: debhelper (>= 7), quilt, autotools-dev, libfcgi-dev, librrd-dev, libyajl-dev, bison +Build-Depends: debhelper (>= 7), po-debconf, quilt, autotools-dev, + libfcgi-dev, librrd-dev, libyajl-dev, bison Standards-Version: 3.9.2 Homepage: http://octo.it/c4/ Vcs-Git: git://git.tokkee.org/pkg-collection4.git diff --git a/debian/po/POTFILES.in b/debian/po/POTFILES.in new file mode 100644 index 0000000..417e3ac --- /dev/null +++ b/debian/po/POTFILES.in @@ -0,0 +1 @@ +[type: gettext/rfc822deb] collection4.templates diff --git a/debian/po/templates.pot b/debian/po/templates.pot new file mode 100644 index 0000000..cc7c59e --- /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: collection4@packages.debian.org\n" +"POT-Creation-Date: 2011-06-03 23:39+0200\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 +#: ../collection4.templates:1001 +msgid "Web servers to configure for collection4:" +msgstr "" + +#. Type: multiselect +#. Description +#: ../collection4.templates:1001 +msgid "Please select which web servers should be configured for collection4." +msgstr "" + +#. Type: multiselect +#. Description +#: ../collection4.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 8e8496b..64b6fb0 100755 --- a/debian/rules +++ b/debian/rules @@ -49,6 +49,7 @@ clean: unpatch [ ! -f Makefile ] || $(MAKE) distclean dh_clean + debconf-updatepo install: build dh_testdir @@ -68,6 +69,7 @@ binary-arch: build install dh_testroot dh_installchangelogs dh_installdocs -a -A AUTHORS README + dh_installdebconf -a dh_link -a dh_strip -a dh_compress -a -- 2.30.2