From b31f79b9c72b7e548ed2a1b8e1fc7308fdad19a0 Mon Sep 17 00:00:00 2001 From: Valentin Vidic Date: Fri, 28 Mar 2008 16:23:04 +0100 Subject: [PATCH] Fixes for ldap -> openldap user switch. --- src/functions.sh | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/src/functions.sh b/src/functions.sh index 9c81fc8..33ac260 100644 --- a/src/functions.sh +++ b/src/functions.sh @@ -1,4 +1,3 @@ -# last update: 2005-07-03 # Ivan 'ico' Rako # Zoran 'jelly' Dzelajlija @@ -655,17 +654,35 @@ upgrade_amavis () { upgrade_openldap () { pkg openldap-aai lt 2.3 || return 0 + # openldap-aai expects org.ldif to exists + local ldif=/var/lib/ldap/org.ldif + local ldif_backup=/var/lib/carnet-upgrade/org.ldif + if [ -f $ldif ]; then + cp -v $ldif $ldif_backup + fi + # slapd postinst fails if move_old_database is false echo 'slapd slapd/move_old_database boolean true' | debconf-set-selections pkgadd slapd - # openldap-aai postinst fails here because of database permissions - if ! apt-get -y install openldap-aai; then - chown -R openldap:openldap /var/lib/ldap # fix slapd - /etc/init.d/slapd restart + # slapd removes org.ldif during switch from ldap -> openldap user + if [ -f $ldif_backup -a ! -f $ldif ]; then + cp -v $ldif_backup $ldif + fi - # try openldap-aai postinst again (also re-enables slurpd) - dpkg --configure -a + # openldap-aai postinst fails here because of database permissions + apt-get -y install openldap-aai || true + chown -R openldap:openldap /var/lib/ldap + /etc/init.d/slapd restart + dpkg --configure -a + + # remove ldap user if openldap works + if getent passwd ldap > /dev/null && \ + getent passwd openldap > /dev/null && \ + pgrep -U openldap slapd > /dev/null + then + log "userdel ldap (replaced by openldap)" + userdel ldap || true fi } -- 1.7.10.4