Sophie

Sophie

distrib > Mageia > 5 > x86_64 > media > core-release > by-pkgid > c1e5f0a394bd4cf5f297ce3c5dbb1335 > scriptlet

openldap-back_bdb-2.4.40-3.mga5.x86_64.rpm

Triggers

openldap-servers < 2.4.38

/bin/sh
# FIXME: moduleload back_bdb.la, moduleload back_hdb.la
[ -e /etc/sysconfig/slapd ] && . /etc/sysconfig/slapd
#SLAPDCONF=${SLAPDCONF:-/etc/openldap/slapd.conf}
if [ -z "$SLAPDCONF" ]
then
    if [ -e "/etc/openldap/slapd.d/cn=config.ldif" ]
    then
	SLAPDCONF=/etc/openldap/slapd.d
    else
	SLAPDCONF=/etc/openldap/slapd.conf
    fi
fi
start_slapd=no
if [ -e "$SLAPDCONF/cn=config.ldif" -a -e /etc/openldap/slapd-config-rpm-upgrade.ldif ]
then
    if grep -qE '^objectClass: olc(B|H)dbConfig' /etc/openldap/slapd-config-rpm-upgrade.ldif
    then
	start_slapd=yes
	echo "Fixing previous export /etc/openldap/slapd-config-rpm-upgrade.ldif and importing to ${SLAPDCONF}.rpm-upgrade"
awk 'BEGIN {seenmodules=0} /^olcModuleLoad: {([0-9]+)}.+/ {seenmodules++} /^$/ { if (seenmodules>1) {printf "olcModuleLoad: {%s}back_bdb.la\n",seenmodules;printf "olcModuleLoad: {%s}back_hdb.la\n",seenmodules+1;seenmodules=0}} {print}' /etc/openldap/slapd-config-rpm-upgrade.ldif > /etc/openldap/slapd-config-rpm-upgrade-fixed.ldif
	mkdir "${SLAPDCONF}.rpm-upgrade"
	slapadd -F "${SLAPDCONF}.rpm-upgrade" -n0 -l /etc/openldap/slapd-config-rpm-upgrade-fixed.ldif
	chown -R ldap:ldap "${SLAPDCONF}.rpm-upgrade"
	echo "Importing fixed config complete, testing config: "
	if slaptest -u -F "${SLAPDCONF}.rpm-upgrade" 2>/dev/null
	then
	    echo "Configuration passed, removing temporary configuration copies and old configuration"
	    rm -f /etc/openldap/slapd-config-rpm-upgrade.ldif /etc/openldap/slapd-config-rpm-upgrade-fixed.ldif
	    rm -Rf "${SLAPDCONF}"
	    mv "${SLAPDCONF}.rpm-upgrade" "${SLAPDCONF}"
	else
	    echo "Modification of your existing configuration did not result in a valid configuration"
	    echo "An export of your existing configuration is left as /etc/openldap/slapd-config-rpm-upgrade.ldif"
	    echo "and the modified configuration export as /etc/openldap/slapd-config-rpm-upgrade-fixed.ldif"
	    echo "Your old config is left as-is, and the modified config available in ${SLAPDCONF}.rpm-upgrade"
	fi
    fi
else
    if grep -qE "^database.*(bdb|hdb)" "$SLAPDCONF"
    then
	start_slapd=yes
	awk '/^modulepath/ {print;printf "moduleload back_bdb.la\nmoduleload back_hdb.la\n";next} {print}' "${SLAPDCONF}" > "${SLAPDCONF}.rpm-upgrade"
	if slaptest -u -f ${SLAPDCONF}.rpm-upgrade 2>/dev/null
	then
	    cp -f "${SLAPDCONF}.rpm-upgrade" "${SLAPDCONF}"
	else
	    echo "Modification of ${SLAPDCONF} resulting in ${SLAPDCONF}.rpm-upgrade did not"
	    echo "result in a valid configuration. Please consult 'slaptest -f ${SLAPDCONF}.rpm-upgrade'"
	    echo "and resolve the problem manually."
	fi
    fi
fi
# Maybe need a better flag that slapd may need restarting due to start failing in post
if [ -e /var/lock/subsys/slapd -a "$start_slapd" == "yes" ]
then
    rm -f /var/lock/subsys/slapd
    if [ -x /usr/bin/systemd -a -e /usr/lib/systemd/system/slapd.service ]
    then systemctl start slapd.service
    else service start slapd
    fi
fi