summaryrefslogtreecommitdiff
path: root/debian/build/debian/sendmail-bin.prerm.in
blob: a478620b474bba3105870a8ae00d7a52c6ec4f21 (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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/sh -e
#
# Debian pre removal script
#
# Install of already installed package:
#	1) old-prerm upgrade new-version
#		*) new-prerm failed-upgrade old-version
#			*) old-postinst abort-upgrade new-version
#
# If a `conflicting' package is being removed at the same time:
#	1) forall packages depending on conflicting package and --auto-deconfigure
#		deconfigured's-prerm deconfigure \
#			in-favour package-being-installed version \
#			removing conflicting-package version
#		*) deconfigured's-postinst abort-deconfigure \
#				in-favour package-being-installed-but-failed version \
#				removing conflicting-package version
#	2) To prepare for removal of the conflicting package
#		conflictor's-prerm remove \
#			in-favour package new-version
#		*) conflictor's-postinst abort-remove \
#				in-favour package new-version
#
# Removal of a package:
#	1) prerm remove
#	2) The package's files are removed (except conffiles).
#	3) postrm remove
#	4) All the maintainer scripts except the postrm are removed.
#
set -e;

PACKAGE=sendmail-bin;

case "$1" in
	remove)
		if [ ! -z "$2" ]; then
			echo "Removing $PACKAGE $2 $3($4)";
			if [ "$PACKAGE" = 'sendmail' ] && [ "$3" = 'sendmail-tls' ] || \
				[ "$PACKAGE" = 'sendmail-tls' ] && [ "$3" = 'sendmail' ]; then
				echo '...Nothing to do...';
				exit 0;
				fi;
			fi;
		# Remove alternatives for MTA, MSP
		update-alternatives --remove sendmail-mta @libexecdir@/sendmail;
		update-alternatives --remove sendmail-msp @libexecdir@/sendmail;
		if [ -x @sysconfdir@/init.d/sendmail ] && \
			[ -x @datadir@/sendmail/sendmail ]; then
			if [ -x /usr/sbin/invoke-rc.d ]; then
				/usr/sbin/invoke-rc.d --quiet --force sendmail stop;
			else
				@sysconfdir@/init.d/sendmail stop;
				fi;
			fi;
		# Prevent cronjob from running during upgrade...
		if [ -f /etc/cron.d/sendmail ]; then
			rm -f @sysconfdir@/cron.d/sendmail;
			fi;
		;;

	upgrade)
		# Prevent cronjob from running during upgrade...
		if [ -f /etc/cron.d/sendmail ]; then
			echo "#prerm" > @sysconfdir@/cron.d/sendmail;
			fi;

		# NOTE  NOTE  NOTE  NOTE  NOTE
		# If we fall through to DEBHELPER, sendmail will be stopped
		# much earlier than necessary !!!
		exit 0;
		;;

	failed-upgrade)
		;;

	deconfigure)
		echo "Deconfigure of $PACKAGE $2 $3($4) $5 $6($7) ";
		;;

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

#
# Included for sanity checks
#
#DEBHELPER#
exit 0;