2 # prerm script for @OLDPACKAGE@
4 # see: dh_installdeb(1)
6 # Support for new place for pg_hba.conf
7 # I only try to upgrade on the default cluster
8 if [ -x /usr/bin/pg_lsclusters ]
10 # We are with new postgresql working with clusters
11 # This is probably not te most elegant way to deal with database
12 # I install or upgrade on the default cluster if it is online
13 # or I quit gently with a big message
14 pg_version=`pg_lsclusters | grep 5432 | grep online | cut -d' ' -f1`
15 if [ "x$pg_version" != "x" ]
17 export pg_hba_dir=/etc/postgresql/${pg_version}/main
19 echo "No database found online on port 5432."
20 echo "Assuming the database was dropped and no action is needed."
21 echo "Exiting without error, but make sure there are no leftovers."
25 export pg_hba_dir=/etc/postgresql
30 # summary of how this script can be called:
32 # * <old-prerm> `upgrade' <new-version>
33 # * <new-prerm> `failed-upgrade' <old-version>
34 # * <conflictor's-prerm> `remove' `in-favour' <package> <new-version>
35 # * <deconfigured's-prerm> `deconfigure' `in-favour'
36 # <package-being-installed> <version> `removing'
37 # <conflicting-package> <version>
38 # for details, see /usr/share/doc/packaging-manual/
40 . /usr/share/debconf/confmodule
45 /usr/share/@OLDPACKAGE@/bin/install-db.sh purge
47 # Unpatch DB configuration files
48 /usr/share/@OLDPACKAGE@/bin/install-db.sh purge-files
49 ucf --debconf-ok ${pg_hba_dir}/pg_hba.conf.@OLDPACKAGE@-new ${pg_hba_dir}/pg_hba.conf
50 rm ${pg_hba_dir}/pg_hba.conf.@OLDPACKAGE@-new
52 pg_name=postgresql-$pg_version
53 # Trying "postgresql" init script...
55 invoke-rc.d postgresql reload || v=$?
56 if test x"$v" = x"100"; then
57 # No "postgresql" init script (for packages << 8.4.4-2)
58 pg_name=postgresql-$pg_version
59 invoke-rc.d ${pg_name} reload
60 elif test x"$v" != x"0"; then
61 # Needed, since we run under "set -e"...
65 upgrade|deconfigure|failed-upgrade)
68 echo "prerm called with unknown argument \`$1'" >&2
73 # dh_installdeb will replace this with shell code automatically
74 # generated by other debhelper scripts.