From ea455f73528b8c9481ca31f3ec557527797bc03a Mon Sep 17 00:00:00 2001 From: theit8514 Date: Mon, 7 Mar 2016 17:09:02 -0500 Subject: [PATCH 1/2] Add post-renew hook for executing commands when certificate was renewed successfully. --- le.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/le.sh b/le.sh index 136d0a32..eec523a4 100755 --- a/le.sh +++ b/le.sh @@ -389,6 +389,9 @@ _initpath() { domainhome="$LE_WORKING_DIR/$domain" mkdir -p "$domainhome" + if [ -z "$DOMAIN_PATH" ] ; then + DOMAIN_PATH="$domainhome" + fi if [ -z "$DOMAIN_CONF" ] ; then DOMAIN_CONF="$domainhome/$Le_Domain.conf" fi @@ -409,6 +412,9 @@ _initpath() { if [ -z "$CA_CERT_PATH" ] ; then CA_CERT_PATH="$domainhome/ca.cer" fi + if [ -z "$POST_RENEW_PATH" ] ; then + POST_RENEW_PATH="$domainhome/post-renew.sh" + fi } @@ -956,6 +962,9 @@ renew() { local res=$? IS_RENEW="" + if [ -x "$POST_RENEW_PATH" -a "$res" -eq "0" ] ; then + (cd $DOMAIN_PATH && exec $POST_RENEW_PATH) + fi return $res } @@ -988,12 +997,14 @@ renewAll() { Le_ReloadCmd="" DOMAIN_CONF="" + DOMAIN_PATH="" DOMAIN_SSL_CONF="" CSR_PATH="" CERT_KEY_PATH="" CERT_PATH="" CA_CERT_PATH="" ACCOUNT_KEY_PATH="" + POST_RENEW_PATH="" wellknown_path="" From eef38fccfe9b60ee52474e5f298ca9d10f288215 Mon Sep 17 00:00:00 2001 From: theit8514 Date: Mon, 7 Mar 2016 22:27:08 -0500 Subject: [PATCH 2/2] Modified code for Le_ReloadCmd --- le.sh | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/le.sh b/le.sh index eec523a4..36092ec4 100755 --- a/le.sh +++ b/le.sh @@ -412,9 +412,6 @@ _initpath() { if [ -z "$CA_CERT_PATH" ] ; then CA_CERT_PATH="$domainhome/ca.cer" fi - if [ -z "$POST_RENEW_PATH" ] ; then - POST_RENEW_PATH="$domainhome/post-renew.sh" - fi } @@ -962,9 +959,6 @@ renew() { local res=$? IS_RENEW="" - if [ -x "$POST_RENEW_PATH" -a "$res" -eq "0" ] ; then - (cd $DOMAIN_PATH && exec $POST_RENEW_PATH) - fi return $res } @@ -996,15 +990,14 @@ renewAll() { Le_ReloadCmd="" - DOMAIN_CONF="" DOMAIN_PATH="" + DOMAIN_CONF="" DOMAIN_SSL_CONF="" CSR_PATH="" CERT_KEY_PATH="" CERT_PATH="" CA_CERT_PATH="" ACCOUNT_KEY_PATH="" - POST_RENEW_PATH="" wellknown_path="" @@ -1061,7 +1054,7 @@ installcert() { if [ "$Le_ReloadCmd" ] ; then _info "Run Le_ReloadCmd: $Le_ReloadCmd" - eval $Le_ReloadCmd + (cd $DOMAIN_PATH && eval $Le_ReloadCmd) fi }