This file is indexed.

postinst is in dovecot-core 1:2.2.9-1ubuntu2.

This file is a maintainer script. It is executed when installing (*inst) or removing (*rm) the package.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
#!/bin/sh
set -e
. /usr/share/debconf/confmodule

if [ "$1" = "configure" ]; then
  CONFFILES="dovecot.conf \
    dovecot-dict-sql.conf.ext \
    dovecot-sql.conf.ext \
    conf.d/10-auth.conf \
    conf.d/10-director.conf \
    conf.d/10-logging.conf \
    conf.d/10-mail.conf \
    conf.d/10-master.conf \
    conf.d/10-ssl.conf \
    conf.d/10-tcpwrapper.conf \
    conf.d/15-lda.conf \
    conf.d/15-mailboxes.conf \
    conf.d/90-acl.conf \
    conf.d/90-plugin.conf \
    conf.d/90-quota.conf \
    conf.d/auth-checkpassword.conf.ext \
    conf.d/auth-deny.conf.ext \
    conf.d/auth-master.conf.ext \
    conf.d/auth-passwdfile.conf.ext \
    conf.d/auth-sql.conf.ext \
    conf.d/auth-static.conf.ext \
    conf.d/auth-system.conf.ext \
    conf.d/auth-vpopmail.conf.ext"

  OLD_CONFFILES="dovecot-ldap.conf \
    dovecot-db.conf.ext \
    dovecot-sql.conf \
    protocols.conf \
    dovecot-ldap.conf.ext \
    conf.d/20-imap.conf \
    conf.d/20-lmtp.conf \
    conf.d/20-managesieve.conf \
    conf.d/20-pop3.conf \
    conf.d/90-sieve.conf \
    conf.d/auth-ldap.conf.ext"

    OLD_DPKG_CONFFILES="/etc/cron.daily/dovecot \
      /etc/dovecot/dovecot-dict-sql-example.conf \
      /etc/dovecot/dovecot-db-example.conf"

    # purge old dpkg handled conffiles (we can't use dpkg-maintscript-helper because package rename)
    for conffile in $OLD_DPKG_CONFFILES ; do
      [ -e "$conffile" ] || continue
      confmd5="$(md5sum $conffile | awk '{print $1}')"
      dpkgmd5="$(dpkg-query -W -f='${Conffiles}' $PKGNAME | sed -n -e "\' $conffile ' { s/ obsolete$//; s/.* //; p }")"
      if [ "$confmd5" != "$dpkgmd5" ]; then
        echo "Obsolete conffile $conffile has been modified by you."
        echo "Saving as $conffile.dpkg-bak ..."
        mv -f "$conffile" "$conffile".dpkg-bak
      else
        echo "Removing obsolete conffile $conffile ..."
        rm -f "$conffile"
      fi
    done

  # purge old ucf handled conffiles
  for conffile in $OLD_CONFFILES ; do
    if ucfq "/etc/dovecot/${conffile}" --with-colons | grep -q "^/etc/dovecot/${conffile}:dovecot-common:"; then
      if ucfq --with-colons "/etc/dovecot/${conffile}" | grep -q ":Yes:No"; then
        rm -f "/etc/dovecot/${conffile}"
      fi
      ucf --debconf-ok --purge /etc/dovecot/$conffile
      ucfr --purge dovecot-common /etc/dovecot/$conffile
      for ext in '~' '%' .bak .dpkg-tmp .dpkg-new .dpkg-old .dpkg-dist .ucf-new .ucf-old .ucf-dist;  do
        rm -f /etc/dovecot/$conffile$ext
      done
    fi
  done

  # if we are upgrading from dovecot-common take the ownership of configuration files
  for conffile in $(ucfq dovecot-common --with-colons | cut -f 1 -d :); do
    ucfr --force dovecot-core $conffile
    if [ "$conffile" = "/etc/dovecot/dovecot.conf" ]; then
      # avoid ucf question if the only difference is at the "protocols" line
      confmd5=$(sed 's/^protocols.*/protocols = none/' "$conffile" | md5sum | awk '{print $1}')
      ucfmd5=$(cat /var/lib/ucf/hashfile | grep "$conffile" | awk '{print $1}')
      if [ "$confmd5" = "$ucfmd5" ]; then
        sed -i 's/^protocols.*/protocols = none/' "$conffile"
      fi
      # remove old configuration bakup generated by postinst
      rm -f $conffile.bak
    fi
  done

  ## Users
  #

  if [ -z "`id -u dovecot 2> /dev/null`" ]; then
    adduser --system --group --home /usr/lib/dovecot --gecos "Dovecot mail server" \
            --no-create-home --disabled-password --quiet dovecot || true
  fi

  if [ -z "`id -u dovenull 2> /dev/null`" ]; then
    adduser --system --group --home /nonexistent --no-create-home --gecos "Dovecot login user" \
            --disabled-password --quiet dovenull || true
  fi

  for conffile in $CONFFILES ; do
    # Tell ucf that the file in /usr/share/dovecot is the latest
    # maintainer version, and let it handle how to manage the real
    # configuration file in /etc/dovecot.
    ucf --three-way --debconf-ok /usr/share/dovecot/$conffile /etc/dovecot/$conffile
    ucfr dovecot-core /etc/dovecot/$conffile
    if [ "$conffile" != "dovecot.conf" ] && [ -f "/etc/dovecot/$conffile" ] &&
		[ `echo $conffile | cut -b -7` != "conf.d/" ]; then
      chmod 0640 /etc/dovecot/$conffile
      chgrp dovecot /etc/dovecot/$conffile
    fi
  done

  if [ -n "`id -u imapd 2> /dev/null`" ]; then
    deluser imapd || true
    delgroup imapd || true
  fi

  ## SSL Certs
  # Certs and key file
  OLD_SSL_CERT="/etc/ssl/certs/dovecot.pem"
  OLD_SSL_KEY="/etc/ssl/private/dovecot.pem"
  SSL_CERT=$( (grep -m 1 "ssl_cert_file" /etc/dovecot/conf.d/10-ssl.conf  || echo '/etc/dovecot/dovecot.pem') | cut -d'=' -f2)
  SSL_KEY=$( (grep -m 1 "ssl_key_file" /etc/dovecot/conf.d/10-ssl.conf || echo '/etc/dovecot/private/dovecot.pem') | cut -d'=' -f2)

  if [ ! -e /etc/dovecot/private ]; then
    install -d -o root -g root -m0700 /etc/dovecot/private
  fi

  if [ -e $OLD_SSL_CERT ] || [ -e $OLD_SSL_KEY ]; then
    echo "You already have ssl certs for dovecot."
    echo "However you should move them out of /etc/ssl"
    echo "and into /etc/dovecot and update the configuration"
    echo "in /etc/dovecot/conf.d/10-ssl.conf accordingly."
    echo "See /usr/share/doc/dovecot-core/README.Debian.gz for details."
    # Create backward compatible symlinks to keep dovecot functioning
    if [ ! -e $SSL_CERT ]; then
      echo "Creating compat symlink for $OLD_SSL_CERT"
      ln -s $OLD_SSL_CERT $SSL_CERT
    fi
    if [ ! -e $SSL_KEY ]; then
      echo "Creating compat symlink for $OLD_SSL_KEY"
      ln -s $OLD_SSL_KEY $SSL_KEY
    fi
  fi
  # Generate new certs if needed
  if [ -e $SSL_CERT ] || [ -e $SSL_KEY ]; then
    echo "You already have ssl certs for dovecot."
  else
    echo "Creating generic self-signed certificate: $SSL_CERT"
    echo "This certificate will expire in 10 years."
    echo "(replace with hand-crafted or authorized one if needed)."

    db_get dovecot-core/create-ssl-cert
    if [ "$RET" = "true" ]; then
      cd /etc/dovecot
      SSL_CERT=`doveconf -S ssl_cert | sed -e 's/^ssl_cert=<//'`
      SSL_KEY=`doveconf -S ssl_key | sed -e 's/^ssl_key=<//'`
      PATH=$PATH:/usr/bin/ssl
      db_get dovecot-core/ssl-cert-name
      COMMONNAME="$RET"
      MAILNAME="$(cat /etc/mailname 2> /dev/null || echo "$COMMONNAME")"
      (openssl req -newkey rsa:2048  -x509 -days 3652.5 -nodes \
     -rand /dev/urandom -out $SSL_CERT -keyout $SSL_KEY > /dev/null 2>&1 <<+
.
.
.
Dovecot mail server
$COMMONNAME
$COMMONNAME
root@$MAILNAME
+
      ) || echo "Warning : Bad SSL config, can't generate certificate."

      ucfr dovecot-core $SSL_CERT
      ucfr dovecot-core $SSL_KEY

      chown root:dovecot $SSL_CERT || true
      chmod 0644 $SSL_CERT || true
      chown root:dovecot $SSL_KEY || true
      chmod 0600 $SSL_KEY || true

    fi
    db_stop || true
  fi
fi

if [ "$1" = "triggered" ]; then
    if [ -x "/etc/init.d/dovecot" ]; then
        db_stop || true
        if [ -x /usr/sbin/invoke-rc.d ]; then
            invoke-rc.d dovecot restart
        else
            /etc/init.d/dovecot restart
        fi
    fi
fi

# Automatically added by dh_installinit
if [ -x "/etc/init.d/dovecot" ] || [ -e "/etc/init/dovecot.conf" ]; then
	if [ ! -e "/etc/init/dovecot.conf" ]; then
		update-rc.d dovecot defaults >/dev/null
	fi
	invoke-rc.d dovecot start || exit $?
fi
# End automatically added section
# Automatically added by dh_installinit
update-rc.d -f dovecot remove >/dev/null || exit $?
# End automatically added section