-# last update: 2005-07-03
# Ivan 'ico' Rako <irako@srce.hr>
# Zoran 'jelly' Dzelajlija <jelly@srce.hr>
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
}