docker-nginx-auto/app/acme-autocert.sh
2021-08-20 11:39:58 -04:00

42 lines
764 B
Bash
Executable File

#!/bin/sh
. /root/common.sh
get_domains() {
cat /etc/nginx/conf.d/* \
| sed 's/^[[:blank:]]*//' \
| grep ^server_name \
| grep -v 'NOSSL' \
| cut -d';' -f1 \
| awk '{for(i=2; i<=NF; i++) print $i}' \
| awk '{$1=$1};1' \
| grep -E '^[[:alnum:]_-]+([.][[:alnum:]_-]+)*$' \
| sort | uniq
}
get_args() {
if [ "${ACME_STAGING}" != "" ]; then
echo --staging
fi
if [ "${ACME_EMAIL}" != "" ]; then
echo --email
echo "${ACME_EMAIL}"
fi
echo --issue
echo --webroot
echo /var/www
for h in `get_domains`; do
echo -d
echo "$h"
done
}
if [ "${RELOAD_FIRST}" != "no" ]; then
"${BIN}" -s reload
fi
if /root/.acme.sh/acme.sh \
--key-file "${CONF}/ssl.key" --fullchain-file "${CONF}/ssl.cer" \
"$@" `get_args`; then
"${BIN}" -s reload
fi