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
51 ucf --purge ${pg_hba_dir}/pg_hba.conf
52 ucfr --purge @OLDPACKAGE@-db-postgresql ${pg_hba_dir}/pg_hba.conf
54 pg_name=postgresql-$pg_version
55 # Trying "postgresql" init script...
57 invoke-rc.d postgresql reload || v=$?
58 if test x"$v" = x"100"; then
59 # No "postgresql" init script (for packages << 8.4.4-2)
60 pg_name=postgresql-$pg_version
61 invoke-rc.d ${pg_name} reload
62 elif test x"$v" != x"0"; then
63 # Needed, since we run under "set -e"...
67 upgrade|deconfigure|failed-upgrade)
70 echo "prerm called with unknown argument \`$1'" >&2
75 # dh_installdeb will replace this with shell code automatically
76 # generated by other debhelper scripts.