summaryrefslogtreecommitdiffstats
path: root/debian/postfix.preinst
blob: cd84edb9c3e28fafd982215ba0e1a0f23861f9fa (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
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
#!/bin/sh

set -e

# Debian Postfix preinst
# LaMont Jones <lamont@debian.org>
# Modified to use debconf by Colin Walters <levanti@verbum.org>

# do we have debconf?
if [ -f /usr/share/debconf/confmodule ]; then
    . /usr/share/debconf/confmodule
    DEBCONF=true
else
    DEBCONF=
fi

(umask 022; mkdir -p /var/spool/postfix)

case "$1" in
    install)
	rm -f /var/spool/postfix/restart /var/spool/postfix/reload

	if [ -L /etc/postfix/postfix-script ]; then
		rm -f /etc/postfix/postfix-script
	fi

	;;

    upgrade)
	if [ -d /var/spool/postfix ] && [ -f /etc/postfix/main.cf ]; then
	    touch /var/spool/postfix/restart
	fi
	export LANG=C	# for the comparison of mail version...

	if [ -L /etc/postfix/postfix-script ]; then
		rm -f /etc/postfix/postfix-script
	fi

	# If user has not modified master/main.proto, move aside so new version
	# is installed (#991513)
        cmp -s /usr/share/postfix/main.cf.dist /etc/postfix/main.cf.proto && \
	    mv /etc/postfix/main.cf.proto /etc/postfix/main.cf.proto.old \
	    || echo "/etc/postfix/main.cf.proto modified, not updating."
        cmp -s /usr/share/postfix/master.cf.dist /etc/postfix/master.cf.proto && \
	    mv /etc/postfix/master.cf.proto /etc/postfix/master.cf.proto.old \
	    || echo "/etc/postfix/master.cf.proto modified, not updating."

	;;

    abort-upgrade)
	if [ -f /etc/postfix/main.cf.proto.old ]; then
	  mv /etc/postfix/main.cf.proto.old /etc/postfix/main.cf.proto
	  echo "Restoring old /etc/postfix/main.cf.proto on failed upgrade."
	fi
	if [ -f /etc/postfix/master.cf.proto.old ]; then
	  mv /etc/postfix/master.cf.proto.old /etc/postfix/master.cf.proto
	  echo "Restoring old /etc/postfix/master.cf.proto on failed upgrade."
	fi
	;;

    *)
	echo "preinst called with unknown argument \`$1'" >&2
	exit 1
	;;
esac

if [ install = "$1" ] || [ upgrade = "$1" ]; then
    # cleanup after past mistakes.
    rm -f /usr/sbin/postconf.postfix
    dpkg-divert --package postfix-tls --remove \
	 --divert /usr/sbin/postconf.postfix \
		  /usr/sbin/postconf >/dev/null 2>/dev/null
fi

#DEBHELPER#