[Pkg-openldap-devel] [openldap] 07/11: r2062 at pulsar: torsten | 2005-05-26 16:01:53 +0200 Applied db_recover patch submitted by Eugene Konev r2063 at pulsar: torsten | 2005-05-26 16:53:09 +0200 * Merged suggested changes by Eugene Konev to automatically run db_recover before starting slapd (closes: #255276). + debian/slapd.init: Run db_recover if enabled and available. + debian/slapd.default: Add configuration option to disable it. r2064 at pulsar: torsten | 2005-05-26 17:31:05 +0200 Fix gathering of BDB directories, good error output

Timo Aaltonen tjaalton-guest at alioth.debian.org
Thu Oct 10 05:36:13 UTC 2013


This is an automated email from the git hooks/post-receive script.

tjaalton-guest pushed a commit to annotated tag 2.2.23-6
in repository openldap.

commit b3829709e790363caa3cf3684eb00c6a3588e157
Author: Torsten Landschoff <torsten at debian.org>
Date:   Thu May 26 15:29:15 2005 +0000

     r2062 at pulsar:  torsten | 2005-05-26 16:01:53 +0200
     Applied db_recover patch submitted by Eugene Konev
     r2063 at pulsar:  torsten | 2005-05-26 16:53:09 +0200
      * Merged suggested changes by Eugene Konev to automatically run
        db_recover before starting slapd (closes: #255276).
        + debian/slapd.init: Run db_recover if enabled and available.
        + debian/slapd.default: Add configuration option to disable it.
     r2064 at pulsar:  torsten | 2005-05-26 17:31:05 +0200
     Fix gathering of BDB directories, good error output
---
 debian/changelog     |    6 ++++-
 debian/slapd.default |    3 +++
 debian/slapd.init    |   60 ++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 68 insertions(+), 1 deletion(-)

diff --git a/debian/changelog b/debian/changelog
index 8e81a69..69a2302 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -9,6 +9,10 @@ openldap2.2 (2.2.23-6) unstable; urgency=low
     (closes: #308234).
   * debian/slapd.postinst: Make sure the debhelper commands are executed 
     in all cases (closes: #310422).
+  * Merged suggested changes by Eugene Konev to automatically run 
+    db_recover before starting slapd (closes: #255276).
+    + debian/slapd.init: Run db_recover if enabled and available.
+    + debian/slapd.default: Add configuration option to disable it.
 
   Steve Langasek <vorlon at debian.org>:
   * libraries/libldap_r/Makefile.in: make sure the ximian-connector ntlm
@@ -17,7 +21,7 @@ openldap2.2 (2.2.23-6) unstable; urgency=low
     two versions of this library around is more trouble than it's worth,
     and can cause glorious segfaults down the line
 
- -- 
+ -- Torsten Landschoff <torsten at debian.org>  Mon, 23 May 2005 17:03:53 +0200
 
 openldap2.2 (2.2.23-5) unstable; urgency=low
 
diff --git a/debian/slapd.default b/debian/slapd.default
index f9cf955..fba51e2 100644
--- a/debian/slapd.default
+++ b/debian/slapd.default
@@ -13,6 +13,9 @@ SLAPD_GROUP=
 # will try to figure it out from $SLAPD_CONF (/etc/ldap/slapd.conf)
 SLAPD_PIDFILE=
 
+# Confiure if db_recover should be called before starting slapd
+TRY_BDB_RECOVERY=yes
+
 # Configure if the slurpd daemon should be started. Possible values: 
 # - yes:   Always start slurpd
 # - no:    Never start slurpd
diff --git a/debian/slapd.init b/debian/slapd.init
index edff7a3..bc224e8 100644
--- a/debian/slapd.init
+++ b/debian/slapd.init
@@ -6,6 +6,9 @@ set -e
 # Stop processing if slapd is not there
 [ -x /usr/sbin/slapd ] || exit 0
 
+# Set default values
+DB_RECOVER_CMD=db4.2_recover
+
 # Source the init script configuration
 if [ -f "/etc/default/slapd" ]; then
 	. /etc/default/slapd
@@ -106,6 +109,60 @@ EOF
 	fi
 }
 
+# Try to recover slapd database
+try_fix_db() {
+	local dbdir failed bdb_envs
+
+	# db4.2-util is just recommended by slapd, so make sure it is
+	# available before trying to use it
+	if ! command -v $DB_RECOVER_CMD >/dev/null 2>&1; then
+		echo -n " ($DB_RECOVER_CMD not found), "
+		return 0
+	fi
+
+	bdb_envs=`find_bdb_envs`
+
+	# We care only about BDB environments
+	if [ -z "$bdb_envs" ]; then
+		return 0
+	fi
+
+	echo -n " running BDB recovery"
+	for dbdir in $bdb_envs; do
+		reason="`$DB_RECOVER_CMD -eh $dbdir 2>&1`" || \
+			db_recover_failed $dbdir
+	done
+	echo -n ","
+}
+
+# Find bdb environment dirs
+find_bdb_envs() {
+	local d
+	for d in `sed -ne 's/^directory[[:space:]]\+"*\([^"]\+\).*/\1/p' \
+			< "$SLAPD_CONF"`; do
+		if [ -d "$d" -a -f "$d/objectClass.bdb" ]; then
+			echo $d
+		fi
+	done
+}
+
+# Inform the user that BDB recovery failed
+db_recover_failed() {
+	local dbdir
+	dbdir="$1"
+
+	reason="`cat <<EOF
+Automatic recovery of the OpenLDAP directory database in
+
+	$dbdir
+
+failed. You will need to perform a manual recovery, possibly from backup.
+The failed command was $DB_RECOVER_CMD -eh $dbdir. Output:
+
+$reason
+EOF`"
+	exit 1
+}
 
 # Start the slapd daemon and capture the error message if any to 
 # $reason.
@@ -157,6 +214,9 @@ stop_slurpd() {
 start() {
 	echo -n "Starting OpenLDAP:"
 	trap 'report_failure' 0
+	if [ "$TRY_BDB_RECOVERY" = "yes" ]; then
+		try_fix_db
+	fi
 	start_slapd
 	start_slurpd
 	trap "-" 0

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-openldap/openldap.git



More information about the Pkg-openldap-devel mailing list