Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ If the token is not in the enviornment yet, set it up by the following commands
$ export DUCKDNS_TOKEN='example-token'
```

A few other settings are available via environment variables:

- use `DUCKDNS_VERBOSE=true` to print more details from the DuckDNS API. Defaults to "false".
- use `DUCKDNS_DELAY_SECONDS` change how long the script waits for DNS propagation. Defaults to "30".


## Usage

```
Expand Down
11 changes: 7 additions & 4 deletions hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,22 @@ if [[ -z "${DUCKDNS_TOKEN}" ]]; then
echo " - Unable to locate DuckDNS Token in the environment! Make sure DUCKDNS_TOKEN environment variable is set"
fi

VERBOSE="${DUCKDNS_VERBOSE:-false}"
DELAY="${DUCKDNS_DELAY_SECONDS:-30}"

deploy_challenge() {
local DOMAIN="${1}" TOKEN_FILENAME="${2}" TOKEN_VALUE="${3}"
echo -n " - Setting TXT record with DuckDNS ${TOKEN_VALUE}"
curl "https://www.duckdns.org/update?domains=${DOMAIN}&token=${DUCKDNS_TOKEN}&txt=${TOKEN_VALUE}"
curl -s "https://www.duckdns.org/update?domains=${DOMAIN}&token=${DUCKDNS_TOKEN}&txt=${TOKEN_VALUE}&verbose=${VERBOSE}"
echo
echo " - Waiting 30 seconds for DNS to propagate."
sleep 30
echo " - Waiting $DELAY seconds for DNS to propagate."
sleep "$DELAY"
}

clean_challenge() {
local DOMAIN="${1}" TOKEN_FILENAME="${2}" TOKEN_VALUE="${3}"
echo -n " - Removing TXT record from DuckDNS ${DOMAIN}"
curl "https://www.duckdns.org/update?domains=${DOMAIN}&token=${DUCKDNS_TOKEN}&txt=removed&clear=true"
curl -s "https://www.duckdns.org/update?domains=${DOMAIN}&token=${DUCKDNS_TOKEN}&txt=removed&clear=true&verbose=${VERBOSE}"
echo
}

Expand Down