#! /bin/sh # postinst script for pkgname # # see: dh_installdeb(1) set -e #set -x # Be verbose, be very verbose. # summary of how this script can be called: # * `configure' # * `abort-upgrade' # * `abort-remove' `in-favour' # # * `abort-deconfigure' `in-favour' # `removing' # # for details, see /usr/share/doc/packaging-manual/ # # quoting from the policy: # Any necessary prompting should almost always be confined to the # post-installation script, and should be protected with a conditional # so that unnecessary prompting doesn't happen if a package's # installation fails and the `postinst' is called with `abort-upgrade', # `abort-remove' or `abort-deconfigure'. . /usr/share/debconf/confmodule #DSFHELPER:handle-mainconffile# case "$1" in configure) if [ -c /dev/urandom ]; then # ...using /dev/urandom when possible sys_session_key=$(dd if=/dev/urandom count=256 bs=1 2> /dev/null | md5sum | cut -b1-32) else # ...or something else if need be. # Last I was told, the Hurd had no /dev/urandom # (Correct me if it has changed) sys_session_key=$(dd if=/dev/random count=256 bs=1 2> /dev/null | md5sum | cut -b1-32) fi add_onevar_mainconfile sys_session_key $sys_session_key add_onevar_mainconfile sys_show_source 0 add_onevar_mainconfile sys_force_login 0 if [ -f /usr/bin/cronolog ]; then # this is the preferred location for debian add_onevar_mainconfile cronolog_path /usr/bin/cronolog elif [ -f /usr/sbin/cronolog ]; then # this location is deprecated in debian add_onevar_mainconfile cronolog_path /usr/sbin/cronolog else echo "can't find cronolog in usual places" >&2 add_onevar_mainconfile cronolog_path /usr/bin/cronolog fi if [ ! -e /etc/pkgname/ssl-cert.pem ] || [ ! -e /etc/pkgname/ssl-cert.key ] ; then # Uh-oh, no SSL cert, let's make sure at least a dummy one exists. if [ ! -e /etc/ssl/certs/ssl-cert-snakeoil.pem ] || [ ! -e /etc/ssl/private/ssl-cert-snakeoil.key ] ; then # What, not even the snakeoil cert is there? Let's generate it make-ssl-cert generate-default-snakeoil fi # Right. At this point, it should be safe to set the symlinks. ln -s /etc/ssl/certs/ssl-cert-snakeoil.pem /etc/pkgname/ssl-cert.pem ln -s /etc/ssl/private/ssl-cert-snakeoil.key /etc/pkgname/ssl-cert.key if grep -q ^sys_use_ssl=false$ /etc/pkgname/pkgname.conf \ && grep -q ^sys_sslcrt=$ /etc/pkgname/pkgname.conf \ && grep -q ^sys_sslkey=$ /etc/pkgname/pkgname.conf ; then # Okay, previous installations failed to locate SSL certs # and disabled SSL altogether. Let's fix that sed -i -e 's,^sys_use_ssl=false$,sys_use_ssl=true,' /etc/pkgname/pkgname.conf sed -i -e 's,^sys_sslcrt=$,sys_sslcrt=/etc/pkgname/ssl-cert.pem,' /etc/pkgname/pkgname.conf sed -i -e 's,^sys_sslkey=$,sys_sslkey=/etc/pkgname/ssl-cert.key,' /etc/pkgname/pkgname.conf fi fi pkgname-config db_stop # Setup our Apache touch /var/lib/pkgname/etc/templates/httpd.vhosts && \ chown pkgname:pkgname /var/lib/pkgname/etc/templates/httpd.vhosts && \ /usr/share/pkgname/bin/create-vhosts.sh --norestart # Enable required modules DEBIAN_FRONTEND=noninteractive /usr/sbin/a2enmod php5 || true DEBIAN_FRONTEND=noninteractive /usr/sbin/a2enmod ssl || true DEBIAN_FRONTEND=noninteractive /usr/sbin/a2enmod env || true DEBIAN_FRONTEND=noninteractive /usr/sbin/a2enmod vhost_alias || true DEBIAN_FRONTEND=noninteractive /usr/sbin/a2enmod headers || true DEBIAN_FRONTEND=noninteractive /usr/sbin/a2enmod rewrite || true # Enable the Gforge configuration if [ -e /etc/apache2/conf.d/pkgname.httpd.conf ] ; then rm -f /etc/apache2/conf.d/pkgname.httpd.conf fi if [ -d /etc/apache2/sites-available ] && [ ! -e /etc/apache2/sites-available/pkgname ] ; then ln -s /etc/pkgname/httpd.conf /etc/apache2/sites-available/pkgname fi a2ensite pkgname # Make Apache see these new changes invoke-rc.d apache2 restart || true ;; abort-upgrade|abort-remove|abort-deconfigure) ;; *) echo "postinst called with unknown argument \`$1'" >&2 exit 0 ;; esac # dh_installdeb will replace this with shell code automatically # generated by other debhelper scripts. #DEBHELPER# exit 0