No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

letsencrypt-gencert 1.0KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/bin/bash
  2. # Call script like this:
  3. # letsencrypt-gencert foo.com bar.com baz.com
  4. # Build list of domains and subdomains we need a certificate for
  5. d=""
  6. for domain in "$@"; do
  7. # domain itself - foo.com
  8. # only add if the DNS entry for the domain does actually exist
  9. if (getent hosts $domain > /dev/null); then
  10. if [ -z "$d" ]; then
  11. d="$domain";
  12. else
  13. d="$d,$domain";
  14. fi
  15. fi
  16. # subdomains - www.foo.com mail.foo.com ...
  17. for sub in www mail autoconfig news cloud git; do
  18. # only add if the DNS entry for the subdomain does actually exist
  19. if (getent hosts $sub.$domain > /dev/null); then
  20. if [ -z "$d" ]; then
  21. d="$sub.$domain";
  22. else
  23. d="$d,$sub.$domain";
  24. fi
  25. fi
  26. done
  27. done
  28. # We are using the "standalone" letsencrypt plugin, which runs its own
  29. # webserver, so we need to temporarily free up the HTTP(S) ports by stopping
  30. # our own Apache.
  31. service apache2 stop
  32. /root/letsencrypt/letsencrypt-auto certonly -c /etc/letsencrypt/cli.conf --domains $d
  33. service apache2 start