Skip to content

Commit 53db975

Browse files
committed
Switch to certbot-dns-duckdns
1 parent 3fb6e3f commit 53db975

File tree

8 files changed

+32
-28
lines changed

8 files changed

+32
-28
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ RUN \
116116
certbot-dns-dnspod \
117117
certbot-dns-do \
118118
certbot-dns-domeneshop \
119+
certbot-dns-duckdns \
119120
certbot-dns-dynu \
120121
certbot-dns-gehirn \
121122
certbot-dns-godaddy \

Dockerfile.aarch64

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ RUN \
116116
certbot-dns-dnspod \
117117
certbot-dns-do \
118118
certbot-dns-domeneshop \
119+
certbot-dns-duckdns \
119120
certbot-dns-dynu \
120121
certbot-dns-gehirn \
121122
certbot-dns-godaddy \

Dockerfile.armhf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ RUN \
116116
certbot-dns-dnspod \
117117
certbot-dns-do \
118118
certbot-dns-domeneshop \
119+
certbot-dns-duckdns \
119120
certbot-dns-dynu \
120121
certbot-dns-gehirn \
121122
certbot-dns-godaddy \

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64
336336

337337
## Versions
338338

339-
* **06.10.22:** - Update cpanel and gandi dns plugin handling. Minor adjustments to init logic.
339+
* **06.10.22:** - Switch to certbot-dns-duckdns. Update cpanel and gandi dns plugin handling. Minor adjustments to init logic.
340340
* **05.10.22:** - Use certbot file hooks instead of command line hooks
341341
* **04.10.22:** - Add godaddy and porkbun dns plugins.
342342
* **03.10.22:** - Add default_server back to default site conf's https listen.

readme-vars.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ app_setup_nginx_reverse_proxy_block: ""
156156

157157
# changelog
158158
changelogs:
159-
- { date: "06.10.22:", desc: "Update cpanel and gandi dns plugin handling. Minor adjustments to init logic." }
159+
- { date: "06.10.22:", desc: "Switch to certbot-dns-duckdns. Update cpanel and gandi dns plugin handling. Minor adjustments to init logic." }
160160
- { date: "05.10.22:", desc: "Use certbot file hooks instead of command line hooks" }
161161
- { date: "04.10.22:", desc: "Add godaddy and porkbun dns plugins." }
162162
- { date: "03.10.22:", desc: "Add default_server back to default site conf's https listen." }

root/app/duckdns-txt

Lines changed: 0 additions & 8 deletions
This file was deleted.

root/defaults/dns-conf/duckdns.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Instructions: https://github.com/infinityofspace/certbot_dns_duckdns#credentials-file-or-cli-parameters
2+
# Replace with your API token from your duckdns account.
3+
dns_duckdns_token=<your-duckdns-token>

root/etc/cont-init.d/50-certbot

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ for i in "${SANED_VARS[@]}"; do
2323
done
2424

