From: Lukas Schauer Date: Thu, 22 Dec 2016 21:41:24 +0000 (+0100) Subject: trying to fix #320 again X-Git-Tag: v0.4.0~24 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3c1d2673d1f0f8da717bcbc516fdd2b29fb1cf0a;p=thirdparty%2Fdehydrated.git trying to fix #320 again --- diff --git a/dehydrated b/dehydrated index 0a808bc..7223fed 100755 --- a/dehydrated +++ b/dehydrated @@ -472,7 +472,7 @@ sign_csr() { challenge_status="$(printf '%s' "${response}" | rm_json_arrays | get_json_string_value status)" if [ "${challenge_status}" = "valid" ]; then - echo " + Already validated" + echo " + Already validated!" continue fi @@ -510,9 +510,10 @@ sign_csr() { deploy_args[${idx}]="${altname} ${challenge_token} ${keyauth_hook}" idx=$((idx+1)) done + challenge_count="${idx}" # Wait for hook script to deploy the challenges if used - if [ ${#deploy_args[@]} -ne 0 ]; then + if [[ ${challenge_count} -ne 0 ]]; then # shellcheck disable=SC2068 [[ -n "${HOOK}" ]] && [[ "${HOOK_CHAIN}" = "yes" ]] && "${HOOK}" "deploy_challenge" ${deploy_args[@]} fi @@ -520,7 +521,7 @@ sign_csr() { # Respond to challenges reqstatus="valid" idx=0 - if [ ${#challenge_altnames[@]} -ne 0 ]; then + if [ ${challenge_count} -ne 0 ]; then for altname in "${challenge_altnames[@]:0}"; do challenge_token="${challenge_tokens[${idx}]}" keyauth="${keyauths[${idx}]}" @@ -560,11 +561,13 @@ sign_csr() { # Wait for hook script to clean the challenges if used # shellcheck disable=SC2068 - [[ -n "${HOOK}" ]] && [[ "${HOOK_CHAIN}" = "yes" ]] && "${HOOK}" "clean_challenge" ${deploy_args[@]} + if [[ ${challenge_count} -ne 0 ]]; then + [[ -n "${HOOK}" ]] && [[ "${HOOK_CHAIN}" = "yes" ]] && "${HOOK}" "clean_challenge" ${deploy_args[@]} + fi if [[ "${reqstatus}" != "valid" ]]; then # Clean up any remaining challenge_tokens if we stopped early - if [[ "${CHALLENGETYPE}" = "http-01" ]]; then + if [[ "${CHALLENGETYPE}" = "http-01" ]] && [[ ${challenge_count} -ne 0 ]]; then while [ ${idx} -lt ${#challenge_tokens[@]} ]; do rm -f "${WELLKNOWN}/${challenge_tokens[${idx}]}" idx=$((idx+1))