From 850d7ba9ebfbbfb4502abe8b1e3ae3288cfbc25c Mon Sep 17 00:00:00 2001 From: Sam Batschelet Date: Fri, 24 Aug 2018 09:29:47 -0400 Subject: [PATCH] Add reloadcmd support for cron flag. --- acme.sh | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/acme.sh b/acme.sh index 32219d9d..d00b0014 100755 --- a/acme.sh +++ b/acme.sh @@ -4713,19 +4713,7 @@ _installcert() { fi if [ "$_reload_cmd" ]; then - _info "Run reload cmd: $_reload_cmd" - if ( - export CERT_PATH - export CERT_KEY_PATH - export CA_CERT_PATH - export CERT_FULLCHAIN_PATH - export Le_Domain - cd "$DOMAIN_PATH" && eval "$_reload_cmd" - ); then - _info "$(__green "Reload success")" - else - _err "Reload error for :$Le_Domain" - fi + _eval_reload_cmd "$_reload_cmd" fi } @@ -5388,6 +5376,12 @@ _uninstallalias() { } cron() { + _reload_cmd="$1" + + if [ "$_reload_cmd" = "$NO_VALUE" ]; then + _reload_cmd="" + fi + export IN_CRON=1 _initpath _info "$(__green "===Starting cron===")" @@ -5409,11 +5403,32 @@ cron() { fi renewAll _ret="$?" + if [ "$_reload_cmd" ]; then + _eval_reload_cmd "$_reload_cmd" + fi IN_CRON="" _info "$(__green "===End cron===")" exit $_ret } +_eval_reload_cmd() { + _reload_cmd="$1" + + _info "Run reload cmd: $_reload_cmd" + if ( + export CERT_PATH + export CERT_KEY_PATH + export CA_CERT_PATH + export CERT_FULLCHAIN_PATH + export Le_Domain + cd "$DOMAIN_PATH" && eval "$_reload_cmd" + ); then + _info "$(__green "Reload success")" + else + _err "Reload error for :$Le_Domain" + fi +} + version() { echo "$PROJECT" echo "v$VER" @@ -6168,7 +6183,7 @@ _process() { ;; installcronjob) installcronjob "$_confighome" ;; uninstallcronjob) uninstallcronjob ;; - cron) cron ;; + cron) cron "$_reloadcmd" ;; toPkcs) toPkcs "$_domain" "$_password" "$_ecc" ;;