From c4d63e35e8e5d98e0a78c2f5f5c1b4f08cd00fa1 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Thu, 1 Jan 2009 15:20:50 +0100 Subject: [PATCH] ldap: Interpolate the backupdir config variable. --- examples/example.ldap | 4 +++- handlers/ldap.in | 10 +++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/examples/example.ldap b/examples/example.ldap index 66a0aa3..6fec13f 100644 --- a/examples/example.ldap +++ b/examples/example.ldap @@ -7,7 +7,9 @@ ## ldapadd without being reordered. ## -## backupdir (default /var/backups/ldap): the destination for the backups +## backupdir (default /var/backups/ldap): the destination for the backups. +## This variable is interpolated, see backup.d (5) for which variables are +## available. # backupdir = /var/backups/ldap ## conf (default /etc/ldap/slapd.conf): the location of the slapd.conf file. diff --git a/handlers/ldap.in b/handlers/ldap.in index 83d6a6f..6ef9948 100644 --- a/handlers/ldap.in +++ b/handlers/ldap.in @@ -56,18 +56,18 @@ make_backup() { vexec="$VSERVER $vsname exec" fi + dumpdir=`interpolate "$backupdir" "$vsname"` + info "Backing up to dir '$dumpdir'" + [ -f $vdir$conf ] || fatal "slapd config file ($conf) not found" - [ -d $backupdir ] || mkdir -p $backupdir - [ -d $backupdir ] || fatal "Backup directory '$backupdir'" + [ -d $dumpdir ] || mkdir -p $dumpdir + [ -d $dumpdir ] || fatal "Backup directory '$dumpdir'" dbsuffixes=(`@AWK@ 'BEGIN {OFS=":"} /[:space:]*^database[:space:]*\w*/ {db=$2}; /^[:space:]*suffix[:space:]*\w*/ {if (db=="bdb"||db=="hdb"||db="ldbm") print db,$2}' $vdir$conf|@SED@ -e 's/[" ]//g'`) ## LDIF DUMP if [ "$ldif" == "yes" ]; then - dumpdir="$backupdir" - [ -d $dumpdir ] || mkdir -p $dumpdir - if [ "$databases" == 'all' ]; then dbcount=`grep '^database' $vdir$conf | wc -l` let "dbcount = dbcount - 1" -- 2.30.2