[Pkg-openldap-devel] [openldap] 08/29: r1441 at pulsar: torsten | 2005-03-16 22:40:24 +0100 More hacking on the maintainer scripts
Timo Aaltonen
tjaalton-guest at alioth.debian.org
Thu Oct 10 05:34:48 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-0.pre6
in repository openldap.
commit 8b84bff300545bad0de40ef237b6737dc8591667
Author: Torsten Landschoff <torsten at debian.org>
Date: Fri Mar 18 12:06:17 2005 +0000
r1441 at pulsar: torsten | 2005-03-16 22:40:24 +0100
More hacking on the maintainer scripts
---
debian/slapd.postinst | 51 ++++++++++---------------------------------
debian/slapd.scripts-common | 43 +++++++++++++++++++++++++++++++++++-
2 files changed, 54 insertions(+), 40 deletions(-)
diff --git a/debian/slapd.postinst b/debian/slapd.postinst
index 68ca4ee..b49b77b 100644
--- a/debian/slapd.postinst
+++ b/debian/slapd.postinst
@@ -2,6 +2,9 @@
set -e
+# TODO:
+# - capture slapadd, slapcat output so it does not overwrite the progress display
+
# This will be replaced with debian/slapd.scripts-common which includes
# various helper functions and $OLD_VERSION and $SLAPD_CONF
#SCRIPTSCOMMON#
@@ -24,12 +27,14 @@ compute_backup_path() { # {{{
# exists to be really sure... -- Torsten
local target
- target=`echo "$dirname"|cut -c 2-|tr / _`-`date +%Y%m%d-%H:%M:%S`
- if [ -e "/var/backups/$target" ]; then
+ target="/var/backups/$suffix.ldapdb"
+ if [ -e "$target" ]; then
+ echo >&2
echo >&2 " Backup path $target exists. Giving up..."
+ exit 1
fi
- echo "/var/backups/$target"
+ echo "$target"
}
# }}}
@@ -50,6 +55,7 @@ move_old_database_away() { # {{{
if is_empty_dir "$databasedir"; then
return
fi
+
# Note that we can't just move the database dir as it might be
# a mount point. Instead me move the content which might
@@ -57,7 +63,7 @@ move_old_database_away() { # {{{
db_get slapd/move_old_database
if [ "$RET" = true ]; then
backupdir=`compute_backup_path "$databasedir" "$suffix"`
- echo -n " Moving $databasedir to $backupdir... " >&2
+ echo -n " - directory $suffix... " >&2
mkdir -p "$backupdir"
mv "$databasedir"/* "$backupdir"/
echo done. >&2
@@ -453,42 +459,9 @@ fi
update_access_config_directives
# }}}
-# BROKEN - please fix the following mess!! -- Torsten
-
-# Dump and reload the database if file format changed # {{{
-if database_might_need_reload; then
- get_database_list | while read backend suffix directory
- do
- suffix=`eval echo $suffix`
- directory=`eval echo $directory`
- location=`ldif_dump_location "$suffix"`
-
- if ! test -e "$location"; then
- continue
- fi
-
- # XXX: to be truly idempotent, we should make sure we don't try
- # to overwrite this ldif file on a second pass after already
- # having moved some of the files aside below.
-
- database_needs_reload "$backend" || database_needs_fixing \
- || continue
-
- if database_needs_fixing; then
- fix_ldif "$location" "${location}.new"
- else
- cp -al "$location" "$location.new"
- fi
- move_old_database_away "$directory" "$suffix"
- import_database "$suffix" "${location}.new"
-
- # Since this is actually a subshell, we need to explicitly call
- # exit: otherwise, the errors won't be caught, and the rm
- # command below gets run!
- done || exit $?
-fi
-# }}}
+move_incompatible_databases_away
+load_databases
db_stop || true
diff --git a/debian/slapd.scripts-common b/debian/slapd.scripts-common
index a95763f..5372122 100644
--- a/debian/slapd.scripts-common
+++ b/debian/slapd.scripts-common
@@ -98,9 +98,11 @@ database_dumping_destdir() { # {{{
# }}}
# }}}
-# ----- Dumping the data ------------------------------------------------ {{{
+# ----- Dumping and loading the data ------------------------------------ {{{
dump_databases() { # {{{
+# If the user wants us to dump the databases they are dumped to the
+# configured directory.
local db suffix file dir failed
@@ -126,6 +128,45 @@ dump_databases() { # {{{
}
# }}}
+load_databases() { # {{{
+ local dir file db dbdir
+
+ dir=`database_dumping_destdir`
+ echo >&2 " Loading from $dir: "
+ parse_configuration_file
+ for db in `get_database_list`; do
+ suffix=`get_suffix $db`
+ dbdir=`get_directory $db`
+ if ! is_empty_dir "$dbdir"; then
+ echo >&2 \
+ " Directory $dbdir for $suffix not empty, aborting."
+ exit 1
+ fi
+
+ file="$dir/$suffix.ldif"
+ echo -n " - directory $suffix... " >&2
+ slapadd -b "$suffix" -l "$file" || failed=1
+ if [ "$failed" ]; then
+ rm -f "$dbdir/*"
+ echo failed. >&2
+ exit 1
+ fi
+ echo "done." >&2
+ done
+}
+
+# }}}
+move_incompatible_databases_away() { # {{{
+ echo >&2 " Moving old database directories to /var/backups:"
+ parse_configuration_file
+ for db in `get_database_list`; do
+ suffix=`get_suffix $db`
+ dbdir=`get_directory $db`
+ move_old_database_away "$dbdir" "$suffix"
+ done
+}
+
+# }}}
# }}}
# }}}
--
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