From 08098b3a675eca2e79f404afb75e7322ac3afc6b Mon Sep 17 00:00:00 2001 From: Victor Date: Sat, 10 Sep 2016 15:47:43 +0200 Subject: [PATCH] adding renew-certificates script --- renew-certificates | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 renew-certificates diff --git a/renew-certificates b/renew-certificates new file mode 100644 index 0000000..f739eb5 --- /dev/null +++ b/renew-certificates @@ -0,0 +1,25 @@ +#!/bin/bash + +#Configuration variables +certbot_bin="/root/letsencrypt/certbot-auto" +haproxy_pem_path="/etc/haproxy/cert" + +#Renew all certificates that needed it +${certbot_bin} renew +if [ $? -eq 0 ]; then + echo "Certificates renewed ! Now creating .pem" +else + echo "$(date +%c) Error renewing certificates with error code $?, exit script..." + exit 1 +fi + +#Then, create domain.pem containing fullchain et privkey for haproxy +for domainconf in $(ls /etc/letsencrypt/renewal/ | awk -F'/' '{print $5}'); do + domain=${domainconf%.conf} + echo "create ${domain}.pem" + cat /etc/letsencrypt/live/${domain]/fullchain.pem /etc/letsencrypt/live/${domain}/privkey.pem > ${haproxy_pem_path}/${domain}.pem +done + +# At the end, reload haproxy +service haproxy reload +