|
|
|
@ -84,7 +84,6 @@ dns_cpaneldns_rm() { |
|
|
|
record=$2 |
|
|
|
|
|
|
|
while _dns_cpaneldns_get_record "$zone" "$host" "$record"; do |
|
|
|
record_id="$(_dns_cpaneldns_get_record "$zone" "$host" "$record")" |
|
|
|
|
|
|
|
if [ ! -z "$record_id" ]; then |
|
|
|
_debug zone "$zone" |
|
|
|
@ -180,26 +179,6 @@ _dns_cpaneldns_get_zone_name() { |
|
|
|
return 1 |
|
|
|
} |
|
|
|
|
|
|
|
_dns_cpaneldns_http_api_call() { |
|
|
|
method=$1 |
|
|
|
|
|
|
|
_debug CPANELDNS_AUTH_ID "$CPANELDNS_AUTH_ID" |
|
|
|
_debug CPANELDNS_AUTH_PASSWORD "$CPANELDNS_AUTH_PASSWORD" |
|
|
|
|
|
|
|
if [ -z "$2" ]; then |
|
|
|
data="&$method" |
|
|
|
else |
|
|
|
data="&$method&$2" |
|
|
|
fi |
|
|
|
|
|
|
|
basicauth="$(printf %s "$CPANELDNS_AUTH_ID:$CPANELDNS_AUTH_PASSWORD" | _base64)" |
|
|
|
export _H1="Authorization: Basic $basicauth)" |
|
|
|
|
|
|
|
response="$(_get "$CPANELDNS_API/json-api/cpanel?cpanel_jsonapi_user=user&cpanel_jsonapi_apiversion=2$data")" |
|
|
|
_debug response "$response" |
|
|
|
return 0 |
|
|
|
} |
|
|
|
|
|
|
|
_dns_cpaneldns_get_record() { |
|
|
|
|
|
|
|
zone=$1 |
|
|
|
@ -213,16 +192,37 @@ _dns_cpaneldns_get_record() { |
|
|
|
_dns_cpaneldns_http_api_call "cpanel_jsonapi_module=ZoneEdit" "cpanel_jsonapi_func=fetchzone_records&domain=$zone&$name=$host&type=TXT&txtdata=$record" |
|
|
|
if ! _contains "$response" "\"line\":"; then |
|
|
|
_info "No records left matching TXT host." |
|
|
|
record_id="" |
|
|
|
return 1 |
|
|
|
fi |
|
|
|
|
|
|
|
if $response; then |
|
|
|
else |
|
|
|
recordlist="$(echo "$response" | tr '{' "\n" | grep "$record" | _head_n 1)" |
|
|
|
record_id="$(echo "$recordlist" | tr ',' "\n" | grep -E '^"line"' | sed -re 's/^\"line\"\:\"([0-9]+)\"$/\1/g' | cut -d ":" -f 2)" |
|
|
|
echo "$record_id" |
|
|
|
|
|
|
|
_info "Removing record ID: $record_id" |
|
|
|
|
|
|
|
_debug record_id "$record_id" |
|
|
|
|
|
|
|
return 0 |
|
|
|
fi |
|
|
|
} |
|
|
|
|
|
|
|
_dns_cpaneldns_http_api_call() { |
|
|
|
|
|
|
|
method=$1 |
|
|
|
|
|
|
|
_debug CPANELDNS_AUTH_ID "$CPANELDNS_AUTH_ID" |
|
|
|
_debug CPANELDNS_AUTH_PASSWORD "$CPANELDNS_AUTH_PASSWORD" |
|
|
|
|
|
|
|
if [ -z "$2" ]; then |
|
|
|
data="&$method" |
|
|
|
else |
|
|
|
data="&$method&$2" |
|
|
|
fi |
|
|
|
|
|
|
|
basicauth="$(printf %s "$CPANELDNS_AUTH_ID:$CPANELDNS_AUTH_PASSWORD" | _base64)" |
|
|
|
export _H1="Authorization: Basic $basicauth)" |
|
|
|
|
|
|
|
response="$(_get "$CPANELDNS_API/json-api/cpanel?cpanel_jsonapi_user=user&cpanel_jsonapi_apiversion=2$data")" |
|
|
|
_debug response "$response" |
|
|
|
return 0 |
|
|
|
} |