#!/bin/sh

# Sudoers entry
#--------------

/usr/sbin/addsudo /usr/sbin/authconfig app-openldap-directory-core
/usr/sbin/addsudo /usr/sbin/slapcat app-openldap-directory-core
/usr/sbin/addsudo /usr/sbin/app-openldap-directory-initialize app-openldap-directory-core

# Update group mappings depending on nslcd version
#-------------------------------------------------

IS_OLD_NSLCD=`/usr/sbin/nslcd --version | grep "^nss-pam-ldapd 0\.7\."`
IS_OLD_CONFIG=`grep "^map group uniqueMember" /var/clearos/ldap/synchronize/nslcd.conf 2>/dev/null`

if ( [ -z "$IS_OLD_NSLCD" ] && [ -n "$IS_OLD_CONFIG" ] ); then
    logger -p local6.notice -t installer "app-openldap-directory-core - upgrading to 0.8+ nslcd.conf"
    cp /usr/clearos/apps/openldap_directory/deploy/nslcd.conf /var/clearos/ldap/synchronize/nslcd.conf
    [ -x /usr/sbin/ldap-synchronize ] && /usr/sbin/ldap-synchronize
fi
