Enable new configuration file on upgrade
[manu/mod-proxy-html.git] / debian / postinst
1 #! /bin/sh
2 # postinst script for libapache2-mod-proxy-html
3 #
4 # see: dh_installdeb(1)
5
6 set -e
7
8 # summary of how this script can be called:
9 #        * <postinst> `configure' <most-recently-configured-version>
10 #        * <old-postinst> `abort-upgrade' <new version>
11 #        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
12 #          <new-version>
13 #        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
14 #          <failed-install-package> <version> `removing'
15 #          <conflicting-package> <version>
16 # for details, see http://www.debian.org/doc/debian-policy/ or
17 # the debian-policy package
18 #
19
20 reload_apache()
21 {
22     if apache2ctl configtest 2>/dev/null; then
23         invoke-rc.d apache2 force-reload || true
24     else
25         echo "Your apache2 configuration is broken, so we're not restarting it for you."
26     fi
27 }
28
29
30 case "$1" in
31     configure)
32         # Reload the module on upgrade if enabled
33         if [ -n "$2" ]; then
34             if [ -e /etc/apache2/mods-enabled/proxy_html.load ]; then
35                 # We must reenable this module to enable the new configuration file
36                 if [ dpkg --compare-versions "3.0.0-1" lt "$2" ]; then
37                     a2dismod proxy_html >/dev/null || true 
38                     a2enmod proxy_html >/dev/null || true 
39                 fi
40                 reload_apache
41             fi
42         else 
43         # Enable the module
44         if [ -e /etc/apache2/apache2.conf ]; then
45             a2enmod proxy_html >/dev/null || true
46             reload_apache
47         fi
48     fi
49     ;;
50
51     abort-upgrade|abort-remove|abort-deconfigure)
52
53     ;;
54
55     *)
56         echo "postinst called with unknown argument \`$1'" >&2
57         exit 1
58     ;;
59 esac
60
61 # dh_installdeb will replace this with shell code automatically
62 # generated by other debhelper scripts.
63
64 #DEBHELPER#
65
66 exit 0
67
68