Code

collection4.*: Make Apache configuration configurable using debconf.
authorSebastian Harl <sh@tokkee.org>
Fri, 3 Jun 2011 21:55:47 +0000 (23:55 +0200)
committerSebastian Harl <sh@tokkee.org>
Fri, 3 Jun 2011 21:55:47 +0000 (23:55 +0200)
debian/changelog
debian/collection4.config [new file with mode: 0644]
debian/collection4.postinst [new file with mode: 0644]
debian/collection4.postrm [new file with mode: 0644]
debian/collection4.templates [new file with mode: 0644]
debian/control
debian/po/POTFILES.in [new file with mode: 0644]
debian/po/templates.pot [new file with mode: 0644]
debian/rules

index d2e21546df2ecc198eb99c38c4a909e3c5222139..0bf4575c54dbb0046d9414a4e86733a9e3c7a7c8 100644 (file)
@@ -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 <tokkee@debian.org>  Fri, 03 Jun 2011 23:50:37 +0200
+ -- Sebastian Harl <tokkee@debian.org>  Fri, 03 Jun 2011 23:52:51 +0200
diff --git a/debian/collection4.config b/debian/collection4.config
new file mode 100644 (file)
index 0000000..3d17b79
--- /dev/null
@@ -0,0 +1,40 @@
+#! /bin/sh
+# config script for collection4
+#
+# see: dh_installdebconf(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <preconfigure> `configure' <installed-version>
+#        * <postinst> `configure' <old-version>
+#        * <reconfigure> `reconfigure' <installed-version>
+
+. /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 (file)
index 0000000..afa35e5
--- /dev/null
@@ -0,0 +1,82 @@
+#!/bin/sh
+# postinst script for collection4
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <postinst> `configure' <most-recently-configured-version>
+#        * <old-postinst> `abort-upgrade' <new version>
+#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
+#          <new-version>
+#        * <postinst> `abort-remove'
+#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
+#          <failed-install-package> <version> `removing'
+#          <conflicting-package> <version>
+# 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 (file)
index 0000000..235cfb9
--- /dev/null
@@ -0,0 +1,49 @@
+#!/bin/sh
+# postrm script for collection4
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <postrm> `remove'
+#        * <postrm> `purge'
+#        * <old-postrm> `upgrade' <new-version>
+#        * <new-postrm> `failed-upgrade' <old-version>
+#        * <new-postrm> `abort-install'
+#        * <new-postrm> `abort-install' <old-version>
+#        * <new-postrm> `abort-upgrade' <old-version>
+#        * <disappearer's-postrm> `disappear' <overwriter>
+#          <overwriter-version>
+# 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 (file)
index 0000000..50f445f
--- /dev/null
@@ -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.
index c50b2a3fdec3c7c2e5668c82e7e99618a0498f46..00f13e677e7afa9089946bac74bef5ccba4e0c0b 100644 (file)
@@ -2,7 +2,8 @@ Source: collection4
 Section: web
 Priority: optional
 Maintainer: Sebastian Harl <tokkee@debian.org>
-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 (file)
index 0000000..417e3ac
--- /dev/null
@@ -0,0 +1 @@
+[type: gettext/rfc822deb] collection4.templates
diff --git a/debian/po/templates.pot b/debian/po/templates.pot
new file mode 100644 (file)
index 0000000..cc7c59e
--- /dev/null
@@ -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 <EMAIL@ADDRESS>, 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 <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\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 ""
index 8e8496baafbff0d77a36f262a4b318232948249a..64b6fb0a8847937d64ca755c78f49483118068a3 100755 (executable)
@@ -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