This file is indexed.

postinst is in gforge-db-postgresql 5.1.1-2.

This file is a maintainer script. It is executed when installing (*inst) or removing (*rm) the package.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#! /bin/sh
# postinst script for gforge
#
# see: dh_installdeb(1)

# Support for new place for pg_hba.conf
# I only try to upgrade on the default cluster
if [ -x /usr/bin/pg_lsclusters ]
then 
	# We are with new postgresql working with clusters
	# This is probably not te most elegant way to deal with database
	# I install or upgrade on the default cluster if it is online
	# or I quit gently with a big message
	pg_version=`pg_lsclusters | grep 5432 | grep online | cut -d' ' -f1`
	if [ "x$pg_version" != "x" ] 
	then 
		export pg_hba_dir=/etc/postgresql/${pg_version}/main
	else
		echo "No database found online on port 5432"
		echo "Couldn't initialize or upgrade gforge database."
		echo "Please see postgresql documentation"
		echo "and run dpkg-reconfigure -plow gforge-db-postgresql"
		echo "once the problem is solved"
		echo "exiting without error, but gforge db will not work"
		echo "right now"
		exit 0
	fi
else
    	export pg_hba_dir=/etc/postgresql
fi

set -e
#set -x				# Be verbose, be very verbose.

# summary of how this script can be called:
#        * <postinst> `configure' <most-recently-configured-version>
#        * <old-postinst> `abort-upgrade' <new version>
#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
#          <new-version>
#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
#          <failed-install-package> <version> `removing'
#          <conflicting-package> <version>
# for details, see /usr/share/doc/packaging-manual/
#
# quoting from the policy:
#     Any necessary prompting should almost always be confined to the
#     post-installation script, and should be protected with a conditional
#     so that unnecessary prompting doesn't happen if a package's
#     installation fails and the `postinst' is called with `abort-upgrade',
#     `abort-remove' or `abort-deconfigure'.

. /usr/share/debconf/confmodule

###
# Functions to handle the main FusionForge configuration file
###
mainconffile=/etc/fusionforge/fusionforge.conf
# Update it for the variables received as parameters
create_mainconffile () {
    if [ ! -e $mainconffile ] ; then
        touch $mainconffile
        chmod 600 $mainconffile
    fi
}
update_mainconffile () {
    for key in $@ ; do
	db_get fusionforge/shared/$key
	val=$RET
	update_onevar_mainconffile $key $val
    done
}
update_onevar_mainconfile () {
    key=$1
    val=$2
    if grep -q "^$key=" $mainconffile ; then
	newval=$(echo $val | sed -e 's/@/\\@/g' -e 's/\$/\\$/g' -e 's/\//\\\//g')
	perl -pi -e "s/^$key=.*/$key=$newval/" $mainconffile
    else
	echo "$key=$val" >> $mainconffile
    fi
}
add_onevar_mainconfile () {
    key=$1
    val=$2
    if ! grep -q "^$key=" $mainconffile ; then
	echo "$key=$val" >> $mainconffile
    fi
}

case "$1" in
    configure)
	add_onevar_mainconfile default_trove_cat 18

	fusionforge-config

        # Patch DB configuration files
	/usr/share/gforge/bin/install-db.sh configure-files

	# At first, the pg_hba.conf file is not yet handled by ucf, so
	# we don't display the usual template, but instead a custom
	# one (fusionforge/ucfchangeprompt)
	ucf_package=`ucfq -w ${pg_hba_dir}/pg_hba.conf | cut -d ':' -f 2`
	if [ "x$ucf_package" != "xgforge-db-postgresql" ]
	then
	    ucf --debconf-ok --debconf-template fusionforge/ucfchangeprompt ${pg_hba_dir}/pg_hba.conf.gforge-new ${pg_hba_dir}/pg_hba.conf
	else
	    ucf --debconf-ok ${pg_hba_dir}/pg_hba.conf.gforge-new ${pg_hba_dir}/pg_hba.conf
	fi
	# register it with ucfr/ucfq so that next time the normal ucf template is used, in case of user changes (or another package's)
	ucfr gforge-db-postgresql /etc/postgresql/9.0/main/pg_hba.conf
	rm ${pg_hba_dir}/pg_hba.conf.gforge-new

	# Make sure the database accepts connections from these new users
	pg_name=postgresql-$pg_version
	# Trying "postgresql" init script...
	v=0
	invoke-rc.d postgresql reload || v=$?
	if test x"$v" = x"100"; then
		# No "postgresql" init script (for packages << 8.4.4-2)
		pg_name=postgresql-$pg_version
		invoke-rc.d ${pg_name} reload
	elif test x"$v" != x"0"; then
		# Needed, since we run under "set -e"...
		exit $v
	fi

        # Setup our DB
	v=0
	/usr/share/gforge/bin/install-db.sh configure || v=$?
	if test x"$v" = x"100"; then
	    db_get fusionforge/shared/admin_password || true
	    /usr/share/gforge/bin/forge_set_password admin "$RET"
	elif test x"$v" != x"0"; then
	    exit $v
	fi

	if [ -n "$2" ] && dpkg --compare-versions $2 lt 5.1-8 ; then
            echo "Normalizing all roles and permissions"
            PATH=$PATH:/usr/share/gforge/bin normalize_roles.php
        fi

    ;;

    abort-upgrade|abort-remove|abort-deconfigure)
    ;;

    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 0
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.



exit 0