#!/bin/sh
# postinst script for pgbouncer
#
# see: dh_installdeb(1)

set -e

# 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>
#        * <postinst> `abort-remove'
#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
#          <failed-install-package> <version> `removing'
#          <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package

PGQD_USER=pgqd

case "$1" in
    configure)
	if getent passwd $PGQD_USER > /dev/null; then
	    echo User $PGQD_USER already exists
	else
	    adduser --system --disabled-login --no-create-home --home /etc --ingroup postgres $PGQD_USER
	fi
	chown root:root /etc/pgqd.ini
    ;;
esac

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

#DEBHELPER#

exit 0
