2 # postinst script for @OLDPACKAGE@
4 # see: dh_installdeb(1)
7 #set -x # Be verbose, be very verbose.
9 # summary of how this script can be called:
10 # * <postinst> `configure' <most-recently-configured-version>
11 # * <old-postinst> `abort-upgrade' <new version>
12 # * <conflictor's-postinst> `abort-remove' `in-favour' <package>
14 # * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
15 # <failed-install-package> <version> `removing'
16 # <conflicting-package> <version>
17 # for details, see /usr/share/doc/packaging-manual/
19 # quoting from the policy:
20 # Any necessary prompting should almost always be confined to the
21 # post-installation script, and should be protected with a conditional
22 # so that unnecessary prompting doesn't happen if a package's
23 # installation fails and the `postinst' is called with `abort-upgrade',
24 # `abort-remove' or `abort-deconfigure'.
26 . /usr/share/debconf/confmodule
28 #DSFHELPER:handle-mainconffile#
32 if [ -c /dev/urandom ]; then # ...using /dev/urandom when possible
33 sys_session_key=$(dd if=/dev/urandom count=256 bs=1 2> /dev/null | md5sum | cut -b1-32)
34 else # ...or something else if need be.
35 # Last I was told, the Hurd had no /dev/urandom
36 # (Correct me if it has changed)
37 sys_session_key=$(dd if=/dev/random count=256 bs=1 2> /dev/null | md5sum | cut -b1-32)
39 add_onevar_mainconfile sys_session_key $sys_session_key
40 add_onevar_mainconfile sys_show_source 0
41 add_onevar_mainconfile sys_force_login 0
43 if [ -f /usr/bin/cronolog ]; then # this is the preferred location for debian
44 add_onevar_mainconfile cronolog_path /usr/bin/cronolog
45 elif [ -f /usr/sbin/cronolog ]; then # this location is deprecated in debian
46 add_onevar_mainconfile cronolog_path /usr/sbin/cronolog
48 echo "can't find cronolog in usual places" >&2
49 add_onevar_mainconfile cronolog_path /usr/bin/cronolog
52 if [ ! -e /etc/@OLDPACKAGE@/ssl-cert.pem ] || [ ! -e /etc/@OLDPACKAGE@/ssl-cert.key ] ; then
53 # Uh-oh, no SSL cert, let's make sure at least a dummy one exists.
54 if [ ! -e /etc/ssl/certs/ssl-cert-snakeoil.pem ] || [ ! -e /etc/ssl/private/ssl-cert-snakeoil.key ] ; then
55 # What, not even the snakeoil cert is there? Let's generate it
56 make-ssl-cert generate-default-snakeoil
58 # Right. At this point, it should be safe to set the symlinks.
59 ln -s /etc/ssl/certs/ssl-cert-snakeoil.pem /etc/@OLDPACKAGE@/ssl-cert.pem
60 ln -s /etc/ssl/private/ssl-cert-snakeoil.key /etc/@OLDPACKAGE@/ssl-cert.key
61 if grep -q ^sys_use_ssl=false$ /etc/@OLDPACKAGE@/@OLDPACKAGE@.conf \
62 && grep -q ^sys_sslcrt=$ /etc/@OLDPACKAGE@/@OLDPACKAGE@.conf \
63 && grep -q ^sys_sslkey=$ /etc/@OLDPACKAGE@/@OLDPACKAGE@.conf ; then
64 # Okay, previous installations failed to locate SSL certs
65 # and disabled SSL altogether. Let's fix that
66 sed -i -e 's,^sys_use_ssl=false$,sys_use_ssl=true,' /etc/@OLDPACKAGE@/@OLDPACKAGE@.conf
67 sed -i -e 's,^sys_sslcrt=$,sys_sslcrt=/etc/@OLDPACKAGE@/ssl-cert.pem,' /etc/@OLDPACKAGE@/@OLDPACKAGE@.conf
68 sed -i -e 's,^sys_sslkey=$,sys_sslkey=/etc/@OLDPACKAGE@/ssl-cert.key,' /etc/@OLDPACKAGE@/@OLDPACKAGE@.conf
76 touch /var/lib/@OLDPACKAGE@/etc/templates/httpd.vhosts && \
77 chown @OLDPACKAGE@:@OLDPACKAGE@ /var/lib/@OLDPACKAGE@/etc/templates/httpd.vhosts && \
78 /usr/share/@OLDPACKAGE@/bin/create-vhosts.sh --norestart
80 # Enable required modules
81 DEBIAN_FRONTEND=noninteractive a2enmod php5 || true
82 DEBIAN_FRONTEND=noninteractive a2enmod ssl || true
83 DEBIAN_FRONTEND=noninteractive a2enmod env || true
84 DEBIAN_FRONTEND=noninteractive a2enmod vhost_alias || true
85 DEBIAN_FRONTEND=noninteractive a2enmod headers || true
86 DEBIAN_FRONTEND=noninteractive a2enmod rewrite || true
87 DEBIAN_FRONTEND=noninteractive a2enmod proxy || true
88 DEBIAN_FRONTEND=noninteractive a2enmod proxy_http || true
90 # Enable the @FORGENAME@ configuration
91 if [ -e /etc/apache2/conf.d/@OLDPACKAGE@.httpd.conf ] ; then
92 rm -f /etc/apache2/conf.d/@OLDPACKAGE@.httpd.conf
94 if [ -d /etc/apache2/sites-available ] && [ ! -e /etc/apache2/sites-available/@OLDPACKAGE@ ] ; then
95 ln -s /etc/@OLDPACKAGE@/httpd.conf /etc/apache2/sites-available/@OLDPACKAGE@
99 # Make Apache see these new changes
100 invoke-rc.d apache2 restart || true
103 abort-upgrade|abort-remove|abort-deconfigure)
107 echo "postinst called with unknown argument \`$1'" >&2
112 # dh_installdeb will replace this with shell code automatically
113 # generated by other debhelper scripts.