Skip to content

Commit

Permalink
Duckdns alias support (home-assistant#1253)
Browse files Browse the repository at this point in the history
* Add alias option to duckdns

* add docs

* fix DOCS

* Update config.json

* Update CHANGELOG.md

* Update DOCS.md

Co-authored-by: Pascal Vizeli <pascal.vizeli@syshack.ch>
noamokman and pvizeli authored May 18, 2020
1 parent 16c132e commit 2a3b0ec
Showing 4 changed files with 34 additions and 43 deletions.
43 changes: 5 additions & 38 deletions duckdns/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,18 @@
# Changelog

## 1.12
## 1.12.0

- Add option to specify a service or URL as IPv4 and IPv6 address source
- Add DNS alias option to allow pointing a CNAME at a Duck DNS subdomain

## 1.11
## 1.11.0

- Do not skip TLS security checks on Duck DNS API access

## 1.10
## 1.10.0

- Fix issue with dehydrated lock file

## 1.9
## 1.9.0

- Fix issue with empty IPv4 / IPv6

## 1.8

- Update dehydrated to 0.6.5
- Migrate scripts to bashio

## 1.7

- Add support for manual set IPv4 and IPv6 address

## 1.6

- Update Alpine images / OpenSSL

## 1.5

- Fix bug with multible domains for Let's encrypt

## 1.4

- Update dehydrated to version 0.6.2

## 1.3

- Fix dehydrated warning from hook script

## 1.2

- Update dehydrated to version 0.6.1

## 1.1

- Update dehydrated to version 0.5.0
- Update base image to alpine 3.7
18 changes: 18 additions & 0 deletions duckdns/DOCS.md
Original file line number Diff line number Diff line change
@@ -81,6 +81,24 @@ The DuckDNS authentication token found at the top of the DuckDNS account landing

A list of DuckDNS subdomains registered under your account. An acceptable naming convention is `my-domain.duckdns.org`.

### Option: `aliases` (optional)

A list aliases of domains configured on the `domains` option.
This is useful in cases where you would like to use your own domain.
Create a CNAME record to point at the DuckDNS subdomain and set this value accordingly.

For example:
```yaml
domains:
- my-domain.duckdns.org
- ha.my-domain.com
aliases:
- domain: ha.my-domain.com
alias: my-domain.duckdns.org
```

Also, add your custom domain name to the `domains` array to create the certificate for both domains

### Option: `seconds`

The number of seconds to wait before updating DuckDNS subdomains and renewing Let's Encrypt certificates.
6 changes: 5 additions & 1 deletion duckdns/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Duck DNS",
"version": "1.11",
"version": "1.12.0",
"slug": "duckdns",
"description": "Free Dynamic DNS (DynDNS or DDNS) service with Let's Encrypt support",
"url": "https://github.com/home-assistant/hassio-addons/tree/master/duckdns",
@@ -16,6 +16,7 @@
},
"token": null,
"domains": [null],
"aliases": [],
"seconds": 300
},
"schema": {
@@ -28,6 +29,9 @@
"ipv6": "str?",
"token": "str",
"domains": ["str"],
"aliases": [
{"domain": "str", "alias": "str"}
],
"seconds": "int"
},
"image": "homeassistant/{arch}-addon-duckdns"
10 changes: 6 additions & 4 deletions duckdns/data/hooks.sh
Original file line number Diff line number Diff line change
@@ -11,7 +11,8 @@ SYS_KEYFILE=$(jq --raw-output '.lets_encrypt.keyfile' $CONFIG_PATH)
# https://github.com/lukas2511/dehydrated/blob/master/docs/examples/hook.sh

deploy_challenge() {
local DOMAIN="${1}" TOKEN_FILENAME="${2}" TOKEN_VALUE="${3}"
local DOMAIN="${1}" TOKEN_FILENAME="${2}" TOKEN_VALUE="${3}" ALIAS
ALIAS="$(jq --raw-output --exit-status "[.aliases[]|{(.domain):.alias}]|add.\"$DOMAIN\"" $CONFIG_PATH)" || ALIAS="$DOMAIN"

# This hook is called once for every domain that needs to be
# validated, including any alternative names you may have listed.
@@ -30,19 +31,20 @@ deploy_challenge() {
# TXT record. For HTTP validation it is the value that is expected
# be found in the $TOKEN_FILENAME file.

curl -s "https://www.duckdns.org/update?domains=$DOMAIN&token=$SYS_TOKEN&txt=$TOKEN_VALUE"
curl -s "https://www.duckdns.org/update?domains=$ALIAS&token=$SYS_TOKEN&txt=$TOKEN_VALUE"
}

clean_challenge() {
local DOMAIN="${1}" TOKEN_FILENAME="${2}" TOKEN_VALUE="${3}"
local DOMAIN="${1}" TOKEN_FILENAME="${2}" TOKEN_VALUE="${3}" ALIAS
ALIAS="$(jq --raw-output --exit-status "[.aliases[]|{(.domain):.alias}]|add.\"$DOMAIN\"" $CONFIG_PATH)" || ALIAS="$DOMAIN"

# This hook is called after attempting to validate each domain,
# whether or not validation was successful. Here you can delete
# files or DNS records that are no longer needed.
#
# The parameters are the same as for deploy_challenge.

curl -s "https://www.duckdns.org/update?domains=$DOMAIN&token=$SYS_TOKEN&txt=removed&clear=true"
curl -s "https://www.duckdns.org/update?domains=$ALIAS&token=$SYS_TOKEN&txt=removed&clear=true"
}

deploy_cert() {

0 comments on commit 2a3b0ec

Please sign in to comment.