summaryrefslogtreecommitdiffstats
path: root/debian/slapd.prerm
blob: ab8b991dcf0cf636c8bd4264211083c0f4922793 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/sh

set -e

. /usr/share/debconf/confmodule

# This will be replaced with debian/slapd.scripts-common which includes
# various helper functions and $OLD_VERSION and $SLAPD_CONF
#SCRIPTSCOMMON#

# dh_installinit's --error-handler option requires that the
# error-handling function be defined in the prerm and postinst
# scripts.  This function is declared here as a formality, but we do
# not want to ignore the init script failure during the prerm phase.
ignore_init_failure() {							# {{{
	:
}
# }}}

#DEBHELPER#

# Workaround for #1006147. Debhelper changed to stop the service in
# preinst instead of prerm. However, dpkg-reconfigure doesn't run
# preinst yet.
if [ "$MODE" = upgrade ] && [ -x /etc/init.d/slapd ]; then
	invoke-rc.d slapd stop || exit 1
fi

# Dump config and data to LDIF before removing slapd.
# If a later version is reinstalled without being purged first, the LDIF
# files may be required for the upgrade, and the old slapcat won't be
# available any more.
# During an upgrade, the new preinst will be in a better position to
# control whether dumping is needed.

# If the config is badly broken, slapcat may fail, but this should not
# prevent the package from being removed or purged.
set +e

if [ "$MODE" = remove ]; then
	# scripts-common sets OLD_VERSION incorrectly for remove
	OLD_VERSION="$(dpkg-query -W -f '${Version}' slapd)"

	dump_config
	dump_databases
fi

exit 0

# vim: set foldmethod=marker: