2 # postinst 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
33 #set -x # Be verbose, be very verbose.
35 # summary of how this script can be called:
36 # * <postinst> `configure' <most-recently-configured-version>
37 # * <old-postinst> `abort-upgrade' <new version>
38 # * <conflictor's-postinst> `abort-remove' `in-favour' <package>
40 # * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
41 # <failed-install-package> <version> `removing'
42 # <conflicting-package> <version>
43 # for details, see /usr/share/doc/packaging-manual/
45 # quoting from the policy:
46 # Any necessary prompting should almost always be confined to the
47 # post-installation script, and should be protected with a conditional
48 # so that unnecessary prompting doesn't happen if a package's
49 # installation fails and the `postinst' is called with `abort-upgrade',
50 # `abort-remove' or `abort-deconfigure'.
52 . /usr/share/debconf/confmodule
56 # Patch DB configuration files
57 /usr/share/@OLDPACKAGE@/bin/install-db.sh configure-files
59 # At first, the pg_hba.conf file is not yet handled by ucf, so
60 # we don't display the usual template, but instead a custom
61 # one (fusionforge/ucfchangeprompt)
62 ucf_package=`ucfq -w ${pg_hba_dir}/pg_hba.conf | cut -d ':' -f 2`
63 if [ "x$ucf_package" != "x@OLDPACKAGE@-db-postgresql" ]
65 ucf --debconf-ok --debconf-template fusionforge/ucfchangeprompt ${pg_hba_dir}/pg_hba.conf.@OLDPACKAGE@-new ${pg_hba_dir}/pg_hba.conf
67 ucf --debconf-ok ${pg_hba_dir}/pg_hba.conf.@OLDPACKAGE@-new ${pg_hba_dir}/pg_hba.conf
69 # register it with ucfr/ucfq so that next time the normal ucf template is used, in case of user changes (or another package's)
70 ucfr @OLDPACKAGE@-db-postgresql ${pg_hba_dir}/pg_hba.conf
71 rm ${pg_hba_dir}/pg_hba.conf.@OLDPACKAGE@-new
73 # Make sure the database accepts connections from these new users
74 pg_name=postgresql-$pg_version
75 # Trying "postgresql" init script...
77 invoke-rc.d postgresql reload || v=$?
78 if test x"$v" = x"100"; then
79 # No "postgresql" init script (for packages << 8.4.4-2)
80 pg_name=postgresql-$pg_version
81 invoke-rc.d ${pg_name} reload
82 elif test x"$v" != x"0"; then
83 # Needed, since we run under "set -e"...
89 /usr/share/@OLDPACKAGE@/bin/install-db.sh configure || v=$?
90 if test x"$v" = x"100"; then
91 db_get @PACKAGE@/shared/admin_password || true
92 /usr/share/gforge/bin/forge_set_password admin "$RET"
93 elif test x"$v" != x"0"; then
97 if [ -n "$2" ] && dpkg --compare-versions $2 lt 5.1-8 ; then
98 echo "Normalizing all roles and permissions"
99 PATH=$PATH:/usr/share/gforge/bin normalize_roles.php
104 abort-upgrade|abort-remove|abort-deconfigure)
108 echo "postinst called with unknown argument \`$1'" >&2
113 # dh_installdeb will replace this with shell code automatically
114 # generated by other debhelper scripts.