summaryrefslogtreecommitdiffstats
path: root/main/dovecot/dovecot.post-install
diff options
context:
space:
mode:
Diffstat (limited to 'main/dovecot/dovecot.post-install')
-rw-r--r--main/dovecot/dovecot.post-install31
1 files changed, 31 insertions, 0 deletions
diff --git a/main/dovecot/dovecot.post-install b/main/dovecot/dovecot.post-install
new file mode 100644
index 000000000..a7cccddfd
--- /dev/null
+++ b/main/dovecot/dovecot.post-install
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+# based on doc/mkcert.sh
+
+# Generates a self-signed certificate.
+# Edit dovecot-openssl.cnf before running this.
+
+OPENSSL=${OPENSSL-openssl}
+SSLDIR=${SSLDIR-/etc/ssl/dovecot}
+OPENSSLCONFIG=${OPENSSLCONFIG-/etc/dovecot/dovecot-openssl.cnf}
+
+CERTDIR=$SSLDIR
+KEYDIR=$SSLDIR
+
+CERTFILE=$CERTDIR/server.pem
+KEYFILE=$KEYDIR/server.key
+
+if [ -e "$CERTFILE" ]; then
+ echo "Keeiping existing $CERTFILE"
+ exit 0
+fi
+
+if [ -e "$KEYFILE" ]; then
+ echo "Keeiping existing $KEYFILE"
+ exit 0
+fi
+
+$OPENSSL req -new -x509 -nodes -config $OPENSSLCONFIG -out $CERTFILE -keyout $KEYFILE -days 365 || exit 2
+chmod 0600 $KEYFILE
+echo
+$OPENSSL x509 -subject -fingerprint -noout -in $CERTFILE || exit 2