From d2ab7bbe1842b5fc521c65e304f1c5f500bac589 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 2 Jan 2016 13:14:56 +0000 Subject: [PATCH] Renew letsencrypt certs by default --- src/freedombone-addcert | 2 +- src/freedombone-renew-cert | 19 +++++++------------ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/freedombone-addcert b/src/freedombone-addcert index 822704ae..788ba761 100755 --- a/src/freedombone-addcert +++ b/src/freedombone-addcert @@ -172,7 +172,7 @@ function add_cert_letsencrypt { systemctl stop nginx cd ${INSTALL_DIR}/letsencrypt - ./letsencrypt-auto certonly --server $LETSENCRYPT_SERVER --standalone -d $LETSENCRYPT_HOSTNAME + ./letsencrypt-auto certonly --server $LETSENCRYPT_SERVER --standalone -d $LETSENCRYPT_HOSTNAME --renew-by-default if [ ! "$?" = "0" ]; then echo $"Failed to install letsencrypt for domain $LETSENCRYPT_HOSTNAME" systemctl start nginx diff --git a/src/freedombone-renew-cert b/src/freedombone-renew-cert index 563d83f3..19eea0aa 100755 --- a/src/freedombone-renew-cert +++ b/src/freedombone-renew-cert @@ -37,6 +37,7 @@ HOSTNAME= PROVIDER='startssl' DH_KEYLENGTH=2048 LETSENCRYPT_SERVER='https://acme-v01.api.letsencrypt.org/directory' +INSTALL_DIR=/root/build function show_help { echo '' @@ -54,20 +55,14 @@ function show_help { function renew_letsencrypt { if [ ! -f /etc/letsencrypt/live/${HOSTNAME}/fullchain.pem ]; then echo $"Adding Let's Encrypt certificate" - ${PROJECT_NAME}-addcert -e $HOSTNAME -s $LETSENCRYPT_SERVER --dhkey $DH_KEYLENGTH - if [ ! "$?" = "0" ]; then - echo $"Unable to add Let's encrypt certificate" - exit 6328 - fi else echo $"Renewing Let's Encrypt certificate" - letsencrypt renew \ - --cert-path /etc/letsencrypt/live/${HOSTNAME}/fullchain.pem \ - --key-path /etc/letsencrypt/live/${HOSTNAME}/privkey.pem - if [ ! "$?" = "0" ]; then - echo $"Unable to renew Let's encrypt certificate" - exit 2624 - fi + fi + + ${PROJECT_NAME}-addcert -e $HOSTNAME -s $LETSENCRYPT_SERVER --dhkey $DH_KEYLENGTH + if [ ! "$?" = "0" ]; then + echo $"Unable to add Let's encrypt certificate" + exit 6328 fi # Ensure that links are in place