~ubuntu-dev/ubuntu/lucid/dovecot/lucid-201002101901

« back to all changes in this revision

Viewing changes to debian/dovecot-postfix.postinst

  • Committer: Bazaar Package Importer
  • Author(s): Mathias Gug, Ante Karamatic, Mathias Gug
  • Date: 2009-03-31 18:43:06 UTC
  • Revision ID: james.westby@ubuntu.com-20090331184306-0x78x9v6iiw8ja2v
Tags: 1:1.1.11-0ubuntu3
[ Ante Karamatic ]
* Add SMTP-AUTH support for Outlook (login auth mechanism)
* debian/dovecot-postfix.postinst:
  - merge user's custom changes from dovecot.conf (LP: #339966)

[ Mathias Gug ]
* properly support package upgrades.
* handle reinstallation of package if it wasn't purged. Based on Ante's
  patch:
  + debian/dovecot-postfix.postinst, debian/dovecot-posftix.postrm:
    - rename configuration name on remove, delete on purge
  + debian/dovecot-postfix.dirs
    - create backup directory for postfix's configuration

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
set -e
4
4
 
5
 
if [ "$1" = "configure" -a -z "$2" ]; then
6
 
        ucfr dovecot-postfix /etc/dovecot/dovecot-postfix.conf
7
 
 
8
 
        # Write new configuration file
9
 
        ucf /usr/share/dovecot/dovecot-postfix.conf /etc/dovecot/dovecot-postfix.conf
10
 
 
11
 
        # Create initial symlinks for certificates
12
 
        if [ ! -e "/etc/ssl/private/ssl-mail.key" ]; then
13
 
                ln -s /etc/ssl/private/ssl-cert-snakeoil.key /etc/ssl/private/ssl-mail.key
14
 
        fi
15
 
        if [ ! -e "/etc/ssl/certs/ssl-mail.pem" ]; then
16
 
                ln -s /etc/ssl/certs/ssl-cert-snakeoil.pem /etc/ssl/certs/ssl-mail.pem
17
 
        fi
18
 
        if [ -x "/usr/sbin/postconf" ]; then
19
 
                postconf -e "home_mailbox = Maildir/"
20
 
                postconf -e "smtpd_sasl_auth_enable = yes"
21
 
                postconf -e "smtpd_sasl_type = dovecot"
22
 
                postconf -e "smtpd_sasl_path = private/dovecot-auth"
23
 
                postconf -e "smtpd_sasl_authenticated_header = yes"
24
 
                postconf -e "smtpd_sasl_security_options = noanonymous"
25
 
                postconf -e "smtpd_sasl_local_domain = $myhostname"
26
 
                postconf -e "broken_sasl_auth_clients = yes"
27
 
                postconf -e "smtpd_recipient_restrictions = reject_unknown_sender_domain, reject_unknown_recipient_domain, reject_unauth_pipelining, permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination"
28
 
                postconf -e "smtpd_sender_restrictions = reject_unknown_sender_domain"
29
 
                postconf -e "mailbox_command = /usr/lib/dovecot/deliver -c /etc/dovecot/dovecot-postfix.conf -n -m \"\${EXTENSION}\""
30
 
                postconf -e "smtpd_tls_cert_file = /etc/ssl/certs/ssl-mail.pem"
31
 
                postconf -e "smtpd_tls_key_file = /etc/ssl/private/ssl-mail.key"
32
 
                postconf -e "smtpd_use_tls = yes"
33
 
                postconf -e "smtp_use_tls = yes"
34
 
                postconf -e "smtpd_tls_received_header = yes"
35
 
                postconf -e "smtpd_tls_mandatory_protocols = SSLv3, TLSv1"
36
 
                postconf -e "smtpd_tls_mandatory_ciphers = medium, high"
37
 
                postconf -e "smtpd_tls_auth_only = yes"
38
 
                postconf -e "tls_random_source = dev:/dev/urandom"
39
 
 
40
 
                if [ -x "/etc/init.d/postfix" ]; then
41
 
                        if [ -x /usr/sbin/invoke-rc.d ]; then
42
 
                                invoke-rc.d postfix reload
43
 
                        else
44
 
                                /etc/init.d/postfix reload
45
 
                        fi
46
 
                fi
47
 
        fi
48
 
if [ -x "/etc/init.d/dovecot" ]; then
49
 
                if [ -x /usr/sbin/invoke-rc.d ]; then
50
 
                        invoke-rc.d dovecot restart
51
 
                else
52
 
                        /etc/init.d/dovecot restart
53
 
                fi
54
 
        fi
 
5
POSTFIX_BCKFILE="/var/backups/dovecot-postfix/main.cf-backup"
 
6
 
 
7
set_postfix_option() {
 
8
        opt="$1"
 
9
        # Backup the existion value of the option
 
10
        postconf $(echo ${opt} | cut -d= -f1) >> ${POSTFIX_BCKFILE} || true
 
11
        # Set the new value of the option
 
12
        postconf -e "${opt}"
 
13
}
 
14
 
 
15
if [ "$1" = "configure" ]; then
 
16
        # Move disabled dovecot-postfix.conf file back to the original place
 
