izmjene u postinstu
[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:!SSLv2:HIGH/g' \
37                  /etc/dovecot/conf.d/10-ssl.conf || true
38
39 # trazio zelja
40 cp_check_and_sed '#ssl =' \
41                  's/^#ssl =/ssl =/g' \
42                  /etc/dovecot/conf.d/10-ssl.conf || true
43
44 # trazio zelja
45 cp_check_and_sed 'ssl = no' \
46                  's/^ssl = no/ssl = yes/g' \
47                  /etc/dovecot/conf.d/10-ssl.conf || true
48
49 if ! grep -q ^ssl_cert /etc/dovecot/conf.d/10-ssl.conf \
50   && ! grep -q ^ssl_key /etc/dovecot/conf.d/10-ssl.conf; then
51
52   if [ ! -f /etc/dovecot/dovecot.pem -a ! -f /etc/dovecot/private/dovecot.pem ]; then
53     echo "CN: Generating certificate and key..."
54     /usr/share/dovecot-cn/mkcert.sh || true
55   fi
56
57   cp_check_and_sed '#ssl_cert = </etc/dovecot/dovecot.pem' \
58                    's|#ssl_cert = </etc/dovecot/dovecot.pem|ssl_cert = </etc/dovecot/dovecot.pem|g' \
59                    /etc/dovecot/conf.d/10-ssl.conf || true
60   cp_check_and_sed '#ssl_key = </etc/dovecot/private/dovecot.pem' \
61                    's|#ssl_key = </etc/dovecot/private/dovecot.pem|ssl_key = </etc/dovecot/private/dovecot.pem|g' \
62                    /etc/dovecot/conf.d/10-ssl.conf || true
63 fi
64
65
66
67 # dodao ico, gasi stare SSL protokole
68 cp_check_and_sed '#ssl_protocols =' \
69                  's/^#ssl_protocols.*/ssl_protocols = !SSLv2 !SSLv3/g' \
70                  /etc/dovecot/conf.d/10-ssl.conf || true
71
72 # restart 
73 service dovecot restart || true
74
75 #DEBHELPER#
76
77 exit 0