-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcode-rack
executable file
·59 lines (54 loc) · 1.63 KB
/
code-rack
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env bash
# dehydrated-code-rack - easily invoke multiple dehydrated hooks
# Copyright (c) 2018 Mythic Beasts Ltd
# All right reserved
handler="$1"; shift
case $handler in
deploy_challenge|clean_challenge)
export DOMAIN="$1" TOKEN_FILENAME="$2" TOKEN_VALUE="$3"
# allow chaining - see documentation
args=''
while [ "$1" ]; do args="$args$1 $2 $3"$'\n'; shift 3; done
export ARGS="$args"
;;
deploy_cert|unchanged_cert)
export DOMAIN="$1"
export KEYFILE="$2" CERTFILE="$3" FULLCHAINFILE="$4" CHAINFILE="$5"
export TIMESTAMP="$6" # not set for unchanged_cert
;;
invalid_challenge)
export DOMAIN="$1" RESPONSE="$2"
;;
request_failure)
export STATUSCODE="$1" REASON="$2" REQTYPE="$3" HEADERS="$4"
;;
startup_hook)
# No variables for this one
;;
generate_csr)
export DOMAIN="$1" CERTDIR="$2" ALTNAMES="$3"
;;
deploy_ocsp)
export DOMAIN="$1" OCSPFILE="$2" TIMESTAMP="$3"
;;
sync_cert)
export KEYFILE="$1" CERTFILE="$2" FULLCHAINFILE="$3" CHAINFILE="$4" REQUESTFILE="$5"
;;
exit_hook)
export ERROR="${1:-}"
;;
*)
echo "Unknown hook: $handler" >&2
exit 0
;;
esac
dir="$(dirname "$0")"/${handler//_/-}
/bin/mkdir -p "$dir"
if [ -x /bin/run-parts ]
then
/bin/run-parts "$dir"
else
# No run-parts - probably not a Debian system, fallback to emulating run-parts with /usr/bin/find
# /usr/bin/find is present on CentOS and FreeBSD
/usr/bin/find "$dir" -executable -regex '.*/[A-Za-z0-9_-]+' -exec '{}' \;
fi