#! /bin/sh # postinst script for gforge # # see: dh_installdeb(1) # Support for new place for pg_hba.conf # I only try to upgrade on the default cluster if [ -x /usr/bin/pg_lsclusters ] then # We are with new postgresql working with clusters # This is probably not te most elegant way to deal with database # I install or upgrade on the default cluster if it is online # or I quit gently with a big message pg_version=`pg_lsclusters | grep 5432 | grep online | cut -d' ' -f1` if [ "x$pg_version" != "x" ] then export pg_hba_dir=/etc/postgresql/${pg_version}/main else echo "No database found online on port 5432" echo "Couldn't initialize or upgrade gforge database." echo "Please see postgresql documentation" echo "and run dpkg-reconfigure -plow gforge-db-postgresql" echo "once the problem is solved" echo "exiting without error, but gforge db will not work" echo "right now" exit 0 fi else export pg_hba_dir=/etc/postgresql fi 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 ### # Functions to handle the main FusionForge configuration file ### mainconffile=/etc/fusionforge/fusionforge.conf # Update it for the variables received as parameters create_mainconffile () { if [ ! -e $mainconffile ] ; then touch $mainconffile chmod 600 $mainconffile fi } update_mainconffile () { for key in $@ ; do db_get fusionforge/shared/$key val=$RET update_onevar_mainconffile $key $val done } update_onevar_mainconfile () { key=$1 val=$2 if grep -q "^$key=" $mainconffile ; then newval=$(echo $val | sed -e 's/@/\\@/g' -e 's/\$/\\$/g' -e 's/\//\\\//g') perl -pi -e "s/^$key=.*/$key=$newval/" $mainconffile else echo "$key=$val" >> $mainconffile fi } add_onevar_mainconfile () { key=$1 val=$2 if ! grep -q "^$key=" $mainconffile ; then echo "$key=$val" >> $mainconffile fi } case "$1" in configure) add_onevar_mainconfile default_trove_cat 18 gforge-config # Patch DB configuration files /usr/share/gforge/bin/install-db.sh configure-files ucf --debconf-ok ${pg_hba_dir}/pg_hba.conf.gforge-new ${pg_hba_dir}/pg_hba.conf rm ${pg_hba_dir}/pg_hba.conf.gforge-new # Make sure the database accepts connections from these new users pg_name=postgresql-$pg_version invoke-rc.d ${pg_name} reload # Setup our DB /usr/share/gforge/bin/install-db.sh configure ;; 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. exit 0