2525
# check to make sure DNSPLUGIN is selected if dns validation is used
26-
if [[ "$VALIDATION" = "dns" ]] && [[ ! "$DNSPLUGIN" =~ ^(acmedns|aliyun|azure|cloudflare|cloudxns|cpanel|desec|digitalocean|directadmin|dnsimple|dnsmadeeasy|dnspod|do|domeneshop|dynu|gandi|gehirn|godaddy|google|he|hetzner|infomaniak|inwx|ionos|linode|loopia|luadns|netcup|njalla|nsone|ovh|porkbun|rfc2136|route53|sakuracloud|standalone|transip|vultr)$ ]]; then
26+
if [[ "$VALIDATION" = "dns" ]] && [[ ! "$DNSPLUGIN" =~ ^(acmedns|aliyun|azure|cloudflare|cloudxns|cpanel|desec|digitalocean|directadmin|dnsimple|dnsmadeeasy|dnspod|do|domeneshop|duckdns|dynu|gandi|gehirn|godaddy|google|he|hetzner|infomaniak|inwx|ionos|linode|loopia|luadns|netcup|njalla|nsone|ovh|porkbun|rfc2136|route53|sakuracloud|standalone|transip|vultr)$ ]]; then
2727
echo "Please set the DNSPLUGIN variable to a valid plugin name. See docker info for more details."
2828
sleep infinity
2929
fi
@@ -50,7 +50,7 @@ if [ -f "/config/donoteditthisfile.conf" ]; then
5050
mv /config/donoteditthisfile.conf /config/.donoteditthisfile.conf
5151
fi
5252
if [ ! -f "/config/.donoteditthisfile.conf" ]; then
53-
echo -e "ORIGURL=\"$URL\" ORIGSUBDOMAINS=\"$SUBDOMAINS\" ORIGONLY_SUBDOMAINS=\"$ONLY_SUBDOMAINS\" ORIGEXTRA_DOMAINS=\"$EXTRA_DOMAINS\" ORIGVALIDATION=\"$VALIDATION\" ORIGDNSPLUGIN=\"$DNSPLUGIN\" ORIGPROPAGATION=\"$PROPAGATION\" ORIGSTAGING=\"$STAGING\" ORIGDUCKDNSTOKEN=\"$DUCKDNSTOKEN\" ORIGCERTPROVIDER=\"$CERTPROVIDER\" ORIGEMAIL=\"$EMAIL\"" >/config/.donoteditthisfile.conf
53+
echo -e "ORIGURL=\"$URL\" ORIGSUBDOMAINS=\"$SUBDOMAINS\" ORIGONLY_SUBDOMAINS=\"$ONLY_SUBDOMAINS\" ORIGEXTRA_DOMAINS=\"$EXTRA_DOMAINS\" ORIGVALIDATION=\"$VALIDATION\" ORIGDNSPLUGIN=\"$DNSPLUGIN\" ORIGPROPAGATION=\"$PROPAGATION\" ORIGSTAGING=\"$STAGING\" ORIGCERTPROVIDER=\"$CERTPROVIDER\" ORIGEMAIL=\"$EMAIL\"" >/config/.donoteditthisfile.conf
5454
echo "Created .donoteditthisfile.conf"
5555
fi
5656

@@ -64,6 +64,25 @@ if [ -z "$VALIDATION" ]; then
6464
echo "VALIDATION parameter not set; setting it to http"
6565
fi
6666

