|
|
@ -2450,7 +2450,7 @@ _initpath() { |
|
|
|
. "$ACCOUNT_CONF_PATH" |
|
|
|
fi |
|
|
|
|
|
|
|
if [ "$IN_CRON" ]; then |
|
|
|
if [ "$ACME_IN_CRON" ]; then |
|
|
|
if [ ! "$_USER_PATH_EXPORTED" ]; then |
|
|
|
_USER_PATH_EXPORTED=1 |
|
|
|
export PATH="$USER_PATH:$PATH" |
|
|
@ -3216,14 +3216,6 @@ _on_issue_err() { |
|
|
|
_err "See: $_DEBUG_WIKI" |
|
|
|
fi |
|
|
|
|
|
|
|
if [ "$IN_CRON" ]; then |
|
|
|
if [ "$NOTIFY_LEVEL" ] && [ $NOTIFY_LEVEL -ge $NOTIFY_LEVEL_ERROR ]; then |
|
|
|
if [ "$NOTIFY_MODE" = "$NOTIFY_MODE_CERT" ]; then |
|
|
|
_send_notify "Renew $_main_domain error" "There is an error." "$NOTIFY_HOOK" 1 |
|
|
|
fi |
|
|
|
fi |
|
|
|
fi |
|
|
|
|
|
|
|
#run the post hook |
|
|
|
if [ "$_chk_post_hook" ]; then |
|
|
|
_info "Run post hook:'$_chk_post_hook'" |
|
|
@ -3266,13 +3258,7 @@ _on_issue_success() { |
|
|
|
_chk_post_hook="$1" |
|
|
|
_chk_renew_hook="$2" |
|
|
|
_debug _on_issue_success |
|
|
|
if [ "$IN_CRON" ]; then |
|
|
|
if [ "$NOTIFY_LEVEL" ] && [ $NOTIFY_LEVEL -ge $NOTIFY_LEVEL_RENEW ]; then |
|
|
|
if [ "$NOTIFY_MODE" = "$NOTIFY_MODE_CERT" ]; then |
|
|
|
_send_notify "Renew $_main_domain success" "Good, the cert is renewed." "$NOTIFY_HOOK" 0 |
|
|
|
fi |
|
|
|
fi |
|
|
|
fi |
|
|
|
|
|
|
|
#run the post hook |
|
|
|
if [ "$_chk_post_hook" ]; then |
|
|
|
_info "Run post hook:'$_chk_post_hook'" |
|
|
@ -4506,7 +4492,7 @@ $_authorizations_map" |
|
|
|
_info "Your cert key is in $(__green " $CERT_KEY_PATH ")" |
|
|
|
fi |
|
|
|
|
|
|
|
if [ ! "$USER_PATH" ] || [ ! "$IN_CRON" ]; then |
|
|
|
if [ ! "$USER_PATH" ] || [ ! "$ACME_IN_CRON" ]; then |
|
|
|
USER_PATH="$PATH" |
|
|
|
_saveaccountconf "USER_PATH" "$USER_PATH" |
|
|
|
fi |
|
|
@ -4686,19 +4672,10 @@ renew() { |
|
|
|
if [ -z "$FORCE" ] && [ "$Le_NextRenewTime" ] && [ "$(_time)" -lt "$Le_NextRenewTime" ]; then |
|
|
|
_info "Skip, Next renewal time is: $(__green "$Le_NextRenewTimeStr")" |
|
|
|
_info "Add '$(__red '--force')' to force to renew." |
|
|
|
|
|
|
|
if [ "$IN_CRON" = "1" ]; then |
|
|
|
if [ "$NOTIFY_LEVEL" ] && [ $NOTIFY_LEVEL -ge $NOTIFY_LEVEL_SKIP ]; then |
|
|
|
if [ "$NOTIFY_MODE" = "$NOTIFY_MODE_CERT" ]; then |
|
|
|
_send_notify "Renew $Le_Domain skipped" "Good, the cert next renewal time is $Le_NextRenewTimeStr." "$NOTIFY_HOOK" "$RENEW_SKIP" |
|
|
|
fi |
|
|
|
fi |
|
|
|
fi |
|
|
|
|
|
|
|
return "$RENEW_SKIP" |
|
|
|
fi |
|
|
|
|
|
|
|
if [ "$IN_CRON" = "1" ] && [ -z "$Le_CertCreateTime" ]; then |
|
|
|
if [ "$ACME_IN_CRON" = "1" ] && [ -z "$Le_CertCreateTime" ]; then |
|
|
|
_info "Skip invalid cert for: $Le_Domain" |
|
|
|
return $RENEW_SKIP |
|
|
|
fi |
|
|
@ -4733,6 +4710,8 @@ renewAll() { |
|
|
|
_success_msg="" |
|
|
|
_error_msg="" |
|
|
|
_skipped_msg="" |
|
|
|
_error_level=$NOTIFY_LEVEL_SKIP |
|
|
|
_notify_code=$RENEW_SKIP |
|
|
|
for di in "${CERT_HOME}"/*.*/; do |
|
|
|
_debug di "$di" |
|
|
|
if ! [ -d "$di" ]; then |
|
|
@ -4750,12 +4729,47 @@ renewAll() { |
|
|
|
) |
|
|
|
rc="$?" |
|
|
|
_debug "Return code: $rc" |
|
|
|
if [ "$rc" != "0" ]; then |
|
|
|
if [ "$rc" = "$RENEW_SKIP" ]; then |
|
|
|
if [ "$rc" = "0" ]; then |
|
|
|
if [ $_error_level -gt $NOTIFY_LEVEL_RENEW ]; then |
|
|
|
_error_level="$NOTIFY_LEVEL_RENEW" |
|
|
|
_notify_code=0 |
|
|
|
fi |
|
|
|
if [ "$ACME_IN_CRON" ]; then |
|
|
|
if [ "$NOTIFY_LEVEL" ] && [ $NOTIFY_LEVEL -ge $NOTIFY_LEVEL_RENEW ]; then |
|
|
|
if [ "$NOTIFY_MODE" = "$NOTIFY_MODE_CERT" ]; then |
|
|
|
_send_notify "Renew $d success" "Good, the cert is renewed." "$NOTIFY_HOOK" 0 |
|
|
|
fi |
|
|
|
fi |
|
|
|
fi |
|
|
|
_success_msg="${_success_msg} $d |
|
|
|
" |
|
|
|
elif [ "$rc" = "$RENEW_SKIP" ]; then |
|
|
|
if [ $_error_level -gt $NOTIFY_LEVEL_SKIP ]; then |
|
|
|
_error_level="$NOTIFY_LEVEL_SKIP" |
|
|
|
_notify_code=$RENEW_SKIP |
|
|
|
fi |
|
|
|
if [ "$ACME_IN_CRON" ]; then |
|
|
|
if [ "$NOTIFY_LEVEL" ] && [ $NOTIFY_LEVEL -ge $NOTIFY_LEVEL_SKIP ]; then |
|
|
|
if [ "$NOTIFY_MODE" = "$NOTIFY_MODE_CERT" ]; then |
|
|
|
_send_notify "Renew $d skipped" "Good, the cert is skipped." "$NOTIFY_HOOK" "$RENEW_SKIP" |
|
|
|
fi |
|
|
|
fi |
|
|
|
fi |
|
|
|
_info "Skipped $d" |
|
|
|
_skipped_msg="${_skipped_msg} $d |
|
|
|
" |
|
|
|
else |
|
|
|
if [ $_error_level -gt $NOTIFY_LEVEL_ERROR ]; then |
|
|
|
_error_level="$NOTIFY_LEVEL_ERROR" |
|
|
|
_notify_code=1 |
|
|
|
fi |
|
|
|
if [ "$ACME_IN_CRON" ]; then |
|
|
|
if [ "$NOTIFY_LEVEL" ] && [ $NOTIFY_LEVEL -ge $NOTIFY_LEVEL_ERROR ]; then |
|
|
|
if [ "$NOTIFY_MODE" = "$NOTIFY_MODE_CERT" ]; then |
|
|
|
_send_notify "Renew $d error" "There is an error." "$NOTIFY_HOOK" 1 |
|
|
|
fi |
|
|
|
fi |
|
|
|
fi |
|
|
|
_error_msg="${_error_msg} $d |
|
|
|
" |
|
|
|
if [ "$_stopRenewOnError" ]; then |
|
|
@ -4767,32 +4781,31 @@ renewAll() { |
|
|
|
_err "Error renew $d." |
|
|
|
fi |
|
|
|
fi |
|
|
|
else |
|
|
|
_success_msg="${_success_msg} $d |
|
|
|
" |
|
|
|
fi |
|
|
|
done |
|
|
|
|
|
|
|
if [ "$IN_CRON" = "1" ]; then |
|
|
|
_debug _error_level "$_error_level" |
|
|
|
if [ "$ACME_IN_CRON" ] && [ $_error_level -le $NOTIFY_LEVEL ]; then |
|
|
|
if [ -z "$NOTIFY_MODE" ] || [ "$NOTIFY_MODE" = "$NOTIFY_MODE_BULK" ]; then |
|
|
|
_msg_subject="Renew" |
|
|
|
if [ "$_error_msg" ]; then |
|
|
|
_msg_subject="${_msg_subject} Error" |
|
|
|
_msg_data="Error certs: |
|
|
|
${_error_msg} |
|
|
|
" |
|
|
|
fi |
|
|
|
if [ "$_success_msg" ]; then |
|
|
|
_msg_subject="${_msg_subject} Success" |
|
|
|
_msg_data="${_msg_data}Success certs: |
|
|
|
${_success_msg} |
|
|
|
" |
|
|
|
fi |
|
|
|
if [ "$_skipped_msg" ]; then |
|
|
|
_msg_subject="${_msg_subject} Skipped" |
|
|
|
fi |
|
|
|
_msg_data="Error certs: |
|
|
|
${_error_msg} |
|
|
|
Success certs: |
|
|
|
${_success_msg} |
|
|
|
Skipped certs: |
|
|
|
$_skipped_msg |
|
|
|
_msg_data="${_msg_data}Skipped certs: |
|
|
|
${_skipped_msg} |
|
|
|
" |
|
|
|
_send_notify "$_msg_subject" "$_msg_data" "$NOTIFY_HOOK" 0 |
|
|
|
fi |
|
|
|
|
|
|
|
_send_notify "$_msg_subject" "$_msg_data" "$NOTIFY_HOOK" "$_notify_code" |
|
|
|
fi |
|
|
|
fi |
|
|
|
|
|
|
@ -5708,7 +5721,7 @@ install() { |
|
|
|
_debug "Skip install cron job" |
|
|
|
fi |
|
|
|
|
|
|
|
if [ "$IN_CRON" != "1" ]; then |
|
|
|
if [ "$ACME_IN_CRON" != "1" ]; then |
|
|
|
if ! _precheck "$_nocron"; then |
|
|
|
_err "Pre-check failed, can not install." |
|
|
|
return 1 |
|
|
@ -5765,7 +5778,7 @@ install() { |
|
|
|
|
|
|
|
_info "Installed to $LE_WORKING_DIR/$PROJECT_ENTRY" |
|
|
|
|
|
|
|
if [ "$IN_CRON" != "1" ] && [ -z "$_noprofile" ]; then |
|
|
|
if [ "$ACME_IN_CRON" != "1" ] && [ -z "$_noprofile" ]; then |
|
|
|
_installalias "$_c_home" |
|
|
|
fi |
|
|
|
|
|
|
@ -5863,7 +5876,7 @@ _uninstallalias() { |
|
|
|
} |
|
|
|
|
|
|
|
cron() { |
|
|
|
export IN_CRON=1 |
|
|
|
export ACME_IN_CRON=1 |
|
|
|
_initpath |
|
|
|
_info "$(__green "===Starting cron===")" |
|
|
|
if [ "$AUTO_UPGRADE" = "1" ]; then |
|
|
@ -5884,7 +5897,7 @@ cron() { |
|
|
|
fi |
|
|
|
renewAll |
|
|
|
_ret="$?" |
|
|
|
IN_CRON="" |
|
|
|
ACME_IN_CRON="" |
|
|
|
_info "$(__green "===End cron===")" |
|
|
|
exit $_ret |
|
|
|
} |
|
|
@ -6106,11 +6119,11 @@ Parameters: |
|
|
|
|
|
|
|
--notify-level 0|1|2|3 Set the notification level: Default value is $NOTIFY_LEVEL_DEFAULT. |
|
|
|
0: disabled, no notification will be sent. |
|
|
|
1: send notification only when there is an error. |
|
|
|
2: send notification when a cert is successfully renewed, or there is an error |
|
|
|
3: send notification when a cert is skipped, renewdd, or error |
|
|
|
1: send notifications only when there is an error. |
|
|
|
2: send notifications when a cert is successfully renewed, or there is an error. |
|
|
|
3: send notifications when a cert is skipped, renewed, or error. |
|
|
|
--notify-mode 0|1 Set notification mode. Default value is $NOTIFY_MODE_DEFAULT. |
|
|
|
0: Bulk mode. Send all the domain's notifications in one message(mail) |
|
|
|
0: Bulk mode. Send all the domain's notifications in one message(mail). |
|
|
|
1: Cert mode. Send a message for every single cert. |
|
|
|
--notify-hook [hookname] Set the notify hook |
|
|
|
|
|
|
|