docker-ftps/rootfs/app/acme-cert-init.sh

31 lines
799 B
Bash
Raw Permalink Normal View History

2024-01-23 16:15:08 +00:00
#!/bin/sh
MASQUERADE=${MASQUERADE:-127.0.0.1}
ACME_SERVER=${ACME_SERVER:-letsencrypt}
ACME_DNS=${ACME_DNS:-myapi}
if [ ! -d /acme/cert ] ; then
mkdir -p /acme/cert
fi
if [ -n "${ACME_EMAIL}" ] ; then
ACME_EMAIL="--accountemail ${ACME_EMAIL}"
fi
if [ ! -f "/acme/cert/cert.pem" ] ; then
echo "Initializing certificate with acme.sh"
# shellcheck disable=SC2086
acme.sh --issue -d "${MASQUERADE}" \
--home /acme \
--dns "${ACME_DNS}" \
--server "${ACME_SERVER}" \
--cert-file /acme/cert/cert.pem \
--key-file /acme/cert/privkey.pem \
--fullchain-file /acme/cert/chain.pem \
--reloadcmd /app/acme-refresh-cert.sh ${ACME_EMAIL}
2024-01-28 10:20:13 +00:00
echo "Certificate ready"
2024-01-23 16:15:08 +00:00
else
2024-01-28 10:20:13 +00:00
/app/acme-refresh-cert.sh
2024-01-23 16:15:08 +00:00
echo "Certificate ready"
fi