17
        # to renable the postfix integration in dovecot.
 
18
        if [ -f "/etc/dovecot/dovecot-postfix.conf.disabled" ]; then
 
19
                mv /etc/dovecot/dovecot-postfix.conf.disabled /etc/dovecot/dovecot-postfix.conf
 
20
        fi
 
21
        # Check if the existing dovecot configuration file had
 
22
        # local modification made
 
23
        # Exclude the protocol option since it's changed by the -pop
 
24
        # and -imap packages during their installation
 
25
        if [ ! -f "/etc/dovecot/dovecot-postfix.conf" ]; then
 
26
                DIR=`mktemp -d`
 
27
                egrep -v ^protocol /etc/dovecot/dovecot.conf > $DIR/dovecot-custom.conf
 
28
                egrep -v ^protocol /usr/share/dovecot/dovecot.conf > $DIR/dovecot.conf
 
29
                if ! diff -qur $DIR/dovecot-custom.conf $DIR/dovecot.conf 1>/dev/null 2>&1; then
 
30
                        cp /etc/dovecot/dovecot.conf /etc/dovecot/dovecot-postfix.conf
 
31
                fi
 
32
                rm -rf $DIR
 
33
        fi
 
34
        ucf --three-way /usr/share/dovecot/dovecot-postfix.conf /etc/dovecot/dovecot-postfix.conf
 
35
        if which ucfr >/dev/null; then
 
36
                ucfr dovecot-postfix /etc/dovecot/dovecot-postfix.conf
 
37
        fi
 
38
        if [ -x "/etc/init.d/dovecot" ]; then
 
39
                if [ -x /usr/sbin/invoke-rc.d ]; then
 
40
                        invoke-rc.d dovecot restart
 
41
                else
 
42
                        /etc/init.d/dovecot restart
 
43
                fi
 
44
        fi
 
45
        # Create initial symlinks for certificates
 
46
        if [ ! -e "/etc/ssl/private/ssl-mail.key" ]; then
 
47
                ln -s /etc/ssl/private/ssl-cert-snakeoil.key /etc/ssl/private/ssl-mail.key
 
48
        fi
 
49
        if [ ! -e "/etc/ssl/certs/ssl-mail.pem" ]; then
 
50
                ln -s /etc/ssl/certs/ssl-cert-snakeoil.pem /etc/ssl/certs/ssl-mail.pem
 
51
        fi
 
52
        # Configure postfix either on new install 
 
53
        # or if the postfix backup file is no longer there 
 
54
        # (only deleted when the pkg is removed)
 
55
        if [ -z "$2" -o ! -e "$POSTFIX_BCKFILE" ]; then
 
56
                if which postconf >/dev/null; then
 
57
                        # Setup postfix
 
58
                        set_postfix_option "home_mailbox = Maildir/"
 
59
                        set_postfix_option "smtpd_sasl_auth_enable = yes"
 
60
                        set_postfix_option "smtpd_sasl_type = dovecot"
 
61
                        set_postfix_option "smtpd_sasl_path = private/dovecot-auth"
 
62
                        set_postfix_option "smtpd_sasl_authenticated_header = yes"
 
63
                        set_postfix_option "smtpd_sasl_security_options = noanonymous"
 
64
                        set_postfix_option "smtpd_sasl_local_domain = \$myhostname"
 
65
                        set_postfix_option "broken_sasl_auth_clients = yes"
 
66
                        set_postfix_option "smtpd_recipient_restrictions = reject_unknown_sender_domain, reject_unknown_recipient_domain, reject_unauth_pipelining, permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination"
 
67
                        set_postfix_option "smtpd_sender_restrictions = reject_unknown_sender_domain"
 
68
                        set_postfix_option "mailbox_command = /usr/lib/dovecot/deliver -c /etc/dovecot/dovecot-postfix.conf -n -m \"\${EXTENSION}\""
 
69
                        set_postfix_option "smtpd_tls_cert_file = /etc/ssl/certs/ssl-mail.pem"
 
70
                        set_postfix_option "smtpd_tls_key_file = /etc/ssl/private/ssl-mail.key"
 
71
                        set_postfix_option "smtpd_use_tls = yes"
 
72
                        set_postfix_option "smtp_use_tls = yes"
 
73
                        set_postfix_option "smtpd_tls_received_header = yes"
 
74
                        set_postfix_option "smtpd_tls_mandatory_protocols = SSLv3, TLSv1"
 
75
                        set_postfix_option "smtpd_tls_mandatory_ciphers = medium, high"
 
76
                        set_postfix_option "smtpd_tls_auth_only = yes"
 
77
                        set_postfix_option "tls_random_source = dev:/dev/urandom"
 
78
                fi
 
79
        fi
 
80
        if [ -x "/etc/init.d/postfix" ]; then
 
81
                if [ -x /usr/sbin/invoke-rc.d ]; then
 
82
                        invoke-rc.d postfix restart
 
83
                else
 
84
                        /etc/init.d/postfix restart
 
85
                fi
 
86
        fi
55
87
fi
56
88
 
57
89
#DEBHELPER#