mrc0mmand / rpms / openldap

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