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