Code

collection4.*: Make Apache configuration configurable using debconf.
[pkg-collection4.git] / debian / collection4.postinst
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
+