update-cert.template.txt 874 B

1234567891011121314151617181920
  1. #!/bin/bash
  2. set -e
  3. DOMAIN="${CERTBOT_DOMAIN}"
  4. EMAIL="${CERTBOT_EMAIL}"
  5. OPTIONS="${CERTBOT_OPTIONS}"
  6. CERT_NAME="${DOMAIN}" # 証明書名をドメイン名と同じにする
  7. # Check if the certificate already exists
  8. if [ -f "/etc/letsencrypt/renewal/${CERT_NAME}.conf" ]; then
  9. echo "Certificate exists. Attempting to renew..."
  10. certbot renew --noninteractive --cert-name ${CERT_NAME} --webroot --webroot-path=/var/www/html --email ${EMAIL} --agree-tos --no-eff-email ${OPTIONS}
  11. else
  12. echo "Certificate does not exist. Obtaining a new certificate..."
  13. certbot certonly --noninteractive --webroot --webroot-path=/var/www/html --email ${EMAIL} --agree-tos --no-eff-email -d ${DOMAIN} ${OPTIONS}
  14. fi
  15. echo "Certificate operation successful"
  16. # Note: Nginx reload should be handled outside this container
  17. echo "Please ensure to reload Nginx to apply any certificate changes."