2 # postinst script for pkgname
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/pkgname/ssl-cert.pem ] || [ ! -e /etc/pkgname/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/pkgname/ssl-cert.pem
60 ln -s /etc/ssl/private/ssl-cert-snakeoil.key /etc/pkgname/ssl-cert.key
61 if grep -q ^sys_use_ssl=false$ /etc/pkgname/pkgname.conf \
62 && grep -q ^sys_sslcrt=$ /etc/pkgname/pkgname.conf \
63 && grep -q ^sys_sslkey=$ /etc/pkgname/pkgname.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/pkgname/pkgname.conf
67 sed -i -e 's,^sys_sslcrt=$,sys_sslcrt=/etc/pkgname/ssl-cert.pem,' /etc/pkgname/pkgname.conf
68 sed -i -e 's,^sys_sslkey=$,sys_sslkey=/etc/pkgname/ssl-cert.key,' /etc/pkgname/pkgname.conf
76 touch /var/lib/pkgname/etc/templates/httpd.vhosts && \
77 chown pkgname:pkgname /var/lib/pkgname/etc/templates/httpd.vhosts && \
78 /usr/share/pkgname/bin/create-vhosts.sh --norestart
80 # Enable required modules
81 DEBIAN_FRONTEND=noninteractive /usr/sbin/a2enmod php5 || true
82 DEBIAN_FRONTEND=noninteractive /usr/sbin/a2enmod ssl || true
83 DEBIAN_FRONTEND=noninteractive /usr/sbin/a2enmod env || true
84 DEBIAN_FRONTEND=noninteractive /usr/sbin/a2enmod vhost_alias || true
85 DEBIAN_FRONTEND=noninteractive /usr/sbin/a2enmod headers || true
86 DEBIAN_FRONTEND=noninteractive /usr/sbin/a2enmod rewrite || true
88 # Enable the Gforge configuration
89 if [ -e /etc/apache2/conf.d/pkgname.httpd.conf ] ; then
90 rm -f /etc/apache2/conf.d/pkgname.httpd.conf
92 if [ -d /etc/apache2/sites-available ] && [ ! -e /etc/apache2/sites-available/pkgname ] ; then
93 ln -s /etc/pkgname/httpd.conf /etc/apache2/sites-available/pkgname
97 # Make Apache see these new changes
98 invoke-rc.d apache2 restart || true
101 abort-upgrade|abort-remove|abort-deconfigure)
105 echo "postinst called with unknown argument \`$1'" >&2
110 # dh_installdeb will replace this with shell code automatically
111 # generated by other debhelper scripts.