~ubuntu-branches/ubuntu/saucy/sendmail/saucy-proposed

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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/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-base;

case "$1" in
	remove)
		if [ ! -z "$2" ]; then
			echo "Removing $PACKAGE $2 $3($4)";
			fi;

		if [ -x /usr/sbin/update-inetd ]; then
			update-inetd --group MAIL --disable smtp,smtps,submission;
			fi;

		# Make sure /etc/aliases is left (move it from /etc/mail if needed)
		if [ -L /etc/mail/aliases ]; then
			rm -f /etc/mail/aliases;
		elif [ -f /etc/mail/aliases ] \
		&&   [ -L /etc/aliases ]; then
			mv /etc/mail/aliases /etc/aliases;
			fi;

		# Remove psuedo conffiles (managed by sendmail)
		rm -f	/etc/cron.d/sendmail;

		# Remove files scattered across the system that
		# happened to be created by sendmail
		rm -f /usr/lib/sasl/Sendmail.conf;

		# Remove those files created by sendmail
		rm -rf	/var/lib/sendmail;
		rm -rf	/var/run/sendmail;
		# Note: syslog really owns these files
		#rm -f	/var/log/mail/*;
		#rm -f	/var/log/mail.log;
		# Note: these can lead to a loss of mail!!!!
		if [ -x /etc/init.d/sendmail ]; then
			/etc/init.d/sendmail clean;
			fi;
		if [ -L /var/spool/mqueue ]; then
			rmdir --ignore-fail-on-non-empty \
			`readlink -fn /var/spool/mqueue`;
		elif [ -d /var/spool/mqueue ]; then
			rmdir	--ignore-fail-on-non-empty \
				/var/spool/mqueue;
			fi;
		if [ -L /var/spool/mqueue-client ]; then
			rmdir	--ignore-fail-on-non-empty \
			`readlink -fn /var/spool/mqueue-client`;
		elif [ -d /var/spool/mqueue-client ]; then
			rmdir	--ignore-fail-on-non-empty \
				/var/spool/mqueue-client;
			fi;

		# Remove sendmail built configuration files
		rm -f	/etc/mail/*.db \
			/etc/mail/*.dir \
			/etc/mail/*.pag;
		rm -f	/etc/mail/sendmail.cf \
			/etc/mail/sendmail.cf.old \
			/etc/mail/sendmail.cf.errors \
			/etc/mail/sendmail.mc.old \
			/etc/mail/submit.cf \
			/etc/mail/submit.cf.errors \
			/etc/mail/submit.mc.old \
			/etc/mail/databases \
			/etc/mail/Makefile \
			;
		rm -rf /etc/mail/smrsh \
			/etc/mail/sasl \
			/etc/mail/tls;

		# Remove empty files (probably touched databases)
		find /etc/mail -maxdepth 1 -size 0 | xargs -r rm;
		;;

	upgrade)
		# Potentially move the old configuration file to the new name -
		# before it gets deleted (for not existing in the new package)
		mv -f /etc/default/sendmail \
			/etc/mail/sendmail.conf 2>/dev/null || true;

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

	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;

# The @DEBHELPER@ stuff causes problems with upgrades because of the
# length of time that Sendmail is stopped...

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