Refactoring amcedns api (second try) (#3231)
This commit is contained in:
parent
7e7291ace9
commit
2ce145f359
63
dnsapi/dns_acmedns.sh
Normal file → Executable file
63
dnsapi/dns_acmedns.sh
Normal file → Executable file
@ -1,31 +1,70 @@
|
||||
#!/usr/bin/env sh
|
||||
#
|
||||
#Author: Wolfgang Ebner
|
||||
#Report Bugs here: https://github.com/webner/acme.sh
|
||||
#Author: Sven Neubuaer
|
||||
#Report Bugs here: https://github.com/dampfklon/acme.sh
|
||||
#
|
||||
# Usage:
|
||||
# export ACMEDNS_BASE_URL="https://auth.acme-dns.io"
|
||||
#
|
||||
# You can optionally define an already existing account:
|
||||
#
|
||||
# export ACMEDNS_USERNAME="<username>"
|
||||
# export ACMEDNS_PASSWORD="<password>"
|
||||
# export ACMEDNS_SUBDOMAIN="<subdomain>"
|
||||
#
|
||||
######## Public functions #####################
|
||||
|
||||
#Usage: dns_acmedns_add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
|
||||
# Used to add txt record
|
||||
dns_acmedns_add() {
|
||||
fulldomain=$1
|
||||
txtvalue=$2
|
||||
_info "Using acme-dns"
|
||||
_debug fulldomain "$fulldomain"
|
||||
_debug txtvalue "$txtvalue"
|
||||
_debug "fulldomain $fulldomain"
|
||||
_debug "txtvalue $txtvalue"
|
||||
|
||||
ACMEDNS_UPDATE_URL="${ACMEDNS_UPDATE_URL:-$(_readaccountconf_mutable ACMEDNS_UPDATE_URL)}"
|
||||
#for compatiblity from account conf
|
||||
ACMEDNS_USERNAME="${ACMEDNS_USERNAME:-$(_readaccountconf_mutable ACMEDNS_USERNAME)}"
|
||||
_clearaccountconf_mutable ACMEDNS_USERNAME
|
||||
ACMEDNS_PASSWORD="${ACMEDNS_PASSWORD:-$(_readaccountconf_mutable ACMEDNS_PASSWORD)}"
|
||||
_clearaccountconf_mutable ACMEDNS_PASSWORD
|
||||
ACMEDNS_SUBDOMAIN="${ACMEDNS_SUBDOMAIN:-$(_readaccountconf_mutable ACMEDNS_SUBDOMAIN)}"
|
||||
_clearaccountconf_mutable ACMEDNS_SUBDOMAIN
|
||||
|
||||
if [ "$ACMEDNS_UPDATE_URL" = "" ]; then
|
||||
ACMEDNS_UPDATE_URL="https://auth.acme-dns.io/update"
|
||||
ACMEDNS_BASE_URL="${ACMEDNS_BASE_URL:-$(_readdomainconf ACMEDNS_BASE_URL)}"
|
||||
ACMEDNS_USERNAME="${ACMEDNS_USERNAME:-$(_readdomainconf ACMEDNS_USERNAME)}"
|
||||
ACMEDNS_PASSWORD="${ACMEDNS_PASSWORD:-$(_readdomainconf ACMEDNS_PASSWORD)}"
|
||||
ACMEDNS_SUBDOMAIN="${ACMEDNS_SUBDOMAIN:-$(_readdomainconf ACMEDNS_SUBDOMAIN)}"
|
||||
|
||||
if [ "$ACMEDNS_BASE_URL" = "" ]; then
|
||||
ACMEDNS_BASE_URL="https://auth.acme-dns.io"
|
||||
fi
|
||||
|
||||
_saveaccountconf_mutable ACMEDNS_UPDATE_URL "$ACMEDNS_UPDATE_URL"
|
||||
_saveaccountconf_mutable ACMEDNS_USERNAME "$ACMEDNS_USERNAME"
|
||||
_saveaccountconf_mutable ACMEDNS_PASSWORD "$ACMEDNS_PASSWORD"
|
||||
_saveaccountconf_mutable ACMEDNS_SUBDOMAIN "$ACMEDNS_SUBDOMAIN"
|
||||
ACMEDNS_UPDATE_URL="$ACMEDNS_BASE_URL/update"
|
||||
ACMEDNS_REGISTER_URL="$ACMEDNS_BASE_URL/register"
|
||||
|
||||
if [ -z "$ACMEDNS_USERNAME" ] || [ -z "$ACMEDNS_PASSWORD" ]; then
|
||||
response="$(_post "" "$ACMEDNS_REGISTER_URL" "" "POST")"
|
||||
_debug response "$response"
|
||||
ACMEDNS_USERNAME=$(echo "$response" | sed -n 's/^{.*\"username\":[ ]*\"\([^\"]*\)\".*}/\1/p')
|
||||
_debug "received username: $ACMEDNS_USERNAME"
|
||||
ACMEDNS_PASSWORD=$(echo "$response" | sed -n 's/^{.*\"password\":[ ]*\"\([^\"]*\)\".*}/\1/p')
|
||||
_debug "received password: $ACMEDNS_PASSWORD"
|
||||
ACMEDNS_SUBDOMAIN=$(echo "$response" | sed -n 's/^{.*\"subdomain\":[ ]*\"\([^\"]*\)\".*}/\1/p')
|
||||
_debug "received subdomain: $ACMEDNS_SUBDOMAIN"
|
||||
ACMEDNS_FULLDOMAIN=$(echo "$response" | sed -n 's/^{.*\"fulldomain\":[ ]*\"\([^\"]*\)\".*}/\1/p')
|
||||
_info "##########################################################"
|
||||
_info "# Create $fulldomain CNAME $ACMEDNS_FULLDOMAIN DNS entry #"
|
||||
_info "##########################################################"
|
||||
_info "Press enter to continue... "
|
||||
read -r _
|
||||
fi
|
||||
|
||||
_savedomainconf ACMEDNS_BASE_URL "$ACMEDNS_BASE_URL"
|
||||
_savedomainconf ACMEDNS_USERNAME "$ACMEDNS_USERNAME"
|
||||
_savedomainconf ACMEDNS_PASSWORD "$ACMEDNS_PASSWORD"
|
||||
_savedomainconf ACMEDNS_SUBDOMAIN "$ACMEDNS_SUBDOMAIN"
|
||||
|
||||
export _H1="X-Api-User: $ACMEDNS_USERNAME"
|
||||
export _H2="X-Api-Key: $ACMEDNS_PASSWORD"
|
||||
@ -48,8 +87,8 @@ dns_acmedns_rm() {
|
||||
fulldomain=$1
|
||||
txtvalue=$2
|
||||
_info "Using acme-dns"
|
||||
_debug fulldomain "$fulldomain"
|
||||
_debug txtvalue "$txtvalue"
|
||||
_debug "fulldomain $fulldomain"
|
||||
_debug "txtvalue $txtvalue"
|
||||
}
|
||||
|
||||
#################### Private functions below ##################################
|
||||
|
Loading…
Reference in New Issue
Block a user