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