From d4df2ce2d253de3ffba50a2b7d4a567f7fe3003d Mon Sep 17 00:00:00 2001 From: Frank Laszlo Date: Thu, 23 Aug 2018 16:14:58 -0400 Subject: [PATCH] fixes --- dnsapi/dns_fh.sh | 37 ++++++++++++++++++++++--------------- dnsapi/dns_thermo.sh | 17 ++++++++++++----- 2 files changed, 34 insertions(+), 20 deletions(-) diff --git a/dnsapi/dns_fh.sh b/dnsapi/dns_fh.sh index 97e09ad6..f950fed8 100644 --- a/dnsapi/dns_fh.sh +++ b/dnsapi/dns_fh.sh @@ -6,25 +6,25 @@ # # - FH_API_TOKEN (your Futurehosting API Token) # Note: If you do not have an API token, one can be generated at: -# https://my.futurehosting.net/api-token +# https://my.futurehosting.com/api-token # # Author: Frank Laszlo FH_API_URL="https://my.futurehosting.com/" FH_API_VERSION="0" -# dns_futurehosting_add() - Add TXT record -# Usage: dns_futurehosting_add _acme-challenge.subdomain.domain.com "XyZ123..." -dns_futurehosting_add() { +# dns_fh_add() - Add TXT record +# Usage: dns_fh_add _acme-challenge.subdomain.domain.com "XyZ123..." +dns_fh_add() { host="${1}" txtvalue="${2}" - if ! _check_futurehosting_api_token; then + if ! _check_fh_api_token; then return 1 fi _info "Using Futurehosting" - _debug "Calling: dns_futurehosting_add() '${host}' '${txtvalue}'" + _debug "Calling: dns_fh_add() '${host}' '${txtvalue}'" _debug "Detecting root zone" if ! _get_root "${host}"; then @@ -53,17 +53,21 @@ dns_futurehosting_add() { return 1 } -# dns_futurehosting_rm() - Remove TXT record -# Usage: dns_futurehosting_rm _acme-challenge.subdomain.domain.com -dns_futurehosting_rm() { +# dns_fh_rm() - Remove TXT record +# Usage: dns_fh_rm _acme-challenge.subdomain.domain.com "XyZ123..." +dns_fh_rm() { host="${1}" + txtvalue="${2}" - if ! _check_futurehosting_api_token; then + _debug host "${host}" + _debug txtvalue "${txtvalue}" + + if ! _check_fh_api_token; then return 1 fi _info "Using Futurehosting" - _debug "Calling: dns_futurehosting_rm() '${host}'" + _debug "Calling: dns_fh_rm() '${host}'" _debug "Detecting root zone" if ! _get_root "${host}"; then @@ -78,8 +82,11 @@ dns_futurehosting_rm() { if _rest GET "dns-record" "${_parameters}" && [ -n "${response}" ]; then response="$(echo "${response}" | tr -d "\n" | sed 's/^\[\(.*\)\]$/\1/' | sed -e 's/{"record_id":/|"record_id":/g' | sed 's/|/&{/g' | tr "|" "\n")" + _debug response "${response}" + + record="$(echo "${response}" | _egrep_o "{.*\"host\":\s*\"${_sub_domain}\",\s*\"target\":\s*\"${txtvalue}\".*}")" + _debug record "${record}" - record="$(echo "${response}" | _egrep_o "{.*\"host\":\s*\"${_sub_domain}\".*}")" if [ "${record}" ]; then _record_id=$(printf "%s\n" "${record}" | _egrep_o "\"record_id\":\s*[0-9]+" | _head_n 1 | cut -d : -f 2 | tr -d \ ) if [ "${_record_id}" ]; then @@ -100,14 +107,14 @@ dns_futurehosting_rm() { return 1 } -_check_futurehosting_api_token() { +_check_fh_api_token() { if [ -z "${FH_API_TOKEN}" ]; then - FH_API_TOKEN="" + FH_API_TOKEN="${FH_API_TOKEN:-$(_readaccountconf FH_API_TOKEN)}" _err "You have not defined your FH_API_TOKEN." _err "Please create your token and try again." _err "If you need to generate a new token, please visit:" - _err "https://portal.futurehosting.net/api-token" + _err "https://portal.fh.net/api-token" return 1 fi diff --git a/dnsapi/dns_thermo.sh b/dnsapi/dns_thermo.sh index 16c437a5..48d717f3 100644 --- a/dnsapi/dns_thermo.sh +++ b/dnsapi/dns_thermo.sh @@ -4,9 +4,9 @@ # # Environment variables: # -# - THERMO_API_TOKEN (your Thermo.io API Token) +# - THERMO_API_TOKEN (Your Thermo.io API Token) # Note: If you do not have an API token, one can be generated at: -# https://portal.thermo.net/api-token +# https://core.thermo.io//api-token # # Author: Frank Laszlo @@ -54,9 +54,13 @@ dns_thermo_add() { } # dns_thermo_rm() - Remove TXT record -# Usage: dns_thermo_rm _acme-challenge.subdomain.domain.com +# Usage: dns_thermo_rm _acme-challenge.subdomain.domain.com "XyZ123..." dns_thermo_rm() { host="${1}" + txtvalue="${2}" + + _debug host "${host}" + _debug txtvalue "${txtvalue}" if ! _check_thermo_api_token; then return 1 @@ -78,8 +82,11 @@ dns_thermo_rm() { if _rest GET "dns-record" "${_parameters}" && [ -n "${response}" ]; then response="$(echo "${response}" | tr -d "\n" | sed 's/^\[\(.*\)\]$/\1/' | sed -e 's/{"record_id":/|"record_id":/g' | sed 's/|/&{/g' | tr "|" "\n")" + _debug response "${response}" + + record="$(echo "${response}" | _egrep_o "{.*\"host\":\s*\"${_sub_domain}\",\s*\"target\":\s*\"${txtvalue}\".*}")" + _debug record "${record}" - record="$(echo "${response}" | _egrep_o "{.*\"host\":\s*\"${_sub_domain}\".*}")" if [ "${record}" ]; then _record_id=$(printf "%s\n" "${record}" | _egrep_o "\"record_id\":\s*[0-9]+" | _head_n 1 | cut -d : -f 2 | tr -d \ ) if [ "${_record_id}" ]; then @@ -102,7 +109,7 @@ dns_thermo_rm() { _check_thermo_api_token() { if [ -z "${THERMO_API_TOKEN}" ]; then - THERMO_API_TOKEN="" + THERMO_API_TOKEN="${THERMO_API_TOKEN:-$(_readaccountconf THERMO_API_TOKEN)}" _err "You have not defined your THERMO_API_TOKEN." _err "Please create your token and try again."