88a20bf
diff -up dovecot-2.3.0.1/dovecot-init.service.initbysystemd dovecot-2.3.0.1/dovecot-init.service
88a20bf
--- dovecot-2.3.0.1/dovecot-init.service.initbysystemd	2018-03-01 10:38:22.059716008 +0100
88a20bf
+++ dovecot-2.3.0.1/dovecot-init.service	2018-03-01 10:38:22.059716008 +0100
0813442
@@ -0,0 +1,13 @@
76785b6
+[Unit]
76785b6
+Description=One-time Dovecot init service
76785b6
+ConditionPathExists=|!/etc/pki/dovecot/certs/dovecot.pem
76785b6
+
76785b6
+[Service]
76785b6
+Type=oneshot
76785b6
+RemainAfterExit=no
76785b6
+ExecStart=/bin/sh -c '\
76785b6
+if [ ! -f /etc/pki/dovecot/certs/dovecot.pem ]; \
76785b6
+then\
76785b6
+  SSLDIR=/etc/pki/dovecot/ OPENSSLCONFIG=/etc/pki/dovecot/dovecot-openssl.cnf /usr/libexec/dovecot/mkcert.sh /dev/null 2>&1;\
cfb1172
+fi'
76785b6
+
88a20bf
diff -up dovecot-2.3.0.1/dovecot.service.in.initbysystemd dovecot-2.3.0.1/dovecot.service.in
88a20bf
--- dovecot-2.3.0.1/dovecot.service.in.initbysystemd	2018-03-01 10:38:22.060716016 +0100
88a20bf
+++ dovecot-2.3.0.1/dovecot.service.in	2018-03-01 10:40:45.524901319 +0100
88a20bf
@@ -8,7 +8,8 @@
76785b6
 Description=Dovecot IMAP/POP3 email server
76785b6
 Documentation=man:dovecot(1)
76785b6
 Documentation=http://wiki2.dovecot.org/
76785b6
-After=local-fs.target network-online.target
76785b6
+After=local-fs.target network-online.target dovecot-init.service
76785b6
+Requires=dovecot-init.service
76785b6
 
76785b6
 [Service]
88a20bf
 Type=simple
88a20bf
diff -up dovecot-2.3.0.1/Makefile.am.initbysystemd dovecot-2.3.0.1/Makefile.am
88a20bf
--- dovecot-2.3.0.1/Makefile.am.initbysystemd	2018-02-28 15:28:57.000000000 +0100
88a20bf
+++ dovecot-2.3.0.1/Makefile.am	2018-03-01 10:38:22.060716016 +0100
88a20bf
@@ -63,9 +63,10 @@ if HAVE_SYSTEMD
76785b6
 
76785b6
 systemdsystemunit_DATA = \
76785b6
         dovecot.socket \
76785b6
-        dovecot.service
76785b6
+        dovecot.service \
76785b6
+        dovecot-init.service
76785b6
 else
76785b6
-EXTRA_DIST += dovecot.socket dovecot.service.in
76785b6
+EXTRA_DIST += dovecot.socket dovecot.service.in dovecot-init.service
76785b6
 endif
76785b6
 
76785b6
 install-exec-hook: