5
if [ "$1" = "configure" -a -z "$2" ]; then
6
ucfr dovecot-postfix /etc/dovecot/dovecot-postfix.conf
8
# Write new configuration file
9
ucf /usr/share/dovecot/dovecot-postfix.conf /etc/dovecot/dovecot-postfix.conf
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
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
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"
40
if [ -x "/etc/init.d/postfix" ]; then
41
if [ -x /usr/sbin/invoke-rc.d ]; then
42
invoke-rc.d postfix reload
44
/etc/init.d/postfix reload
48
if [ -x "/etc/init.d/dovecot" ]; then
49
if [ -x /usr/sbin/invoke-rc.d ]; then
50
invoke-rc.d dovecot restart
52
/etc/init.d/dovecot restart
5
POSTFIX_BCKFILE="/var/backups/dovecot-postfix/main.cf-backup"
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
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
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
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
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
38
if [ -x "/etc/init.d/dovecot" ]; then
39
if [ -x /usr/sbin/invoke-rc.d ]; then
40
invoke-rc.d dovecot restart
42
/etc/init.d/dovecot restart
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
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
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
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"
80
if [ -x "/etc/init.d/postfix" ]; then
81
if [ -x /usr/sbin/invoke-rc.d ]; then
82
invoke-rc.d postfix restart
84
/etc/init.d/postfix restart