san domain handling centralised

This commit is contained in:
Sebastian Hugentobler 2017-09-04 16:10:39 +02:00
parent f6b4c20e4a
commit 51cc43c11d
4 changed files with 17 additions and 10 deletions

View File

@ -17,6 +17,6 @@ RUN chmod 775 /run/postgresql
ADD /rootfs / ADD /rootfs /
VOLUME /var/lib/postgresql/data VOLUME /var/lib/postgresql/data /var/lib/postgresql/.lego
EXPOSE 5432 EXPOSE 5432

11
rootfs/bin/concat-sans Executable file
View File

@ -0,0 +1,11 @@
#!/usr/bin/with-contenv sh
SAN_DOMAINS=""
export IFS=";"
for SAN in ${POSTGRES_SAN}
do
SAN_DOMAINS="${SAN_DOMAINS} --domains=\"${SAN}\""
done
echo ${SAN_DOMAINS}

View File

@ -2,13 +2,15 @@
cd /var/lib/postgresql cd /var/lib/postgresql
SAN_DOMAINS=$(/bin/concat-sans)
OLD_MOD=$(stat -c %y /var/lib/postgresql/.lego/certificates/${POSTGRES_DOMAIN}.crt) OLD_MOD=$(stat -c %y /var/lib/postgresql/.lego/certificates/${POSTGRES_DOMAIN}.crt)
lego \ lego \
--accept-tos \ --accept-tos \
--server="${POSTGRES_CA}" \ --server="${POSTGRES_CA}" \
--email="${POSTGRES_ACME_EMAIL}" \ --email="${POSTGRES_ACME_EMAIL}" \
--domains="${POSTGRES_DOMAIN}" \ --domains="${POSTGRES_DOMAIN}" ${SAN_DOMAINS} \
--dns="${POSTGRES_DNS_PROVIDER}" \ --dns="${POSTGRES_DNS_PROVIDER}" \
renew --days 30 renew --days 30

View File

@ -2,13 +2,7 @@
cd /var/lib/postgresql cd /var/lib/postgresql
SAN_DOMAINS="" SAN_DOMAINS=$(/bin/concat-sans)
export IFS=";"
for SAN in ${POSTGRES_SAN}
do
SAN_DOMAINS="${SAN_DOMAINS} --domains=\"${SAN}\""
done
if [ ! -f /var/lib/postgresql/.lego/certificates/${POSTGRES_DOMAIN}.crt ]; then if [ ! -f /var/lib/postgresql/.lego/certificates/${POSTGRES_DOMAIN}.crt ]; then
chown -R postgres /var/lib/postgresql/.lego chown -R postgres /var/lib/postgresql/.lego
@ -24,7 +18,7 @@ else
--accept-tos \ --accept-tos \
--server="${POSTGRES_CA}" \ --server="${POSTGRES_CA}" \
--email="${POSTGRES_ACME_EMAIL}" \ --email="${POSTGRES_ACME_EMAIL}" \
--domains="${POSTGRES_DOMAIN}" \ --domains="${POSTGRES_DOMAIN}" ${SAN_DOMAINS} \
--dns="${POSTGRES_DNS_PROVIDER}" \ --dns="${POSTGRES_DNS_PROVIDER}" \
renew --days 30 renew --days 30
fi fi