--- /dev/null
+#!/usr/bin/perl
+
+require DebianNet;
+
+$| = 1;
+
+my $action = shift;
+
+if ( $action eq 'configure' or $action eq 'abort-upgrade' or $action eq 'abort-deconfigure' or $action eq 'abort-remove' ) {
+ my $old_version = shift;
+
+ DebianNet::add_service('smtp stream tcp nowait qmaild /usr/sbin/tcpd /usr/bin/tcp-env /usr/sbin/qmail-smtpd',
+ "MAIL");
+ DebianNet::enable_service('smtp');
+
+ # Add rc?.d links
+ system('update-rc.d qmail defaults >/dev/null');
+
+ if ( ! -r '/var/qmail/control/me' ) {
+ system("/usr/sbin/qmailconfig");
+ }
+
+ if ( !defined($old_version) || $old_version eq '' ) {
+ print <<'EOT1';
+
+By default qmail will deliver mail to ~/Mailbox instead of /var/spool/mail.
+To learn how to deal with this, read the file /usr/doc/qmail/INSTALL.mbox.
+Disregard the warning in INSTALL.mbox about qmail-alias using flock to lock
+the mailbox.
+
+If you were using sendmail (or smail) previously, you will want to read
+the "qmail-upgrade" manpage, which details user-visible differences between
+sendmail and qmail.
+
+If you are new to qmail, you will want to at least peruse the qmail FAQ, which
+can be found in /usr/doc/qmail
+
+EOT1
+ print 'Do you want to start qmail now? [y/N] ';
+ my $answer = <STDIN>;
+ if ( $answer =~ /^\s*[yY]/ ) {
+ system("/etc/init.d/qmail start");
+ }
+ else {
+ print <<'EOT2';
+Qmail will be started at the next reboot. Or you can start qmail manually when
+you are ready by typing (as root) "/etc/init.d/qmail start" at a shell prompt.
+EOT2
+ }
+ }
+ else {
+ system("/etc/init.d/qmail start");
+ }
+}
+
+exit 0;
+