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 "Couldn't initialize or upgrade @OLDPACKAGE@ database."
21 echo "Please see postgresql documentation"
22 echo "and run dpkg-reconfigure -plow @OLDPACKAGE@-db-postgresql"
23 echo "once the problem is solved"
24 echo "exiting without error, but @OLDPACKAGE@ db will not work"
29 export pg_hba_dir=/etc/postgresql
34 # summary of how this script can be called:
36 # * <old-prerm> `upgrade' <new-version>
37 # * <new-prerm> `failed-upgrade' <old-version>
38 # * <conflictor's-prerm> `remove' `in-favour' <package> <new-version>
39 # * <deconfigured's-prerm> `deconfigure' `in-favour'
40 # <package-being-installed> <version> `removing'
41 # <conflicting-package> <version>
42 # for details, see /usr/share/doc/packaging-manual/
44 . /usr/share/debconf/confmodule
49 /usr/share/@OLDPACKAGE@/bin/install-db.sh purge
51 # Unpatch DB configuration files
52 /usr/share/@OLDPACKAGE@/bin/install-db.sh purge-files
53 ucf --debconf-ok ${pg_hba_dir}/pg_hba.conf.@OLDPACKAGE@-new ${pg_hba_dir}/pg_hba.conf
54 rm ${pg_hba_dir}/pg_hba.conf.@OLDPACKAGE@-new
55 ucf --purge ${pg_hba_dir}/pg_hba.conf
57 pg_name=postgresql-$pg_version
58 # Trying "postgresql" init script...
59 invoke-rc.d postgresql reload || v=$?
60 if test x"$v" = x"100"; then
61 # No "postgresql" init script (for packages << 8.4.4-2)
62 pg_name=postgresql-$pg_version
63 invoke-rc.d ${pg_name} reload
64 elif test x"$v" != x"0"; then
65 # Needed, since we run under "set -e"...
69 upgrade|deconfigure|failed-upgrade)
72 echo "prerm called with unknown argument \`$1'" >&2
77 # dh_installdeb will replace this with shell code automatically
78 # generated by other debhelper scripts.