post_install() {
  if ! getent group pgbouncer >/dev/null; then
    groupadd -r pgbouncer
  fi
  if ! getent passwd pgbouncer >/dev/null; then
    useradd -c 'PGBouncer user' -r -g pgbouncer -d '/etc/pgbouncer' -s /bin/bash pgbouncer
    passwd -l pgbouncer >/dev/null
  fi
  chown pgbouncer:pgbouncer /var/log/pgbouncer
  systemd-tmpfiles --create pgbouncer.conf
  post_upgrade
}

post_upgrade() {
  gpasswd -a pgbouncer postgres
}
