#!/bin/sh
# postinst script for faspamgroupconfig
#
# 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


case "$1" in
    configure)

# configure for pam_group
    if ! grep "pam_group.so" /etc/pam.d/common-auth; then
    cat <<EOF>> /etc/pam.d/common-auth

# use pam-group for setting extra groups
auth    optional        pam_group.so
EOF
    fi

restart_nslcd=0

# configure nslcd for ldap groups
    if ! grep "uniqueMember" /etc/nslcd.conf; then
    cat <<EOF>> /etc/nslcd.conf

# take groups from ldap
map group member uniqueMember
EOF

       restart_nslcd=1

    fi

if [ $restart_nslcd -eq 1 ]; then
	service nslcd restart
fi

    ;;

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

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

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

#DEBHELPER#

exit 0