67+
# set duckdns validation to dns
68+
if [ "$VALIDATION" = "duckdns" ]; then
69+
VALIDATION="dns"
70+
DNSPLUGIN="duckdns"
71+
if [ -n "$DUCKDNSTOKEN" ] && ! grep -q "dns_duckdns_token=${DUCKDNSTOKEN}$" /config/dns-conf/duckdns.ini;then
72+
sed -i "s|^dns_duckdns_token=.*|dns_duckdns_token=${DUCKDNSTOKEN}|g" /config/dns-conf/duckdns.ini
73+
fi
74+
fi
75+
if [ "$VALIDATION" = "dns" ] && [ "$DNSPLUGIN" = "duckdns" ]; then
76+
if [ "$SUBDOMAINS" = "wildcard" ]; then
77+
echo "the resulting certificate will only cover the subdomains due to a limitation of duckdns, so it is advised to set the root location to use www.subdomain.duckdns.org"
78+
export ONLY_SUBDOMAINS=true
79+
else
80+
echo "the resulting certificate will only cover the main domain due to a limitation of duckdns, ie. subdomain.duckdns.org"
81+
export SUBDOMAINS=""
82+
fi
83+
export EXTRA_DOMAINS=""
84+
fi
85+
6786
# if zerossl is selected or staging is set to true, use the relevant server
6887
if [ "$CERTPROVIDER" = "zerossl" ] && [ "$STAGING" = "true" ]; then
6988
echo "ZeroSSL does not support staging mode, ignoring STAGING variable"
@@ -142,7 +161,7 @@ if [ "$VALIDATION" = "dns" ]; then
142161
elif [[ "$DNSPLUGIN" =~ ^(google)$ ]]; then
143162
if [ -n "$PROPAGATION" ]; then PROPAGATIONPARAM="--dns-${DNSPLUGIN}-propagation-seconds ${PROPAGATION}"; fi
144163
PREFCHAL="--dns-${DNSPLUGIN} --dns-${DNSPLUGIN}-credentials /config/dns-conf/${DNSPLUGIN}.json ${PROPAGATIONPARAM}"
145-
elif [[ "$DNSPLUGIN" =~ ^(aliyun|cpanel|desec|dnspod|do|domeneshop|dynu|godaddy|he|hetzner|infomaniak|inwx|ionos|loopia|netcup|njalla|porkbun|transip|vultr)$ ]]; then
164+
elif [[ "$DNSPLUGIN" =~ ^(aliyun|cpanel|desec|dnspod|do|domeneshop|duckdns|dynu|godaddy|he|hetzner|infomaniak|inwx|ionos|loopia|netcup|njalla|porkbun|transip|vultr)$ ]]; then
146165
if [ -n "$PROPAGATION" ]; then PROPAGATIONPARAM="--dns-${DNSPLUGIN}-propagation-seconds ${PROPAGATION}"; fi
147166
PREFCHAL="-a dns-${DNSPLUGIN} --dns-${DNSPLUGIN}-credentials /config/dns-conf/${DNSPLUGIN}.ini ${PROPAGATIONPARAM}"
148167
elif [[ "$DNSPLUGIN" =~ ^(standalone)$ ]]; then
@@ -159,17 +178,6 @@ if [ "$VALIDATION" = "dns" ]; then
159178
elif [ "$VALIDATION" = "tls-sni" ]; then
160179
PREFCHAL="--standalone --preferred-challenges http"
161180
echo "*****tls-sni validation has been deprecated, attempting http validation instead"
162-
elif [ "$VALIDATION" = "duckdns" ]; then
163-
PREFCHAL="--manual --preferred-challenges dns --manual-auth-hook /app/duckdns-txt"
164-
chmod +x /app/duckdns-txt
165-
echo "duckdns validation is selected"
166-
if [ "$SUBDOMAINS" = "wildcard" ]; then
167-
echo "the resulting certificate will only cover the subdomains due to a limitation of duckdns, so it is advised to set the root location to use www.subdomain.duckdns.org"
168-
export URL_REAL="-d *.${URL}"
169-
else
170-
echo "the resulting certificate will only cover the main domain due to a limitation of duckdns, ie. subdomain.duckdns.org"
171-
export URL_REAL="-d ${URL}"
172-
fi
173181
else
174182
PREFCHAL="--standalone --preferred-challenges http"
175183
echo "http validation is selected"
@@ -189,7 +197,7 @@ rm -rf /config/keys/cert.key
189197
ln -s ./letsencrypt/privkey.pem /config/keys/cert.key
190198

