This commit is contained in:
Frank Laszlo 2018-08-23 16:14:58 -04:00
parent 873ed15399
commit d4df2ce2d2
2 changed files with 34 additions and 20 deletions

View File

@ -6,25 +6,25 @@
# #
# - FH_API_TOKEN (your Futurehosting API Token) # - FH_API_TOKEN (your Futurehosting API Token)
# Note: If you do not have an API token, one can be generated at: # 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 <flaszlo@nexcess.net> # Author: Frank Laszlo <flaszlo@nexcess.net>
FH_API_URL="https://my.futurehosting.com/" FH_API_URL="https://my.futurehosting.com/"
FH_API_VERSION="0" FH_API_VERSION="0"
# dns_futurehosting_add() - Add TXT record # dns_fh_add() - Add TXT record
# Usage: dns_futurehosting_add _acme-challenge.subdomain.domain.com "XyZ123..." # Usage: dns_fh_add _acme-challenge.subdomain.domain.com "XyZ123..."
dns_futurehosting_add() { dns_fh_add() {
host="${1}" host="${1}"
txtvalue="${2}" txtvalue="${2}"
if ! _check_futurehosting_api_token; then if ! _check_fh_api_token; then
return 1 return 1
fi fi
_info "Using Futurehosting" _info "Using Futurehosting"
_debug "Calling: dns_futurehosting_add() '${host}' '${txtvalue}'" _debug "Calling: dns_fh_add() '${host}' '${txtvalue}'"
_debug "Detecting root zone" _debug "Detecting root zone"
if ! _get_root "${host}"; then if ! _get_root "${host}"; then
@ -53,17 +53,21 @@ dns_futurehosting_add() {
return 1 return 1
} }
# dns_futurehosting_rm() - Remove TXT record # dns_fh_rm() - Remove TXT record
# Usage: dns_futurehosting_rm _acme-challenge.subdomain.domain.com # Usage: dns_fh_rm _acme-challenge.subdomain.domain.com "XyZ123..."
dns_futurehosting_rm() { dns_fh_rm() {
host="${1}" host="${1}"
txtvalue="${2}"
if ! _check_futurehosting_api_token; then _debug host "${host}"
_debug txtvalue "${txtvalue}"
if ! _check_fh_api_token; then
return 1 return 1
fi fi
_info "Using Futurehosting" _info "Using Futurehosting"
_debug "Calling: dns_futurehosting_rm() '${host}'" _debug "Calling: dns_fh_rm() '${host}'"
_debug "Detecting root zone" _debug "Detecting root zone"
if ! _get_root "${host}"; then if ! _get_root "${host}"; then
@ -78,8 +82,11 @@ dns_futurehosting_rm() {
if _rest GET "dns-record" "${_parameters}" && [ -n "${response}" ]; then 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")" 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 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 \ ) _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 if [ "${_record_id}" ]; then
@ -100,14 +107,14 @@ dns_futurehosting_rm() {
return 1 return 1
} }
_check_futurehosting_api_token() { _check_fh_api_token() {
if [ -z "${FH_API_TOKEN}" ]; then 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 "You have not defined your FH_API_TOKEN."
_err "Please create your token and try again." _err "Please create your token and try again."
_err "If you need to generate a new token, please visit:" _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 return 1
fi fi

View File

@ -4,9 +4,9 @@
# #
# Environment variables: # 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: # 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 <flaszlo@nexcess.net> # Author: Frank Laszlo <flaszlo@nexcess.net>
@ -54,9 +54,13 @@ dns_thermo_add() {
} }
# dns_thermo_rm() - Remove TXT record # 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() { dns_thermo_rm() {
host="${1}" host="${1}"
txtvalue="${2}"
_debug host "${host}"
_debug txtvalue "${txtvalue}"
if ! _check_thermo_api_token; then if ! _check_thermo_api_token; then
return 1 return 1
@ -78,8 +82,11 @@ dns_thermo_rm() {
if _rest GET "dns-record" "${_parameters}" && [ -n "${response}" ]; then 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")" 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 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 \ ) _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 if [ "${_record_id}" ]; then
@ -102,7 +109,7 @@ dns_thermo_rm() {
_check_thermo_api_token() { _check_thermo_api_token() {
if [ -z "${THERMO_API_TOKEN}" ]; then 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 "You have not defined your THERMO_API_TOKEN."
_err "Please create your token and try again." _err "Please create your token and try again."