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

mkdir -Zp -m755 /var/spool/postfix

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

    upgrade)
	if [ -d /var/spool/postfix ] && [ -f /etc/postfix/main.cf ]; then
	    touch /var/spool/postfix/restart
	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

#DEBHELPER#