[Pkg-openldap-devel] [openldap] 11/17: Problem with reusing compute_backup_path, it bombs out if the directory exists. Add a "-n" option so that we can use it for picking up an existing backup path later.

Timo Aaltonen tjaalton-guest at alioth.debian.org
Thu Oct 10 05:35:34 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-3
in repository openldap.

commit f2803383e6330ac11a769d47d0464d1532c24ff1
Author: Steve Langasek <vorlon at debian.org>
Date:   Sun Apr 17 11:19:05 2005 +0000

    Problem with reusing compute_backup_path, it bombs out if the directory
    exists.  Add a "-n" option so that we can use it for picking up an
    existing backup path later.
---
 debian/slapd.scripts-common |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/debian/slapd.scripts-common b/debian/slapd.scripts-common
index 1a18c0c..ff4b1bf 100644
--- a/debian/slapd.scripts-common
+++ b/debian/slapd.scripts-common
@@ -155,7 +155,7 @@ load_databases() {							# {{{
 
 		# If there is an old DB_CONFIG file, restore it before
 		# running slapadd
-		backupdir=`compute_backup_path "$dbdir" "$suffix"`
+		backupdir=`compute_backup_path -n "$dbdir" "$suffix"`
 		if [ -e "$backupdir"/DB_CONFIG ]; then
 			cp -a "$backupdir"/DB_CONFIG "$dbdir"/
 		fi
@@ -345,11 +345,15 @@ get_database_list() {
 
 compute_backup_path() {							# {{{
 # Compute the path to backup a database directory
-# Usage: compute_backup_path <dir> <basedn>
+# Usage: compute_backup_path [-n] <dir> <basedn>
 
 # XXX: should ask the user via debconf
 
-	local dirname basedn
+	local dirname basedn ok_exists
+	if [ "$1" = "-n" ]; then
+		ok_exists=yes
+		shift
+	fi
 	dirname="$1"
 	basedn="$2"
 
@@ -365,7 +369,7 @@ compute_backup_path() {							# {{{
 	id="$OLD_VERSION"
 	[ -n "$id" ] || id=`date +%Y%m%d-%H%M%S`
 	target="/var/backups/$basedn-$id.ldapdb"
-	if [ -e "$target" ]; then
+	if [ -e "$target" ] && [ -z "$ok_exists" ]; then
 		echo >&2
 		echo >&2 "  Backup path $target exists. Giving up..."
 		exit 1

-- 
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