191199
# checking for changes in cert variables, revoking certs if necessary
192-
if [ ! "$URL" = "$ORIGURL" ] || [ ! "$SUBDOMAINS" = "$ORIGSUBDOMAINS" ] || [ ! "$ONLY_SUBDOMAINS" = "$ORIGONLY_SUBDOMAINS" ] || [ ! "$EXTRA_DOMAINS" = "$ORIGEXTRA_DOMAINS" ] || [ ! "$VALIDATION" = "$ORIGVALIDATION" ] || [ ! "$DNSPLUGIN" = "$ORIGDNSPLUGIN" ] || [ ! "$PROPAGATION" = "$ORIGPROPAGATION" ] || [ ! "$STAGING" = "$ORIGSTAGING" ] || [ ! "$DUCKDNSTOKEN" = "$ORIGDUCKDNSTOKEN" ] || [ ! "$CERTPROVIDER" = "$ORIGCERTPROVIDER" ]; then
200+
if [ ! "$URL" = "$ORIGURL" ] || [ ! "$SUBDOMAINS" = "$ORIGSUBDOMAINS" ] || [ ! "$ONLY_SUBDOMAINS" = "$ORIGONLY_SUBDOMAINS" ] || [ ! "$EXTRA_DOMAINS" = "$ORIGEXTRA_DOMAINS" ] || [ ! "$VALIDATION" = "$ORIGVALIDATION" ] || [ ! "$DNSPLUGIN" = "$ORIGDNSPLUGIN" ] || [ ! "$PROPAGATION" = "$ORIGPROPAGATION" ] || [ ! "$STAGING" = "$ORIGSTAGING" ] || [ ! "$CERTPROVIDER" = "$ORIGCERTPROVIDER" ]; then
193201
echo "Different validation parameters entered than what was used before. Revoking and deleting existing certificate, and an updated one will be created"
194202
if [ "$ORIGONLY_SUBDOMAINS" = "true" ] && [ ! "$ORIGSUBDOMAINS" = "wildcard" ]; then
195203
ORIGDOMAIN="$(echo "$ORIGSUBDOMAINS" | tr ',' ' ' | awk '{print $1}').${ORIGURL}"
@@ -217,7 +225,7 @@ if [ ! "$URL" = "$ORIGURL" ] || [ ! "$SUBDOMAINS" = "$ORIGSUBDOMAINS" ] || [ ! "
217225
fi
218226

219227
# saving new variables
220-
echo -e "ORIGURL=\"$URL\" ORIGSUBDOMAINS=\"$SUBDOMAINS\" ORIGONLY_SUBDOMAINS=\"$ONLY_SUBDOMAINS\" ORIGEXTRA_DOMAINS=\"$EXTRA_DOMAINS\" ORIGVALIDATION=\"$VALIDATION\" ORIGDNSPLUGIN=\"$DNSPLUGIN\" ORIGPROPAGATION=\"$PROPAGATION\" ORIGSTAGING=\"$STAGING\" ORIGDUCKDNSTOKEN=\"$DUCKDNSTOKEN\" ORIGCERTPROVIDER=\"$CERTPROVIDER\" ORIGEMAIL=\"$EMAIL\"" >/config/.donoteditthisfile.conf
228+
echo -e "ORIGURL=\"$URL\" ORIGSUBDOMAINS=\"$SUBDOMAINS\" ORIGONLY_SUBDOMAINS=\"$ONLY_SUBDOMAINS\" ORIGEXTRA_DOMAINS=\"$EXTRA_DOMAINS\" ORIGVALIDATION=\"$VALIDATION\" ORIGDNSPLUGIN=\"$DNSPLUGIN\" ORIGPROPAGATION=\"$PROPAGATION\" ORIGSTAGING=\"$STAGING\" ORIGCERTPROVIDER=\"$CERTPROVIDER\" ORIGEMAIL=\"$EMAIL\"" >/config/.donoteditthisfile.conf
221229

222230
# alter extension for error message
223231
if [ "$DNSPLUGIN" = "google" ]; then
@@ -255,8 +263,6 @@ if [ ! -f "/config/keys/letsencrypt/fullchain.pem" ]; then
255263
if [ ! -d /config/keys/letsencrypt ]; then
256264
if [ "$VALIDATION" = "dns" ]; then
257265
echo "ERROR: Cert does not exist! Please see the validation error above. Make sure you entered correct credentials into the /config/dns-conf/${FILENAME} file."
258-
elif [ "$VALIDATION" = "duckdns" ]; then
259-
echo "ERROR: Cert does not exist! Please see the validation error above. Make sure your DUCKDNSTOKEN is correct."
260266
else
261267
echo "ERROR: Cert does not exist! Please see the validation error above. The issue may be due to incorrect dns or port forwarding settings. Please fix your settings and recreate the container"
262268
fi

0 commit comments

Comments
 (0)