aboutsummaryrefslogblamecommitdiffstats
path: root/terminaldweller.com/haproxy/certbot/certbot-entrypoint.sh
blob: 2be858f7a41420f1d7794618933cc6bccf3b5969 (plain) (tree)





























                                                               
#!/bin/sh
set -ex

cat_cert() {
  dir="/etc/letsencrypt/live/$1"
  cat "$dir/privkey.pem" "$dir/fullchain.pem" > "/certs/$1.pem"
}

while :;do
  echo starting...
  if [ -e /certs/$DOMAIN.pem ]; then
      certbot \
      certonly \
      --test-cert \
      --webroot -w /webroot \
      -d $DOMAIN \
      --email $EMAIL \
      --non-interactive \
      --agree-tos

    cat_cert $DOMAIN
  else
    certbot renew -w /webroot

    for dir in /etc/letsencrypt/live/*/; do
      cat_cert $(basename "$dir")
    done
  fi
  sleep 12h
done