Make it work with newer Debian stuff.
[qmail] / debian / prerm
CommitLineData
9312c29d
MW
1#!/usr/bin/perl
2
3require DebianNet;
4
5$| = 1;
6
7$action = shift;
8
9if ( $action eq 'failed-upgrade' ) {
10 exit 1;
11}
12
13if ( $action eq 'upgrade' or $action eq 'deconfigure' ) {
14 system("/etc/init.d/qmail stop");
15 exit $? if $?;
16 DebianNet::disable_service('smtp');
17 exit 0;
18}
19
20if ( $action eq 'remove' ) {
21 # Ask for confirmation if there are still messages in qmail's queue.
22 $mesg_inqueue = `find /var/qmail/queue/mess -type f -print | wc -l`;
23 $mesg_inqueue =~ s/\s//g;
24 $mesg_unprocessed = `find /var/qmail/queue/todo -type f -print | wc -l`;
25 $mesg_unprocessed =~ s/\s//g;
26
27 if ( $mesg_inqueue != 0 || $mesg_unprocessed != 0 ) {
28 print STDERR <<EOT;
29There are still messages in qmail's queue. You probably want to wait until
30qmail's queue is empty before removing the qmail package. Otherwise
31the messages currently waiting in the queue will not be delivered or will be
32lost. (\`qmail-qstat' will tell you the number of messages in qmail's queue.)
33
34EOT
35
36 print STDERR 'Do you still want to proceed and remove the qmail package? [y/N] ';
37 my $answer = <STDIN>;
38 exit 1 unless $answer =~ /^\s*[yY]/;
39 }
40
41 # Remove qmail-smtpd from inetd.conf
42 DebianNet::remove_service('smtp\s+stream\s+tcp\s+nowait\s+qmaild.*/usr/sbin/qmail-smtpd');
43
44 # Stop qmail process.
45 system("/etc/init.d/qmail stop");
46 exit $? if $?;
47}
48
bcb3f3eb
MW
49unlink("/usr/doc/qmail");
50
9312c29d 51exit 0;
bcb3f3eb
MW
52
53__END__;