Initial commit
This commit is contained in:
commit
f8e921c0d2
91
dns_acmedns.sh
Executable file
91
dns_acmedns.sh
Executable file
@ -0,0 +1,91 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
#
|
||||||
|
#Author: Wolfgang Ebner
|
||||||
|
#Report Bugs here: https://github.com/webner/acme.sh
|
||||||
|
#
|
||||||
|
######## Public functions #####################
|
||||||
|
|
||||||
|
#Usage: dns_acmedns_add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
|
||||||
|
dns_acmedns_add() {
|
||||||
|
fulldomain=$1
|
||||||
|
txtvalue=$2
|
||||||
|
_info "Using acme-dns"
|
||||||
|
_debug fulldomain "$fulldomain"
|
||||||
|
_debug txtvalue "$txtvalue"
|
||||||
|
|
||||||
|
ACMEDNS_URL="${ACMEDNS_URL:-$(_readaccountconf_mutable ACMEDNS_URL)}"
|
||||||
|
|
||||||
|
if [ "$ACMEDNS_URL" = "" ]; then
|
||||||
|
ACMEDNS_URL="https://auth.acme-dns.io"
|
||||||
|
fi
|
||||||
|
|
||||||
|
_saveaccountconf_mutable ACMEDNS_URL "$ACMEDNS_URL"
|
||||||
|
|
||||||
|
confdomain=`echo "$fulldomain" | sed 's/[-.]/_/g'`
|
||||||
|
_debug confdomain "$confdomain"
|
||||||
|
data="$(_readaccountconf_mutable ACMEDNS_DATA_$confdomain)"
|
||||||
|
_debug data "$data"
|
||||||
|
if [ "$data" = "" ]; then
|
||||||
|
# Register a new domain
|
||||||
|
response="$(_post "" "${ACMEDNS_URL}/register" "" "POST")"
|
||||||
|
ad_username=`echo "$response" | sed 's/.*"username":"\([^"]*\)".*/\1/'`
|
||||||
|
ad_password=`echo "$response" | sed 's/.*"password":"\([^"]*\)".*/\1/'`
|
||||||
|
ad_subdomain=`echo "$response" | sed 's/.*"subdomain":"\([^"]*\)".*/\1/'`
|
||||||
|
ad_fulldomain=`echo "$response" | sed 's/.*"fulldomain":"\([^"]*\)".*/\1/'`
|
||||||
|
|
||||||
|
_err "Please add the following DNS record to $fulldomain: CNAME $ad_fulldomain"
|
||||||
|
_err "Press ENTER to continue."
|
||||||
|
read _
|
||||||
|
|
||||||
|
# Save the domain data
|
||||||
|
_saveaccountconf_mutable "ACMEDNS_DATA_$confdomain" "$ad_username $ad_password $ad_subdomain"
|
||||||
|
else
|
||||||
|
set -- $data
|
||||||
|
ad_username=$1
|
||||||
|
ad_password=$2
|
||||||
|
ad_subdomain=$3
|
||||||
|
fi
|
||||||
|
|
||||||
|
_debug ad_username "$ad_username"
|
||||||
|
_debug ad_password "$ad_password"
|
||||||
|
_debug ad_subdomain "$ad_subdomain"
|
||||||
|
|
||||||
|
if [ "$ad_username" = "" ]; then
|
||||||
|
_err "Error getting username for acme_dns"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
if [ "$ad_password" = "" ]; then
|
||||||
|
_err "Error getting password for acme_dns"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
if [ "$ad_subdomain" = "" ]; then
|
||||||
|
_err "Error getting subdomain for ame_dns"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
export _H1="X-Api-User: $ad_username"
|
||||||
|
export _H2="X-Api-Key: $ad_password"
|
||||||
|
data="{\"subdomain\":\"$ad_subdomain\", \"txt\": \"$txtvalue\"}"
|
||||||
|
|
||||||
|
_debug data "$data"
|
||||||
|
response="$(_post "$data" "${ACMEDNS_URL}/update" "" "POST")"
|
||||||
|
_debug response "$response"
|
||||||
|
|
||||||
|
if ! echo "$response" | grep "\"$txtvalue\"" >/dev/null; then
|
||||||
|
_err "invalid response of acme-dns"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#Usage: fulldomain txtvalue
|
||||||
|
#Remove the txt record after validation.
|
||||||
|
dns_acmedns_rm() {
|
||||||
|
fulldomain=$1
|
||||||
|
txtvalue=$2
|
||||||
|
_info "Using acme-dns"
|
||||||
|
_debug fulldomain "$fulldomain"
|
||||||
|
_debug txtvalue "$txtvalue"
|
||||||
|
}
|
||||||
|
|
||||||
|
#################### Private functions below ##################################
|
Loading…
Reference in New Issue
Block a user