]> git.street.me.uk Git - andy/dehydrated.git/commitdiff
Adding the request_failure hook (#326)
authornkovacne <nkovacne@ull.edu.es>
Thu, 5 Jan 2017 23:15:51 +0000 (00:15 +0100)
committerLukas Schauer <lukas2511@users.noreply.github.com>
Thu, 5 Jan 2017 23:15:51 +0000 (00:15 +0100)
dehydrated
docs/dns-verification.md
docs/examples/hook.sh

index 7223fed124e8eb2691ba3a30aec75f6476a02724..dc9265ef6ad4571ffa174f3eec94713f92d169cd 100755 (executable)
@@ -366,6 +366,13 @@ http_request() {
     cat "${tempcont}" >&2
     echo >&2
     echo >&2
+
+    # An exclusive hook for the {1}-request error might be useful (e.g., for sending an e-mail to admins)
+    if [[ -n "${HOOK}" ]] && [[ "${HOOK_CHAIN}" != "yes" ]]; then
+      errtxt=`cat ${tempcont}`
+      "${HOOK}" "request_failure" "${statuscode}" "${errtxt}" "${1}"
+    fi
+
     rm -f "${tempcont}"
 
     # Wait for hook script to clean the challenge if used
index 0813cb0fb6bd3f0fd9c3e04acca69e491503ffc0..d9f3df2bb9d5f22b729663e47b158ce2200147f3 100644 (file)
@@ -4,7 +4,7 @@ This script also supports the new `dns-01`-type verification. This type of verif
 
 You need a hook script that deploys the challenge to your DNS server!
 
-The hook script (indicated in the config file or the --hook/-k command line argument) gets four arguments: an operation name (clean_challenge, deploy_challenge, deploy_cert or invalid_challenge) and some operands for that. For deploy_challenge $2 is the domain name for which the certificate is required, $3 is a "challenge token" (which is not needed for dns-01), and $4 is a token which needs to be inserted in a TXT record for the domain.
+The hook script (indicated in the config file or the --hook/-k command line argument) gets four arguments: an operation name (clean_challenge, deploy_challenge, deploy_cert, invalid_challenge or request_failure) and some operands for that. For deploy_challenge $2 is the domain name for which the certificate is required, $3 is a "challenge token" (which is not needed for dns-01), and $4 is a token which needs to be inserted in a TXT record for the domain.
 
 Typically, you will need to split the subdomain name in two, the subdomain name and the domain name separately. For example, for "my.example.com", you'll need "my" and "example.com" separately. You then have to prefix "_acme-challenge." before the subdomain name, as in "_acme-challenge.my" and set a TXT record for that on the domain (e.g. "example.com") which has the value supplied in $4
 
index 0ea0a0e1873e1aeab4238330af7021d96a4ac8c2..4e9f886e30b9c9d30e6ec05d97352605383d059c 100755 (executable)
@@ -88,5 +88,22 @@ function invalid_challenge {
     #   The response that the verification server returned
 }
 
+request_failure() {
+    local STATUSCODE="${1}" REASON="${2}" REQTYPE=${3}
+
+    # This hook is called when a HTTP request fails (e.g., when the ACME
+    # server is busy, returns an error, etc). It will be called upon any
+    # response code that does not start with '2'. Useful to alert admins
+    # about problems with requests.
+    #
+    # Parameters:
+    # - STATUSCODE
+    #   The HTML status code that originated the error.
+    # - REASON
+    #   The specified reason for the error.
+    # - REQTYPE
+    #   The kind of request that was made (GET, POST...)
+}
+
 HANDLER="$1"; shift
-"$HANDLER" "$@"
\ No newline at end of file
+"$HANDLER" "$@"