File: sasl2-bin.postinst

package info (click to toggle)
cyrus-sasl2 2.1.23.dfsg1-7
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 8,692 kB
  • ctags: 7,265
  • sloc: ansic: 50,844; sh: 12,869; java: 1,614; xml: 1,498; makefile: 649; perl: 11
file content (96 lines) | stat: -rw-r--r-- 2,833 bytes parent folder | download
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/sh
# postinst script for sasl2-bin
# Copyright (c) 2006 Fabian Fagerholm
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

set -e

FALLBACK_RUN_DIR=/var/run/saslauthd
SASLDB_FILE=/etc/sasldb2

# Debconf hook.
. /usr/share/debconf/confmodule

case "$1" in
	configure)
		# Upgrade SASL database if needed
		# The libdb dependency was updated in the following versions:
		#  2.1.22.dfsg1-14 (db4.2 -> db4.4)
		#  2.1.22.dfsg1-17 (db4.4 -> db4.6)
		#  2.1.22.dfsg1-24 (db4.6 -> db4.7)
		#  2.1.23.dfsg1-4 (db4.7 -> db4.8)
		if dpkg --compare-versions "$2" "lt-nl" 2.1.23.dfsg1-4; then
			
			# If the database contains no users, just wipe it out,
			# it will be recreated later in the current format
			if [ -e $SASLDB_FILE ] && \
				[ `sasldblistusers2 | wc -l` -eq 0 ]; then
				rm $SASLDB_FILE
			elif [ -e $SASLDB_FILE ]; then
				# The database exists and has users, begin upgrade procedure

				# Make backup and handle errors
				db_get cyrus-sasl2/backup-sasldb2
				if ! cp --archive $SASLDB_FILE "$RET" >/dev/null 2>&1; then
					db_input high cyrus-sasl2/upgrade-sasldb2-backup-failed || true
					db_go || true
					exit 1
				fi

				# Upgrade SASL database and handle errors
				if ! db4.8_upgrade $SASLDB_FILE >/dev/null 2>&1; then
					db_input high cyrus-sasl2/upgrade-sasldb2-failed || true
					db_go || true
					cp --archive "$RET" $SASLDB_FILE >/dev/null 2>&1
					exit 1
				fi
			fi
		fi

		# Create a statoverride for the default saslauthd run directory,
		# unless one already exists
		if ! dpkg-statoverride --list $FALLBACK_RUN_DIR >/dev/null 2>&1; then
			install -d --owner="root" --group="sasl" --mode="710" \
				$FALLBACK_RUN_DIR
			dpkg-statoverride --update --add root sasl 710 $FALLBACK_RUN_DIR
		fi

		# Create an empty sasldb file, unless one already exists
		if [ ! -e $SASLDB_FILE ]; then
			echo '!' | saslpasswd2 -c 'no:such:user'
			saslpasswd2 -d 'no:such:user'
		fi

		# Create a statoverride for the sasldb file, unless one already exists
		if ! dpkg-statoverride --list $SASLDB_FILE >/dev/null 2>&1; then
			dpkg-statoverride --update --add root sasl 660 $SASLDB_FILE
		fi

		# In 2.1.23.dfsg1-4 and later versions, saslauthd is no longer
		# explicitly stopped on shutdown and reboot.
		if dpkg --compare-versions "$2" lt "2.1.23.dfsg1-4"; then
			rm -f /etc/rc0.d/K20saslauthd /etc/rc6.d/K20saslauthd
		fi

		db_stop

		;;

	abort-upgrade|abort-remove|abort-deconfigure)
		;;

	*)
		echo "postinst called with unknown argument $1" >&2
		exit 0
		;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0