--- /root/nss_ldap-253.ebuild 2006-11-28 09:51:45.000000000 +0200 +++ nss_ldap-253.ebuild 2006-11-28 10:54:46.000000000 +0200 @@ -68,3 +68,45 @@ COPYING CVSVersionInfo.txt README nsswitch.ldap certutil docinto docs; dodoc doc/* } + +pkg_postinst() { + elog "You can use emerge --config =${PF} to automatically add" + elog "ldap to your ${ROOT}etc/nsswitch.conf" +} + +pkg_config() { + local ns=${ROOT}etc/nsswitch.conf + cp "${ns}" "${T}" || die "Could not copy ${ns} to ${T}" + local nst="${T}/nsswitch.conf" + + einfo "Configuring passwd shadow and group databases to use ldap." + einfo "If you want to use ldap for other uses, please configure" + einfo "${ns} manually." + einfo "" + + for var in passwd shadow group; do + local match=$(egrep "^${var}:.*ldap" "${nst}") + if [[ -z "${match}" ]]; then + sed -e "s/^${var}:.*/& ldap/" -i "${nst}" + else + eerror "Ldap already found:" + eerror "${match}" + fi + done + + diff -u "${ns}" "${nst}" + + einfo "" + einfo "Use the new file?" + einfo "Please note that if your ${ROOT}etc/ldap.conf is not" + einfo "setup correctly this might cause slowdowns in the usage" + einfo "of the configured databases." + einfo "[yes/edit/no]" + read answer + + case "${answer}" in + yes ) cp -v ${nst} ${ns};; + edit ) ${EDITOR} ${nst} && cp -v ${nst} ${ns};; + * ) einfo "${ns} not modified";; + esac +}