mirror of
https://github.com/aljazceru/addons.git
synced 2025-12-17 21:24:20 +01:00
Fix domain layout duckdns (#325)
* Update run.sh * Update config.json * Update hooks.sh * Update run.sh * Update CHANGELOG.md * Update run.sh * Update hooks.sh
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
# Changelog
|
||||
|
||||
## 1.5
|
||||
- Fix bug with multible domains for Let's encrypt
|
||||
|
||||
## 1.4
|
||||
- Update dehydrated to version 0.6.2
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "Duck DNS",
|
||||
"version": "1.4",
|
||||
"version": "1.5",
|
||||
"slug": "duckdns",
|
||||
"description": "Free Dynamic DNS (DynDNS or DDNS) service with Let's Encrypt support",
|
||||
"url": "https://home-assistant.io/addons/duckdns/",
|
||||
|
||||
@@ -1,23 +1,78 @@
|
||||
#!/bin/bash
|
||||
# shellcheck disable=SC2034
|
||||
set -e
|
||||
|
||||
CONFIG_PATH=/data/options.json
|
||||
|
||||
DOMAINS=$(jq --raw-output '.domains | join(",")' $CONFIG_PATH)
|
||||
TOKEN=$(jq --raw-output '.token' $CONFIG_PATH)
|
||||
CERTFILE=$(jq --raw-output '.lets_encrypt.certfile' $CONFIG_PATH)
|
||||
KEYFILE=$(jq --raw-output '.lets_encrypt.keyfile' $CONFIG_PATH)
|
||||
SYS_TOKEN=$(jq --raw-output '.token' $CONFIG_PATH)
|
||||
SYS_CERTFILE=$(jq --raw-output '.lets_encrypt.certfile' $CONFIG_PATH)
|
||||
SYS_KEYFILE=$(jq --raw-output '.lets_encrypt.keyfile' $CONFIG_PATH)
|
||||
|
||||
# https://github.com/lukas2511/dehydrated/blob/master/docs/examples/hook.sh
|
||||
case "$1" in
|
||||
"deploy_challenge")
|
||||
curl -s "https://www.duckdns.org/update?domains=$DOMAINS&token=$TOKEN&txt=$4"
|
||||
;;
|
||||
"clean_challenge")
|
||||
curl -s "https://www.duckdns.org/update?domains=$DOMAINS&token=$TOKEN&txt=removed&clear=true"
|
||||
;;
|
||||
"deploy_cert")
|
||||
cp -f "$5" "/ssl/$CERTFILE"
|
||||
cp -f "$3" "/ssl/$KEYFILE"
|
||||
;;
|
||||
esac
|
||||
|
||||
deploy_challenge() {
|
||||
local DOMAIN="${1}" TOKEN_FILENAME="${2}" TOKEN_VALUE="${3}"
|
||||
|
||||
# This hook is called once for every domain that needs to be
|
||||
# validated, including any alternative names you may have listed.
|
||||
#
|
||||
# Parameters:
|
||||
# - DOMAIN
|
||||
# The domain name (CN or subject alternative name) being
|
||||
# validated.
|
||||
# - TOKEN_FILENAME
|
||||
# The name of the file containing the token to be served for HTTP
|
||||
# validation. Should be served by your web server as
|
||||
# /.well-known/acme-challenge/${TOKEN_FILENAME}.
|
||||
# - TOKEN_VALUE
|
||||
# The token value that needs to be served for validation. For DNS
|
||||
# validation, this is what you want to put in the _acme-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"
|
||||
}
|
||||
|
||||
clean_challenge() {
|
||||
local DOMAIN="${1}" TOKEN_FILENAME="${2}" TOKEN_VALUE="${3}"
|
||||
|
||||
# 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"
|
||||
}
|
||||
|
||||
deploy_cert() {
|
||||
local DOMAIN="${1}" KEYFILE="${2}" CERTFILE="${3}" FULLCHAINFILE="${4}" CHAINFILE="${5}" TIMESTAMP="${6}"
|
||||
|
||||
# This hook is called once for each certificate that has been
|
||||
# produced. Here you might, for instance, copy your new certificates
|
||||
# to service-specific locations and reload the service.
|
||||
#
|
||||
# Parameters:
|
||||
# - DOMAIN
|
||||
# The primary domain name, i.e. the certificate common
|
||||
# name (CN).
|
||||
# - KEYFILE
|
||||
# The path of the file containing the private key.
|
||||
# - CERTFILE
|
||||
# The path of the file containing the signed certificate.
|
||||
# - FULLCHAINFILE
|
||||
# The path of the file containing the full certificate chain.
|
||||
# - CHAINFILE
|
||||
# The path of the file containing the intermediate certificate(s).
|
||||
# - TIMESTAMP
|
||||
# Timestamp when the specified certificate was created.
|
||||
|
||||
cp -f "$FULLCHAINFILE" "/ssl/$SYS_CERTFILE"
|
||||
cp -f "$KEYFILE" "/ssl/$SYS_KEYFILE"
|
||||
}
|
||||
|
||||
|
||||
HANDLER="$1"; shift
|
||||
if [[ "${HANDLER}" =~ ^(deploy_challenge|clean_challenge|deploy_cert)$ ]]; then
|
||||
"$HANDLER" "$@"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user