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_down=`pg_lsclusters | grep 5432 | grep down | cut -d' ' -f1`
15 if [ "x$pg_version_down" != "x" ]
17 invoke-rc.d postgresql-$pg_version_down start
19 pg_version=`pg_lsclusters | grep 5432 | grep online | cut -d' ' -f1`
20 if [ "x$pg_version" != "x" ]
22 export pg_hba_dir=/etc/postgresql/${pg_version}/main/
24 echo "No database found online on port 5432"
25 echo "Couldn't initialize or upgrade @OLDPACKAGE@ database."
26 echo "Please see postgresql documentation"
27 echo "and run dpkg-reconfigure -plow @OLDPACKAGE@-db-postgresql"
28 echo "once the problem is solved"
29 echo "exiting without error, but @OLDPACKAGE@ db will not work"
34 export pg_hba_dir=/etc/postgresql
39 # summary of how this script can be called:
41 # * <old-prerm> `upgrade' <new-version>
42 # * <new-prerm> `failed-upgrade' <old-version>
43 # * <conflictor's-prerm> `remove' `in-favour' <package> <new-version>
44 # * <deconfigured's-prerm> `deconfigure' `in-favour'
45 # <package-being-installed> <version> `removing'
46 # <conflicting-package> <version>
47 # for details, see /usr/share/doc/packaging-manual/
49 . /usr/share/debconf/confmodule
54 /usr/share/@OLDPACKAGE@/bin/install-db.sh purge
56 # Unpatch DB configuration files
57 /usr/share/@OLDPACKAGE@/bin/install-db.sh purge-files
58 ucf --debconf-ok ${pg_hba_dir}/pg_hba.conf.@OLDPACKAGE@-new ${pg_hba_dir}/pg_hba.conf
59 rm ${pg_hba_dir}/pg_hba.conf.@OLDPACKAGE@-new
60 ucf --purge ${pg_hba_dir}/pg_hba.conf
62 pg_name=postgresql-$pg_version
63 invoke-rc.d ${pg_name} reload
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.