#! /bin/sh # prerm script for @OLDPACKAGE@ # # 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 @OLDPACKAGE@ database." echo "Please see postgresql documentation" echo "and run dpkg-reconfigure -plow @OLDPACKAGE@-db-postgresql" echo "once the problem is solved" echo "exiting without error, but @OLDPACKAGE@ db will not work" echo "right now" exit 0 fi else export pg_hba_dir=/etc/postgresql fi set -e # summary of how this script can be called: # * `remove' # * `upgrade' # * `failed-upgrade' # * `remove' `in-favour' # * `deconfigure' `in-favour' # `removing' # # for details, see /usr/share/doc/packaging-manual/ . /usr/share/debconf/confmodule case "$1" in remove) # Remove our database /usr/share/@OLDPACKAGE@/bin/install-db.sh purge # Unpatch DB configuration files /usr/share/@OLDPACKAGE@/bin/install-db.sh purge-files ucf --debconf-ok ${pg_hba_dir}/pg_hba.conf.@OLDPACKAGE@-new ${pg_hba_dir}/pg_hba.conf rm ${pg_hba_dir}/pg_hba.conf.@OLDPACKAGE@-new ucf --purge ${pg_hba_dir}/pg_hba.conf pg_name=postgresql-$pg_version # Trying "postgresql" init script... v=0 invoke-rc.d postgresql reload || v=$? if test x"$v" = x"100"; then # No "postgresql" init script (for packages << 8.4.4-2) pg_name=postgresql-$pg_version invoke-rc.d ${pg_name} reload elif test x"$v" != x"0"; then # Needed, since we run under "set -e"... exit $v fi ;; upgrade|deconfigure|failed-upgrade) ;; *) echo "prerm 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