generira certifikat ako ga nema
[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   cp_check_and_sed '#ssl_cert = </etc/dovecot/dovecot.pem' \
50                    's|#ssl_cert = </etc/dovecot/dovecot.pem|ssl_cert = </etc/dovecot/dovecot.pem|g' \
51                    /etc/dovecot/conf.d/10-ssl.conf || true
52   cp_check_and_sed '#ssl_key = </etc/dovecot/private/dovecot.pem' \
53                    's|#ssl_key = </etc/dovecot/private/dovecot.pem|ssl_key = </etc/dovecot/private/dovecot.pem|g' \
54                    /etc/dovecot/conf.d/10-ssl.conf || true
55
56   echo "CN: Generating certificate and key..."
57   /usr/share/dovecot-cn/mkcert.sh > /dev/null
58 fi
59
60
61
62 # dodao ico, gasi stare SSL protokole
63 cp_check_and_sed '#ssl_protocols =' \
64                  's/^#ssl_protocols.*/ssl_protocols = !SSLv2 !SSLv3/g' \
65                  /etc/dovecot/conf.d/10-ssl.conf || true
66
67 # restart 
68 if [ -x /usr/sbin/invoke-rc.d ]; then
69   [ -x /etc/init.d/dovecot ] && invoke-rc.d dovecot restart
70 else
71   [ -x /etc/init.d/dovecot ] && /etc/init.d/dovecot restart
72 fi
73
74 #DEBHELPER#
75
76 exit 0