-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathduckdns-hook.sh
executable file
·59 lines (54 loc) · 1.33 KB
/
duckdns-hook.sh
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 sh
# inspired by https://www.splitbrain.org/blog/2017-08/10-homeassistant_duckdns_letsencrypt
set -e
set -u
set -o pipefail
domain="${CERTBOT_DOMAIN}"
token="$2"
txt="${CERTBOT_VALIDATION}"
which curl || :
if [[ $? -eq 0 ]]; then
http_method=curl
fi
which wget || :
if [[ $? -eq 0 ]]; then
http_method=wget
else
echo "Neither CURL nor WGET installed"
exit
fi
curl_options="-q"
wget_options="-q"
case "$1" in
"deploy_challenge")
url="https://www.duckdns.org/update?domains=$domain&token=$token&txt=${txt}&verbose=true"
if [[ ${http_method} == "curl" ]]; then
curl "${url}" ${curl_options}
elif [[ ${http_method} == "wget" ]]; then
wget "${url}" ${wget_options}
fi
echo
;;
"clean_challenge")
url="https://www.duckdns.org/update?domains=$domain&token=$token&txt=removed&clear=true"
if [[ ${http_method} == "curl" ]]; then
curl "${url}" ${curl_options}
elif [[ ${http_method} == "wget" ]]; then
wget "${url}" ${wget_options}
fi
echo
;;
"deploy_cert")
# sudo systemctl restart [email protected]
;;
"unchanged_cert")
;;
"startup_hook")
;;
"exit_hook")
;;
*)
echo Unknown hook "${1}"
exit 0
;;
esac