2afcf7adf1dd1f0b8a7f6cb808f77cd7ff83eb7b
[dovecot-cn.git] / debian / postinst
1 #!/bin/sh -e
2
3 [ "$1" = "configure" ] || exit 0
4 [ "$DEBIAN_SCRIPT_DEBUG" ] && set -vx
5
6 # Load CARNet Tools
7 . /usr/share/carnet-tools/functions.sh
8
9 cp_check_and_sed '#disable_plaintext_auth' \
10                  's/#disable_plaintext_auth/disable_plaintext_auth/g' \
11                  /etc/dovecot/conf.d/10-auth.conf || true
12
13 cp_check_and_sed 'disable_plaintext_auth.*yes' \
14                  's/disable_plaintext_auth.*$/disable_plaintext_auth = no/g' \
15                  /etc/dovecot/conf.d/10-auth.conf || true
16
17 cp_check_and_sed '#imap_client_workarounds' \
18                  's/#imap_client_workarounds/imap_client_workarounds/g' \
19                  /etc/dovecot/conf.d/20-imap.conf || true
20
21 cp_check_and_sed '#pop3_client_workarounds' \
22                  's/#pop3_client_workarounds/pop3_client_workarounds/g' \
23                  /etc/dovecot/conf.d/20-pop3.conf || true
24
25 cp_check_and_sed 'imap_client_workarounds' \
26                  's/imap_client_workarounds.*$/imap_client_workarounds = delay-newmail tb-extra-mailbox-sep tb-lsub-flags/g' \
27                  /etc/dovecot/conf.d/20-imap.conf || true
28
29 cp_check_and_sed 'pop3_client_workarounds' \
30                  's/pop3_client_workarounds.*$/pop3_client_workarounds = outlook-no-nuls oe-ns-eoh/g' \
31                  /etc/dovecot/conf.d/20-pop3.conf || true
32
33 cp_check_and_sed '#ssl_cipher_list' \
34                  's/#ssl_cipher_list.*/ssl_cipher_list = ALL:!aNULL:!eNULL:!ADH!LOW:!MEDIUM:!EXP:!SSLv2:HIGH/g' \
35                  /etc/dovecot/conf.d/10-ssl.conf || true
36
37 # trazio zelja
38 cp_check_and_sed '#ssl =' \
39                  's/^#ssl =/ssl =/g' \
40                  /etc/dovecot/conf.d/10-ssl.conf || true
41
42 # trazio zelja
43 cp_check_and_sed 'ssl = no' \
44                  's/^ssl = no/ssl = yes/g' \
45                  /etc/dovecot/conf.d/10-ssl.conf || true
46
47 if ! grep -q ^ssl_cert /etc/dovecot/conf.d/10-ssl.conf \
48   && ! grep -q ^ssl_key /etc/dovecot/conf.d/10-ssl.conf; then
49
50   if [ ! -f /etc/dovecot/dovecot.pem -a ! -f /etc/dovecot/private/dovecot.pem ]; then
51     echo "CN: Generating certificate and key..."
52     /usr/share/dovecot-cn/mkcert.sh || true
53   fi
54
55   cp_check_and_sed '#ssl_cert = </etc/dovecot/dovecot.pem' \
56                    's|#ssl_cert = </etc/dovecot/dovecot.pem|ssl_cert = </etc/dovecot/dovecot.pem|g' \
57                    /etc/dovecot/conf.d/10-ssl.conf || true
58   cp_check_and_sed '#ssl_key = </etc/dovecot/private/dovecot.pem' \
59                    's|#ssl_key = </etc/dovecot/private/dovecot.pem|ssl_key = </etc/dovecot/private/dovecot.pem|g' \
60                    /etc/dovecot/conf.d/10-ssl.conf || true
61 fi
62
63
64
65 # dodao ico, gasi stare SSL protokole
66 cp_check_and_sed '#ssl_protocols =' \
67                  's/^#ssl_protocols.*/ssl_protocols = !SSLv2 !SSLv3/g' \
68                  /etc/dovecot/conf.d/10-ssl.conf || true
69
70 # restart 
71 if [ -x /usr/sbin/invoke-rc.d ]; then
72   [ -x /etc/init.d/dovecot ] && invoke-rc.d dovecot restart
73 else
74   [ -x /etc/init.d/dovecot ] && /etc/init.d/dovecot restart
75 fi
76
77 #DEBHELPER#
78
79 exit 0