mrc0mmand / rpms / openldap

Forked from rpms/openldap 3 years ago
Clone
57672d
#!/bin/sh
57672d
# Author: Jan Vcelak <jvcelak@redhat.com>
57672d
57672d
. /usr/libexec/openldap/functions
57672d
57672d
if [ `id -u` -ne 0 ]; then
57672d
	error "You have to be root to run this command."
57672d
	exit 4
57672d
fi
57672d
57672d
load_sysconfig
57672d
retcode=0
57672d
57672d
for dbdir in `databases`; do
57672d
	upgrade_log="$dbdir/db_upgrade.`date +%Y%m%d%H%M%S`.log"
57672d
	bdb_files=`find "$dbdir" -maxdepth 1 -name "*.bdb" -printf '"%f" '`
57672d
57672d
	# skip uninitialized database
57672d
	[ -z "$bdb_files"]  || continue
57672d
57672d
	printf "Updating '%s', logging into '%s'\n" "$dbdir" "$upgrade_log"
57672d
57672d
	# perform the update
57672d
	for command in \
57672d
		"/usr/bin/db_recover -v -h \"$dbdir\"" \
57672d
		"/usr/bin/db_upgrade -v -h \"$dbdir\" $bdb_files" \
57672d
		"/usr/bin/db_checkpoint -v -h \"$dbdir\" -1" \
57672d
	; do
57672d
		printf "Executing: %s\n" "$command" &>>$upgrade_log
57672d
		run_as_ldap "$command" &>>$upgrade_log
57672d
		result=$?
57672d
		printf "Exit code: %d\n" $result >>"$upgrade_log"
57672d
		if [ $result -ne 0 ]; then
57672d
			printf "Upgrade failed: %d\n" $result
57672d
			retcode=1
57672d
		fi
57672d
	done
57672d
done
57672d
57672d
exit $retcode