fix database upgrade process

Resolves: #656257
This commit is contained in:
Jan Vcelak 2010-11-23 16:01:50 +01:00
parent 82b8ccaded
commit 40bc33f600

View File

@ -400,14 +400,14 @@ fi
# upgrade # upgrade
if [ $1 -eq 2 ]; then if [ $1 -eq 2 ]; then
# safe way to migrate the database if minor version number changed (2.x -> 2.y) # safe way to migrate the database if version number changed
# http://www.openldap.org/doc/admin24/maintenance.html # http://www.openldap.org/doc/admin24/maintenance.html
old_version=$(rpm -q --qf=%%{version} openldap-servers | sed 's/\.[0-9]*$//') old_version=$(rpm -q --qf=%%{version} openldap-servers)
new_version=$(sed 's/\.[0-9]*$//' <<< %{version}) new_version=%{version}
if [ "$old_version" != "$new_version" ]; then if [ "$old_version" != "$new_version" ]; then
pushd %{_sharedstatedir}/ldap pushd %{_sharedstatedir}/ldap &>/dev/null
# stop the service # stop the service
if service slapd status &>/dev/null; then if service slapd status &>/dev/null; then
@ -417,7 +417,7 @@ if [ $1 -eq 2 ]; then
rm -f need_start rm -f need_start
fi fi
if ls __db.* &>/dev/null; then if ls *.bdb &>/dev/null; then
# export the database # export the database
if [ -f %{_sysconfdir}/openldap/slapd.conf ]; then if [ -f %{_sysconfdir}/openldap/slapd.conf ]; then
slapcat -f %{_sysconfdir}/openldap/slapd.conf -l upgrade.ldif &>/dev/null slapcat -f %{_sysconfdir}/openldap/slapd.conf -l upgrade.ldif &>/dev/null
@ -427,15 +427,21 @@ if [ $1 -eq 2 ]; then
# backup the old database # backup the old database
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
rm -rf rpmorig chown ldap:ldap upgrade.ldif
mv alock *.bdb __db.* log.* rpmorig &>/dev/null || : chmod 0400 upgrade.ldif
cp -f rpmorig/DB_CONFIG . &>/dev/null || :
rm -rf backup
mkdir -m 0700 backup
chown 0500 backup
mv alock *.bdb __db.* log.* backup &>/dev/null
cp -f backup/DB_CONFIG DB_CONFIG &>/dev/null
else else
rm -f upgrade.ldif rm -f upgrade.ldif
fi fi
fi fi
popd popd &>/dev/null
fi fi
fi fi
@ -500,8 +506,8 @@ fi
# finish database migration (see %pre) # finish database migration (see %pre)
if [ -f %{_sharedstatedir}/ldap/upgrade.ldif ]; then if [ -f %{_sharedstatedir}/ldap/upgrade.ldif ]; then
runuser -m -s /usr/sbin/slapadd -- ldap -l %{_sharedstatedir}/ldap/upgrade.ldif &>/dev/null runuser -m -s /usr/sbin/slapadd -- ldap -q -l %{_sharedstatedir}/ldap/upgrade.ldif >/dev/null
rm -f %{_sharedstatedir}/ldap/upgrade.ldif mv -f %{_sharedstatedir}/ldap/upgrade.ldif %{_sharedstatedir}/ldap/backup.ldif
fi fi
# restart after upgrade # restart after upgrade
@ -536,7 +542,7 @@ fi
# db4 upgrade (see %triggerun) # db4 upgrade (see %triggerun)
if [ $2 -eq 2 ]; then if [ $2 -eq 2 ]; then
pushd %{_sharedstatedir}/ldap pushd %{_sharedstatedir}/ldap &>/dev/null
# we are interested in minor version changes (both versions of db4 are installed at this moment) # we are interested in minor version changes (both versions of db4 are installed at this moment)
if [ "$(rpm -q --qf="%%{version}\n" db4 | sed 's/\.[0-9]*$//' | sort -u | wc -l)" != "1" ]; then if [ "$(rpm -q --qf="%%{version}\n" db4 | sed 's/\.[0-9]*$//' | sort -u | wc -l)" != "1" ]; then
@ -555,7 +561,7 @@ if [ $2 -eq 2 ]; then
rm -f upgrade_db4 rm -f upgrade_db4
fi fi
popd popd &>/dev/null
fi fi
exit 0 exit 0
@ -564,7 +570,7 @@ exit 0
# db4 upgrade (see %triggerin) # db4 upgrade (see %triggerin)
if [ -f %{_sharedstatedir}/ldap/upgrade_db4 ]; then if [ -f %{_sharedstatedir}/ldap/upgrade_db4 ]; then
pushd %{_sharedstatedir}/ldap pushd %{_sharedstatedir}/ldap &>/dev/null
# perform the upgrade # perform the upgrade
if ls *.bdb &>/dev/null; then if ls *.bdb &>/dev/null; then
@ -579,7 +585,7 @@ if [ -f %{_sharedstatedir}/ldap/upgrade_db4 ]; then
fi fi
rm -f upgrade_db4 rm -f upgrade_db4
popd popd &>/dev/null
fi fi
exit 0 exit 0
@ -658,6 +664,7 @@ exit 0
- Mozilla NSS - implement full non-blocking semantics - Mozilla NSS - implement full non-blocking semantics
ldapsearch -Z hangs server if starttls fails (#652822) ldapsearch -Z hangs server if starttls fails (#652822)
- updated list of all overlays in slapd.conf (#655899) - updated list of all overlays in slapd.conf (#655899)
- fix database upgrade process (#656257)
* Thu Nov 18 2010 Jan Vcelak <jvcelak@redhat.com> 2.4.23-3 * Thu Nov 18 2010 Jan Vcelak <jvcelak@redhat.com> 2.4.23-3
- add support for multiple prefixed Mozilla NSS database files in TLS_CACERTDIR - add support for multiple prefixed Mozilla NSS database files in TLS_CACERTDIR