Some scripts to create and renew all your certificates, and concatenate fullchain and privkey so haproxy is able to use it
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.

26 lines
773 B

  1. #!/bin/bash
  2. #Configuration variables
  3. certbot_bin="/usr/local/bin/certbot"
  4. haproxy_pem_path="/etc/haproxy/cert"
  5. #Renew all certificates that needed it
  6. ${certbot_bin} renew
  7. if [ $? -eq 0 ]; then
  8. echo "$(date +%c)Certificates renewed ! Now creating .pem"
  9. else
  10. echo "$(date +%c) Error renewing certificates with error code $?, exit script..."
  11. exit 1
  12. fi
  13. #Then, create domain.pem containing fullchain et privkey for haproxy
  14. for domainconf in $(ls /etc/letsencrypt/renewal/); do
  15. domain=${domainconf%.conf}
  16. echo "$(date +%c)create ${domain}.pem"
  17. cat /etc/letsencrypt/live/${domain}/fullchain.pem /etc/letsencrypt/live/${domain}/privkey.pem > ${haproxy_pem_path}/${domain}.pem
  18. done
  19. # At the end, reload haproxy
  20. echo "$(date +%c) Reload haproxy"
  21. systemctl reload haproxy