]> git.street.me.uk Git - andy/dehydrated.git/blob - docs/examples/hook.sh
3f2a5867a24816b5ebaa6071e3181a1d185bc04c
[andy/dehydrated.git] / docs / examples / hook.sh
1 #!/bin/sh
2
3 deploy_challenge() {
4     local DOMAIN="${1}" TOKEN_FILENAME="${2}" TOKEN_VALUE="${3}"
5
6     # This hook is called once for every domain that needs to be
7     # validated, including any alternative names you may have listed.
8     #
9     # Parameters:
10     # - DOMAIN
11     #   The domain name (CN or subject alternative name) being
12     #   validated.
13     # - TOKEN_FILENAME
14     #   The name of the file containing the token to be served for HTTP
15     #   validation. Should be served by your web server as
16     #   /.well-known/acme-challenge/${TOKEN_FILENAME}.
17     # - TOKEN_VALUE
18     #   The token value that needs to be served for validation. For DNS
19     #   validation, this is what you want to put in the _acme-challenge
20     #   TXT record. For HTTP validation it is the value that is expected
21     #   be found in the $TOKEN_FILENAME file.
22 }
23
24 clean_challenge() {
25     local DOMAIN="${1}" TOKEN_FILENAME="${2}" TOKEN_VALUE="${3}"
26
27     # This hook is called after attempting to validate each domain,
28     # whether or not validation was successful. Here you can delete
29     # files or DNS records that are no longer needed.
30     #
31     # The parameters are the same as for deploy_challenge.
32 }
33
34 deploy_cert() {
35     local DOMAIN="${1}" KEYFILE="${2}" CERTFILE="${3}" FULLCHAINFILE="${4}" CHAINFILE="${5}" TIMESTAMP="${6}"
36
37     # This hook is called once for each certificate that has been
38     # produced. Here you might, for instance, copy your new certificates
39     # to service-specific locations and reload the service.
40     #
41     # Parameters:
42     # - DOMAIN
43     #   The primary domain name, i.e. the certificate common
44     #   name (CN).
45     # - KEYFILE
46     #   The path of the file containing the private key.
47     # - CERTFILE
48     #   The path of the file containing the signed certificate.
49     # - FULLCHAINFILE
50     #   The path of the file containing the full certificate chain.
51     # - CHAINFILE
52     #   The path of the file containing the intermediate certificate(s).
53     # - TIMESTAMP
54     #   Timestamp when the specified certificate was created.
55 }
56
57 unchanged_cert() {
58     local DOMAIN="${1}" KEYFILE="${2}" CERTFILE="${3}" FULLCHAINFILE="${4}" CHAINFILE="${5}"
59
60     # This hook is called once for each certificate that is still
61     # valid and therefore wasn't reissued.
62     #
63     # Parameters:
64     # - DOMAIN
65     #   The primary domain name, i.e. the certificate common
66     #   name (CN).
67     # - KEYFILE
68     #   The path of the file containing the private key.
69     # - CERTFILE
70     #   The path of the file containing the signed certificate.
71     # - FULLCHAINFILE
72     #   The path of the file containing the full certificate chain.
73     # - CHAINFILE
74     #   The path of the file containing the intermediate certificate(s).
75 }
76
77 invalid_challenge() {
78     local DOMAIN="${1}" RESPONSE="${2}"
79
80     # This hook is called if the challenge response has failed, so domain
81     # owners can be aware and act accordingly.
82     #
83     # Parameters:
84     # - DOMAIN
85     #   The primary domain name, i.e. the certificate common
86     #   name (CN).
87     # - RESPONSE
88     #   The response that the verification server returned
89 }
90
91 request_failure() {
92     local STATUSCODE="${1}" REASON="${2}" REQTYPE=${3}
93
94     # This hook is called when a HTTP request fails (e.g., when the ACME
95     # server is busy, returns an error, etc). It will be called upon any
96     # response code that does not start with '2'. Useful to alert admins
97     # about problems with requests.
98     #
99     # Parameters:
100     # - STATUSCODE
101     #   The HTML status code that originated the error.
102     # - REASON
103     #   The specified reason for the error.
104     # - REQTYPE
105     #   The kind of request that was made (GET, POST...)
106 }
107
108 HANDLER="$1"; shift
109 "$HANDLER" "$@"