chiark / gitweb /
Merge branches 'idx/verh' and 'idx/qmqpc'
[qmail] / debian / prerm
1 #!/usr/bin/perl
2
3 require DebianNet;
4
5 $| = 1;
6
7 $action = shift;
8
9 if ( $action eq 'failed-upgrade' ) {
10     exit 1;
11 }
12
13 if ( $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
20 if ( $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;
29 There are still messages in qmail's queue. You probably want to wait until
30 qmail's queue is empty before removing the qmail package. Otherwise 
31 the messages currently waiting in the queue will not be delivered or will be 
32 lost. (\`qmail-qstat' will tell you the number of messages in qmail's queue.)
33
34 EOT
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
49 unlink("/usr/doc/qmail");
50
51 exit 0;
52
53 __END__;