2018-12-26 12:42:48 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
function dump() {
|
|
|
|
echo "$(date) Dumping certificates"
|
|
|
|
|
2019-03-10 14:15:14 +02:00
|
|
|
traefik-certs-dumper dump --crt-name "cert" --crt-ext ".pem" --key-name "key" --key-ext ".pem" --domain-subdir=true --dest /tmp/work --source /traefik/acme.json > /dev/null
|
2018-12-26 12:42:48 +02:00
|
|
|
|
2019-03-10 14:15:14 +02:00
|
|
|
if 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
|
|
|
|
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
|