From b2372951e110babc407ca5181b1680345c1f37d1 Mon Sep 17 00:00:00 2001 From: mapperr Date: Sat, 10 Oct 2020 17:51:44 +0200 Subject: [PATCH] Fix davmail ssl --- davmail/Dockerfile | 6 +++--- davmail/build.sh | 4 ++++ davmail/entrypoint.sh | 33 +++++++++++++++++++++------------ davmail/run.sh | 31 +++++++++++++++++++++++++++++++ soju/Dockerfile | 0 soju/README.md | 0 6 files changed, 59 insertions(+), 15 deletions(-) mode change 100644 => 100755 davmail/Dockerfile create mode 100755 davmail/build.sh create mode 100755 davmail/run.sh mode change 100644 => 100755 soju/Dockerfile mode change 100644 => 100755 soju/README.md diff --git a/davmail/Dockerfile b/davmail/Dockerfile old mode 100644 new mode 100755 index 10e3b58..0db6807 --- a/davmail/Dockerfile +++ b/davmail/Dockerfile @@ -1,6 +1,6 @@ -FROM openjdk:14 -RUN yum update && \ - yum install -y unzip && \ +FROM openjdk:14-alpine +RUN apk update && \ + apk add curl unzip && \ curl -L -o /davmail-5.5.1-3299.zip https://sourceforge.net/projects/davmail/files/davmail/5.5.1/davmail-5.5.1-3299.zip && \ unzip -d /davmail /davmail-5.5.1-3299.zip && \ rm -f /davmail-5.5.1-3299.zip diff --git a/davmail/build.sh b/davmail/build.sh new file mode 100755 index 0000000..5cd9314 --- /dev/null +++ b/davmail/build.sh @@ -0,0 +1,4 @@ +#! /bin/sh + +docker build -t mapperr/davmail . + diff --git a/davmail/entrypoint.sh b/davmail/entrypoint.sh index e293b42..f592d81 100755 --- a/davmail/entrypoint.sh +++ b/davmail/entrypoint.sh @@ -1,26 +1,35 @@ #! /bin/sh -PASS=`head /dev/urandom | tr -dc A-Za-z0-9 | head -c 16 ; echo ''` +certfile="/cert/davmail.p12" +passfile="/cert/davmail.p12.pass" -keytool -genkey -keyalg rsa \ - -keysize 4096 \ - -storepass $PASS \ - -keystore /davmail.p12 \ - -storetype pkcs12 \ - -validity 36000 \ - -dname cn=davmail +if [ -f "$certfile" ] && [ -f "$passfile" ]; then + certpass=`cat $passfile` + +else + certpass=`head /dev/urandom | tr -dc A-Za-z0-9 | head -c 16 ; echo ''` + echo "$certpass" > "$passfile" + + keytool -genkey -keyalg rsa \ + -keysize 4096 \ + -storepass $certpass \ + -keystore $certfile \ + -storetype pkcs12 \ + -validity 36000 \ + -dname cn=davmail +fi echo "certificate fingerprint:" -keytool -list -keystore /davmail.p12 -storepass $PASS -v | grep SHA +keytool -list -keystore $certfile -storepass $certpass -v | grep SHA test -r /davmail.properties && cp /davmail.properties dm.properties cat <> /dm.properties davmail.ssl.keystoreType=PKCS12 -davmail.ssl.keyPass=$PASS -davmail.ssl.keystoreFile=/davmail.p12 -davmail.ssl.keystorePass=$PASS +davmail.ssl.keyPass=$certpass +davmail.ssl.keystoreFile=$certfile +davmail.ssl.keystorePass=$certpass EOF /davmail/davmail /dm.properties diff --git a/davmail/run.sh b/davmail/run.sh new file mode 100755 index 0000000..e51367b --- /dev/null +++ b/davmail/run.sh @@ -0,0 +1,31 @@ +#! /bin/sh + +# taken from gradlew +PRG="$0" +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +SCRIPTDIR="`pwd -P`" + +IMAGE="mapperr/davmail" +CONTNAME="davmail" + +docker run -d \ +--name ${CONTNAME} \ +--restart always \ +-p 40143:1143 \ +-p 40025:1025 \ +-p 40080:1080 \ +-v ${SCRIPTDIR}/cert:/cert \ +-v ${SCRIPTDIR}/davmail.properties:/davmail.properties \ +${IMAGE} + + diff --git a/soju/Dockerfile b/soju/Dockerfile old mode 100644 new mode 100755 diff --git a/soju/README.md b/soju/README.md old mode 100644 new mode 100755 -- 2.38.5