|
|
@ -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 |
|
|
|
|
|
# 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}" |
|
|
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 |
|
|
|
|
|
# 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}" |
|
|
host="${1}" |
|
|
|
|
|
txtvalue="${2}" |
|
|
|
|
|
|
|
|
|
|
|
_debug host "${host}" |
|
|
|
|
|
_debug txtvalue "${txtvalue}" |
|
|
|
|
|
|
|
|
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_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 |
|
|
|