2018-12-26 12:42:48 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
function dump() {
|
|
|
|
echo "$(date) Dumping certificates"
|
|
|
|
|
2019-10-13 21:31:36 +02:00
|
|
|
traefik-certs-dumper file --version ${TRAEFIK_VERSION:-v1} --crt-name "cert" --crt-ext ".pem" --key-name "key" --key-ext ".pem" --domain-subdir --dest /tmp/work --source /traefik/acme.json > /dev/null
|
2018-12-26 12:42:48 +02:00
|
|
|
|
2019-08-11 00:39:52 +02:00
|
|
|
if [[ -f /tmp/work/${DOMAIN}/cert.pem && -f /tmp/work/${DOMAIN}/key.pem && -f /output/cert.pem && -f /output/key.pem ]] && \
|
|
|
|
diff -q /tmp/work/${DOMAIN}/cert.pem /output/cert.pem >/dev/null && \
|
|
|
|
diff -q /tmp/work/${DOMAIN}/key.pem /output/key.pem >/dev/null ; \
|
|
|
|
then
|
2019-03-10 14:15:14 +02:00
|
|
|
echo "$(date) Certificate and key still up to date, doing nothing"
|
|
|
|
else
|
|
|
|
echo "$(date) Certificate or key differ, updating"
|
|
|
|
mv /tmp/work/${DOMAIN}/*.pem /output/
|
|
|
|
fi
|
2018-12-26 12:42:48 +02:00
|
|
|
}
|
|
|
|
|
2019-03-10 14:15:14 +02:00
|
|
|
mkdir -p /tmp/work
|
2018-12-26 12:42:48 +02:00
|
|
|
dump
|
|
|
|
|
|
|
|
while true; do
|
2019-03-10 14:15:14 +02:00
|
|
|
inotifywait -qq -e modify /traefik/acme.json
|
|
|
|
dump
|
2018-12-26 12:42:48 +02:00
|
|
|
done
|