From 926059f6f6fd001a8d0ab4eef552842a1e80eaff Mon Sep 17 00:00:00 2001 From: ddarek2000 <40216289+ddarek2000@users.noreply.github.com> Date: Mon, 31 Aug 2020 12:32:20 -0400 Subject: [PATCH 1/8] Add files via upload DNS Script for Hover dns provider --- dnsapi/dns_hover.sh | 275 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 275 insertions(+) create mode 100644 dnsapi/dns_hover.sh diff --git a/dnsapi/dns_hover.sh b/dnsapi/dns_hover.sh new file mode 100644 index 00000000..5501f0e1 --- /dev/null +++ b/dnsapi/dns_hover.sh @@ -0,0 +1,275 @@ +#!/usr/bin/env sh + +#Here is a sample custom api script. +#This file name is "dns_hover.sh" +# +#So, here must be a method dns_hover_add() +#So, here must be a method dns_hover_rm() +# +#Which will be called by acme.sh to add the txt record to your api system. +#returns 0 means success, otherwise error. +# +#Author: Neilpang +#Report Bugs here: https://github.com/Neilpang/acme.sh +# +######## Public functions ##################### + +HOVER_Api="https://www.hover.com/api" + +#Usage: dns_hover_add _acme-challenge.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs" +dns_hover_add() { + fulldomain=$1 + txtvalue=$2 + + _info "Using HOVER" + _debug fulldomain "$fulldomain" + _debug txtvalue "$txtvalue" + + ########### Login first ########### + if ! _HOVER_login; then + _err "Cannot Login" + return 1 + fi + + ########### Now detect current config ########### + _debug "First detect the root zone" + if ! _get_root "$fulldomain"; then + _err "invalid domain" + return 1 + fi + + _debug _domain_id "$_domain_id" + _debug _sub_domain "$_sub_domain" + _debug _domain "$_domain" + + _debug "Getting txt records" + _cf_rest GET "domains/$_domain_id/dns" + + if ! printf "%s" "$response" | grep \"succeeded\":true >/dev/null; then + _err "Error" + return 1 + fi + + ########### ADD or UPDATE ########### + count=$(printf "%s\n" "$response" | _egrep_o ",\"name\":\"$_sub_domain\",\"type\":\"TXT\"[^,]*" | cut -d : -f 2| wc -l ) + _debug count "$count" + if [ "$count" -eq "0" ]; then + _info "Adding record" + + if _cf_rest POST "domains/$_domain_id/dns" "{\"name\":\"$_sub_domain\",\"type\":\"TXT\",\"content\":\"$txtvalue\",\"ttl\":5,\"is_default\":false,\"can_revert\":false}"; then + + if ! _contains "$response" "\"succeeded\":true"; then + _err "Add txt record error." + return 1 + else + _info "Added, OK" + return 0 + fi + fi + _err "Add txt record error." + fi + +# else +# _info "Updating record" +# record_id=$(printf "%s\n" "$response" | _egrep_o "\"id\":\"[^\"]*\",\"name\":\"$_sub_domain\",\"type\":\"TXT\"" | tr -d \" | tr "," ":" | cut -d : -f 2 | head -n 1) +# _debug "record_id" "$record_id" +# +# _cf_rest PUT "domains/$_domain_id/dns/$record_id" "{\"id\":\"$record_id\",\"type\":\"TXT\",\"name\":\"$_sub_domain\",\"content\":\"$txtvalue\",\"zone_id\":\"$_domain_id\",\"zone_name\":\"$_domain\"}" +# if [ "$?" = "0" ]; then +# _info "Updated, OK" +# return 0 +# fi +# _err "Update error" +# return 1 + + # verify response + if ! _contains "$response" "\"succeeded\":true"; then + _err "Error" + return 1 + fi + +} + +########### DELETE ########### +#Usage: fulldomain txtvalue +#Remove the txt record after validation. +dns_hover_rm() { + fulldomain=$1 + txtvalue=$2 + + _info "Using hover" + _debug fulldomain "$fulldomain" + _debug txtvalue "$txtvalue" + + ########### Login first ########### + if ! _HOVER_login; then + _err "Cannot Login" + return 1 + fi + + ########### Now detect current config ########### + _debug "First detect the root zone" + if ! _get_root "$fulldomain"; then + _err "invalid domain" + return 1 + fi + _debug _domain_id "$_domain_id" + _debug _sub_domain "$_sub_domain" + _debug _domain "$_domain" + + _debug "Getting txt records" + _cf_rest GET "domains/$_domain_id/dns" + + # verify response + if ! _contains "$response" "\"succeeded\":true"; then + _err "Error" + return 1 + fi + + ########### DELETE ########### + count=$(printf "%s\n" "$response" | _egrep_o ",\"name\":\"$_sub_domain\",\"type\":\"TXT\",\"content\":\"$txtvalue\"" | cut -d : -f 2| wc -l ) + _debug count "$count" + + if [ "$count" -eq "0" ]; then + _info "Don't need to remove." + else + # Get the record id to delete + record_id=$(printf "%s\n" "$response" | _egrep_o "\"id\":\"[^\"]*\",\"name\":\"$_sub_domain\",\"type\":\"TXT\",\"content\":\"$txtvalue\"" | tr -d \" | tr "," ":" | cut -d : -f 2 | head -n 1) + _debug "record_id" "$record_id" + if [ -z "$record_id" ]; then + _err "Can not get record id to remove." + return 1 + fi + # Delete the record + if ! _cf_rest DELETE "domains/$_domain_id/dns/$record_id"; then + _err "Delete record error in call." + return 1 + fi + # verify response + if ! _contains "$response" "\"succeeded\":true"; then + _err "Delete record error in response." + return 1 + fi + + fi + +} + +################################################################################ +#################### Private functions below ################################## +################################################################################ + +# usage: _HOVER_login +# returns 0 success +_HOVER_login() { + +#save the credentials to the account conf file required for testing +# _saveaccountconf_mutable HOVER_Username "$HOVER_Username" +# _saveaccountconf_mutable HOVER_Password "$HOVER_Password" + + if [ -z "$HOVER_COOKIE" ]; then + + HOVER_Username="${HOVER_Username:-$(_readaccountconf_mutable HOVER_Username)}" + HOVER_Password="${HOVER_Password:-$(_readaccountconf_mutable HOVER_Password)}" + + if [ -z "$HOVER_Username" ] || [ -z "$HOVER_Password" ]; then + + _err "You did not specify the HOVER username and password yet." + _err "Please export as HOVER_Username / HOVER_Password and try again." + HOVER_Username="" + HOVER_Password="" + return 1 + else + + _debug "Login to HOVER as user $HOVER_Username" + _cf_rest POST "login" "username=$(printf '%s' "$HOVER_Username")&password=$(printf '%s' "$HOVER_Password")" + if [ "$?" != "0" ]; then + _err "HOVER login failed for user $username bad RC from _post" + return 1 + fi + + export HOVER_COOKIE="$(grep -i '^.*Cookie:.*hoverauth=.*$' "$HTTP_HEADER" | _head_n 1 | tr -d "\r\n" | cut -d ":" -f 2)" + + if [ -z "$HOVER_COOKIE" ]; then + _debug3 response "$response" + _err "HOVER login failed for user $username. Check $HTTP_HEADER file" + return 1 + else + _debug "HOVER login cookies: $HOVER_COOKIE (cached = $using_cached_cookies)" + return 0 + fi + fi + else + # use Cookie + return 0 + fi + +return 1 + +} + + +#_acme-challenge.www.domain.com +#returns +# _sub_domain=_acme-challenge.www +# _domain=domain.com +# _domain_id=sdjkglgdfewsdfg +_get_root() { + domain=$1 + i=2 + p=1 + while true; do + h=$(printf "%s" "$domain" | cut -d . -f $i-100) + _debug h "$h" + if [ -z "$h" ]; then + #not valid + return 1 + fi + + if ! _cf_rest GET "domains"; then + return 1 + fi + + if _contains "$response" "\"domain_name\":\"$h\"" >/dev/null; then + _domain_id=$(printf "%s\n" "$response" | _egrep_o '\[.\"id\":\"[^\"]*\"' | head -n 1 | cut -d : -f 2 | tr -d \") + if [ -n "$_domain_id" ]; then + _sub_domain=$(printf "%s" "$domain" | cut -d . -f 1-$p) + _domain=$h + return 0 + fi + return 1 + fi + p=$i + i=$(_math "$i" + 1) + + done + return 1 +} + +_cf_rest() { + m=$1 + ep="$2" + data="$3" + _debug "$ep" + + if [ "$ep" != "login" ]; then + _H1="Cookie:$HOVER_COOKIE" + _H3="Content-Type: application/json" + fi + + _H2="Accept-Language:en-US" + + if [ "$m" != "GET" ]; then + _debug data "$data" + response="$(_post "$data" "$HOVER_Api/$ep" "" "$m")" + else + response="$(_get "$HOVER_Api/$ep")" + fi + + if [ "$?" != "0" ]; then + _err "error $ep" + return 1 + fi + _debug2 response "$response" + return 0 +} From 51ddd2a5f6b02b2fbe958daeaff9896213ee8c5d Mon Sep 17 00:00:00 2001 From: ddarek2000 <40216289+ddarek2000@users.noreply.github.com> Date: Mon, 31 Aug 2020 13:08:02 -0400 Subject: [PATCH 2/8] Update dns_hover.sh fixes to problems identified by code check. --- dnsapi/dns_hover.sh | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/dnsapi/dns_hover.sh b/dnsapi/dns_hover.sh index 5501f0e1..81a791b8 100644 --- a/dnsapi/dns_hover.sh +++ b/dnsapi/dns_hover.sh @@ -184,7 +184,7 @@ _HOVER_login() { _debug "Login to HOVER as user $HOVER_Username" _cf_rest POST "login" "username=$(printf '%s' "$HOVER_Username")&password=$(printf '%s' "$HOVER_Password")" if [ "$?" != "0" ]; then - _err "HOVER login failed for user $username bad RC from _post" + _err "HOVER login failed for user $HOVER_Username bad RC from _post" return 1 fi @@ -192,10 +192,11 @@ _HOVER_login() { if [ -z "$HOVER_COOKIE" ]; then _debug3 response "$response" - _err "HOVER login failed for user $username. Check $HTTP_HEADER file" + _err "HOVER login failed for user $HOVER_Username. Check $HTTP_HEADER file" + using_cached_cookies="true" return 1 else - _debug "HOVER login cookies: $HOVER_COOKIE (cached = $using_cached_cookies)" + using_cached_cookies="true" return 0 fi fi @@ -203,7 +204,8 @@ _HOVER_login() { # use Cookie return 0 fi - + +_debug "HOVER login cookies: $HOVER_COOKIE (cached = $using_cached_cookies)" return 1 } @@ -253,11 +255,11 @@ _cf_rest() { _debug "$ep" if [ "$ep" != "login" ]; then - _H1="Cookie:$HOVER_COOKIE" - _H3="Content-Type: application/json" + export _H1="Cookie:$HOVER_COOKIE" + export _H3="Content-Type: application/json" fi - _H2="Accept-Language:en-US" + export _H2="Accept-Language:en-US" if [ "$m" != "GET" ]; then _debug data "$data" From f28540731e3408bfe0b403463ed4f226dcffee75 Mon Sep 17 00:00:00 2001 From: ddarek2000 <40216289+ddarek2000@users.noreply.github.com> Date: Mon, 31 Aug 2020 13:14:26 -0400 Subject: [PATCH 3/8] Update dns_hover.sh fixing SC2155 --- dnsapi/dns_hover.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dnsapi/dns_hover.sh b/dnsapi/dns_hover.sh index 81a791b8..2040cc96 100644 --- a/dnsapi/dns_hover.sh +++ b/dnsapi/dns_hover.sh @@ -188,7 +188,8 @@ _HOVER_login() { return 1 fi - export HOVER_COOKIE="$(grep -i '^.*Cookie:.*hoverauth=.*$' "$HTTP_HEADER" | _head_n 1 | tr -d "\r\n" | cut -d ":" -f 2)" + HOVER_COOKIE="$(grep -i '^.*Cookie:.*hoverauth=.*$' "$HTTP_HEADER" | _head_n 1 | tr -d "\r\n" | cut -d ":" -f 2)" + export HOVER_COOKIE if [ -z "$HOVER_COOKIE" ]; then _debug3 response "$response" From 3f95564c068d551b4aa1839519e570eeeea4e222 Mon Sep 17 00:00:00 2001 From: ddarek2000 <40216289+ddarek2000@users.noreply.github.com> Date: Mon, 31 Aug 2020 14:15:23 -0400 Subject: [PATCH 4/8] Update dns_hover.sh Fixing format --- dnsapi/dns_hover.sh | 51 +++++++++++++++++---------------------------- 1 file changed, 19 insertions(+), 32 deletions(-) diff --git a/dnsapi/dns_hover.sh b/dnsapi/dns_hover.sh index 2040cc96..d1213c9d 100644 --- a/dnsapi/dns_hover.sh +++ b/dnsapi/dns_hover.sh @@ -18,19 +18,19 @@ HOVER_Api="https://www.hover.com/api" #Usage: dns_hover_add _acme-challenge.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs" dns_hover_add() { - fulldomain=$1 - txtvalue=$2 - + fulldomain="$1" + txtvalue="$2" + _info "Using HOVER" _debug fulldomain "$fulldomain" _debug txtvalue "$txtvalue" ########### Login first ########### - if ! _HOVER_login; then + if ! _HOVER_login; then _err "Cannot Login" return 1 fi - + ########### Now detect current config ########### _debug "First detect the root zone" if ! _get_root "$fulldomain"; then @@ -41,7 +41,7 @@ dns_hover_add() { _debug _domain_id "$_domain_id" _debug _sub_domain "$_sub_domain" _debug _domain "$_domain" - + _debug "Getting txt records" _cf_rest GET "domains/$_domain_id/dns" @@ -49,9 +49,9 @@ dns_hover_add() { _err "Error" return 1 fi - + ########### ADD or UPDATE ########### - count=$(printf "%s\n" "$response" | _egrep_o ",\"name\":\"$_sub_domain\",\"type\":\"TXT\"[^,]*" | cut -d : -f 2| wc -l ) + count=$(printf "%s\n" "$response" | _egrep_o ",\"name\":\"$_sub_domain\",\"type\":\"TXT\"[^,]*" | cut -d : -f 2 | wc -l) _debug count "$count" if [ "$count" -eq "0" ]; then _info "Adding record" @@ -69,19 +69,6 @@ dns_hover_add() { _err "Add txt record error." fi -# else -# _info "Updating record" -# record_id=$(printf "%s\n" "$response" | _egrep_o "\"id\":\"[^\"]*\",\"name\":\"$_sub_domain\",\"type\":\"TXT\"" | tr -d \" | tr "," ":" | cut -d : -f 2 | head -n 1) -# _debug "record_id" "$record_id" -# -# _cf_rest PUT "domains/$_domain_id/dns/$record_id" "{\"id\":\"$record_id\",\"type\":\"TXT\",\"name\":\"$_sub_domain\",\"content\":\"$txtvalue\",\"zone_id\":\"$_domain_id\",\"zone_name\":\"$_domain\"}" -# if [ "$?" = "0" ]; then -# _info "Updated, OK" -# return 0 -# fi -# _err "Update error" -# return 1 - # verify response if ! _contains "$response" "\"succeeded\":true"; then _err "Error" @@ -94,19 +81,19 @@ dns_hover_add() { #Usage: fulldomain txtvalue #Remove the txt record after validation. dns_hover_rm() { - fulldomain=$1 - txtvalue=$2 - + fulldomain="$1" + txtvalue="$2" + _info "Using hover" _debug fulldomain "$fulldomain" _debug txtvalue "$txtvalue" - + ########### Login first ########### if ! _HOVER_login; then _err "Cannot Login" return 1 fi - + ########### Now detect current config ########### _debug "First detect the root zone" if ! _get_root "$fulldomain"; then @@ -116,7 +103,7 @@ dns_hover_rm() { _debug _domain_id "$_domain_id" _debug _sub_domain "$_sub_domain" _debug _domain "$_domain" - + _debug "Getting txt records" _cf_rest GET "domains/$_domain_id/dns" @@ -126,10 +113,10 @@ dns_hover_rm() { return 1 fi - ########### DELETE ########### + ########### DELETE ########### count=$(printf "%s\n" "$response" | _egrep_o ",\"name\":\"$_sub_domain\",\"type\":\"TXT\",\"content\":\"$txtvalue\"" | cut -d : -f 2| wc -l ) _debug count "$count" - + if [ "$count" -eq "0" ]; then _info "Don't need to remove." else @@ -159,7 +146,7 @@ dns_hover_rm() { #################### Private functions below ################################## ################################################################################ -# usage: _HOVER_login +# usage: _HOVER_login # returns 0 success _HOVER_login() { @@ -168,7 +155,7 @@ _HOVER_login() { # _saveaccountconf_mutable HOVER_Password "$HOVER_Password" if [ -z "$HOVER_COOKIE" ]; then - + HOVER_Username="${HOVER_Username:-$(_readaccountconf_mutable HOVER_Username)}" HOVER_Password="${HOVER_Password:-$(_readaccountconf_mutable HOVER_Password)}" @@ -258,7 +245,7 @@ _cf_rest() { if [ "$ep" != "login" ]; then export _H1="Cookie:$HOVER_COOKIE" export _H3="Content-Type: application/json" - fi + fi export _H2="Accept-Language:en-US" From 621325dc83ef8a96c996d0428073119f18492782 Mon Sep 17 00:00:00 2001 From: ddarek2000 <40216289+ddarek2000@users.noreply.github.com> Date: Mon, 31 Aug 2020 14:23:05 -0400 Subject: [PATCH 5/8] Update dns_hover.sh More formating --- dnsapi/dns_hover.sh | 91 ++++++++++++++++++++++----------------------- 1 file changed, 45 insertions(+), 46 deletions(-) diff --git a/dnsapi/dns_hover.sh b/dnsapi/dns_hover.sh index d1213c9d..3c282e86 100644 --- a/dnsapi/dns_hover.sh +++ b/dnsapi/dns_hover.sh @@ -57,7 +57,7 @@ dns_hover_add() { _info "Adding record" if _cf_rest POST "domains/$_domain_id/dns" "{\"name\":\"$_sub_domain\",\"type\":\"TXT\",\"content\":\"$txtvalue\",\"ttl\":5,\"is_default\":false,\"can_revert\":false}"; then - + if ! _contains "$response" "\"succeeded\":true"; then _err "Add txt record error." return 1 @@ -120,23 +120,23 @@ dns_hover_rm() { if [ "$count" -eq "0" ]; then _info "Don't need to remove." else - # Get the record id to delete - record_id=$(printf "%s\n" "$response" | _egrep_o "\"id\":\"[^\"]*\",\"name\":\"$_sub_domain\",\"type\":\"TXT\",\"content\":\"$txtvalue\"" | tr -d \" | tr "," ":" | cut -d : -f 2 | head -n 1) + # Get the record id to delete + record_id=$(printf "%s\n" "$response" | _egrep_o "\"id\":\"[^\"]*\",\"name\":\"$_sub_domain\",\"type\":\"TXT\",\"content\":\"$txtvalue\"" | tr -d \" | tr "," ":" | cut -d : -f 2 | head -n 1) _debug "record_id" "$record_id" if [ -z "$record_id" ]; then _err "Can not get record id to remove." return 1 fi - # Delete the record + # Delete the record if ! _cf_rest DELETE "domains/$_domain_id/dns/$record_id"; then _err "Delete record error in call." return 1 fi - # verify response - if ! _contains "$response" "\"succeeded\":true"; then - _err "Delete record error in response." + # verify response + if ! _contains "$response" "\"succeeded\":true"; then + _err "Delete record error in response." return 1 - fi + fi fi @@ -150,51 +150,50 @@ dns_hover_rm() { # returns 0 success _HOVER_login() { -#save the credentials to the account conf file required for testing -# _saveaccountconf_mutable HOVER_Username "$HOVER_Username" -# _saveaccountconf_mutable HOVER_Password "$HOVER_Password" + #save the credentials to the account conf file required for testing + # _saveaccountconf_mutable HOVER_Username "$HOVER_Username" + # _saveaccountconf_mutable HOVER_Password "$HOVER_Password" if [ -z "$HOVER_COOKIE" ]; then HOVER_Username="${HOVER_Username:-$(_readaccountconf_mutable HOVER_Username)}" HOVER_Password="${HOVER_Password:-$(_readaccountconf_mutable HOVER_Password)}" - - if [ -z "$HOVER_Username" ] || [ -z "$HOVER_Password" ]; then - - _err "You did not specify the HOVER username and password yet." - _err "Please export as HOVER_Username / HOVER_Password and try again." + + if [ -z "$HOVER_Username" ] || [ -z "$HOVER_Password" ]; then + + _err "You did not specify the HOVER username and password yet." + _err "Please export as HOVER_Username / HOVER_Password and try again." HOVER_Username="" HOVER_Password="" - return 1 - else - - _debug "Login to HOVER as user $HOVER_Username" + return 1 + else + _debug "Login to HOVER as user $HOVER_Username" _cf_rest POST "login" "username=$(printf '%s' "$HOVER_Username")&password=$(printf '%s' "$HOVER_Password")" - if [ "$?" != "0" ]; then - _err "HOVER login failed for user $HOVER_Username bad RC from _post" - return 1 - fi + if [ "$?" != "0" ]; then + _err "HOVER login failed for user $HOVER_Username bad RC from _post" + return 1 + fi - HOVER_COOKIE="$(grep -i '^.*Cookie:.*hoverauth=.*$' "$HTTP_HEADER" | _head_n 1 | tr -d "\r\n" | cut -d ":" -f 2)" - export HOVER_COOKIE + HOVER_COOKIE="$(grep -i '^.*Cookie:.*hoverauth=.*$' "$HTTP_HEADER" | _head_n 1 | tr -d "\r\n" | cut -d ":" -f 2)" + export HOVER_COOKIE - if [ -z "$HOVER_COOKIE" ]; then - _debug3 response "$response" - _err "HOVER login failed for user $HOVER_Username. Check $HTTP_HEADER file" - using_cached_cookies="true" - return 1 - else - using_cached_cookies="true" - return 0 - fi - fi - else - # use Cookie - return 0 - fi + if [ -z "$HOVER_COOKIE" ]; then + _debug3 response "$response" + _err "HOVER login failed for user $HOVER_Username. Check $HTTP_HEADER file" + using_cached_cookies="true" + return 1 + else + using_cached_cookies="true" + return 0 + fi + fi + else + # use Cookie + return 0 + fi -_debug "HOVER login cookies: $HOVER_COOKIE (cached = $using_cached_cookies)" -return 1 + _debug "HOVER login cookies: $HOVER_COOKIE (cached = $using_cached_cookies)" + return 1 } @@ -231,7 +230,7 @@ _get_root() { fi p=$i i=$(_math "$i" + 1) - + done return 1 } @@ -243,11 +242,11 @@ _cf_rest() { _debug "$ep" if [ "$ep" != "login" ]; then - export _H1="Cookie:$HOVER_COOKIE" - export _H3="Content-Type: application/json" + export _H1="Cookie:$HOVER_COOKIE" + export _H3="Content-Type: application/json" fi - export _H2="Accept-Language:en-US" + export _H2="Accept-Language:en-US" if [ "$m" != "GET" ]; then _debug data "$data" From 2b5dd5bf7323acec70ee789b0f8ab2b85bac9d33 Mon Sep 17 00:00:00 2001 From: ddarek2000 <40216289+ddarek2000@users.noreply.github.com> Date: Mon, 31 Aug 2020 14:30:19 -0400 Subject: [PATCH 6/8] Update dns_hover.sh --- dnsapi/dns_hover.sh | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/dnsapi/dns_hover.sh b/dnsapi/dns_hover.sh index 3c282e86..eee45294 100644 --- a/dnsapi/dns_hover.sh +++ b/dnsapi/dns_hover.sh @@ -114,13 +114,13 @@ dns_hover_rm() { fi ########### DELETE ########### - count=$(printf "%s\n" "$response" | _egrep_o ",\"name\":\"$_sub_domain\",\"type\":\"TXT\",\"content\":\"$txtvalue\"" | cut -d : -f 2| wc -l ) + count=$(printf "%s\n" "$response" | _egrep_o ",\"name\":\"$_sub_domain\",\"type\":\"TXT\",\"content\":\"$txtvalue\"" | cut -d : -f 2 | wc -l) _debug count "$count" if [ "$count" -eq "0" ]; then _info "Don't need to remove." else - # Get the record id to delete + # Get the record id to delete record_id=$(printf "%s\n" "$response" | _egrep_o "\"id\":\"[^\"]*\",\"name\":\"$_sub_domain\",\"type\":\"TXT\",\"content\":\"$txtvalue\"" | tr -d \" | tr "," ":" | cut -d : -f 2 | head -n 1) _debug "record_id" "$record_id" if [ -z "$record_id" ]; then @@ -132,12 +132,12 @@ dns_hover_rm() { _err "Delete record error in call." return 1 fi - # verify response - if ! _contains "$response" "\"succeeded\":true"; then - _err "Delete record error in response." - return 1 - fi + # verify response + if ! _contains "$response" "\"succeeded\":true"; then + _err "Delete record error in response." + return 1 + fi fi } @@ -158,9 +158,9 @@ _HOVER_login() { HOVER_Username="${HOVER_Username:-$(_readaccountconf_mutable HOVER_Username)}" HOVER_Password="${HOVER_Password:-$(_readaccountconf_mutable HOVER_Password)}" - + if [ -z "$HOVER_Username" ] || [ -z "$HOVER_Password" ]; then - + _err "You did not specify the HOVER username and password yet." _err "Please export as HOVER_Username / HOVER_Password and try again." HOVER_Username="" @@ -187,10 +187,10 @@ _HOVER_login() { return 0 fi fi - else - # use Cookie - return 0 - fi + else + # use Cookie + return 0 + fi _debug "HOVER login cookies: $HOVER_COOKIE (cached = $using_cached_cookies)" return 1 @@ -242,8 +242,8 @@ _cf_rest() { _debug "$ep" if [ "$ep" != "login" ]; then - export _H1="Cookie:$HOVER_COOKIE" - export _H3="Content-Type: application/json" + export _H1="Cookie:$HOVER_COOKIE" + export _H3="Content-Type: application/json" fi export _H2="Accept-Language:en-US" From 78be077872eefb911018ae104cf2a6050838d6d4 Mon Sep 17 00:00:00 2001 From: ddarek2000 <40216289+ddarek2000@users.noreply.github.com> Date: Mon, 31 Aug 2020 14:33:51 -0400 Subject: [PATCH 7/8] Update dns_hover.sh --- dnsapi/dns_hover.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/dnsapi/dns_hover.sh b/dnsapi/dns_hover.sh index eee45294..a3008782 100644 --- a/dnsapi/dns_hover.sh +++ b/dnsapi/dns_hover.sh @@ -57,7 +57,7 @@ dns_hover_add() { _info "Adding record" if _cf_rest POST "domains/$_domain_id/dns" "{\"name\":\"$_sub_domain\",\"type\":\"TXT\",\"content\":\"$txtvalue\",\"ttl\":5,\"is_default\":false,\"can_revert\":false}"; then - + if ! _contains "$response" "\"succeeded\":true"; then _err "Add txt record error." return 1 @@ -127,7 +127,8 @@ dns_hover_rm() { _err "Can not get record id to remove." return 1 fi - # Delete the record + + # Delete the record if ! _cf_rest DELETE "domains/$_domain_id/dns/$record_id"; then _err "Delete record error in call." return 1 @@ -136,7 +137,7 @@ dns_hover_rm() { # verify response if ! _contains "$response" "\"succeeded\":true"; then _err "Delete record error in response." - return 1 + return 1 fi fi @@ -230,7 +231,7 @@ _get_root() { fi p=$i i=$(_math "$i" + 1) - + done return 1 } From 1e07ebf283499f7faf81a785f7c3c3b909b0b371 Mon Sep 17 00:00:00 2001 From: ddarek2000 <40216289+ddarek2000@users.noreply.github.com> Date: Mon, 31 Aug 2020 14:35:43 -0400 Subject: [PATCH 8/8] Update dns_hover.sh --- dnsapi/dns_hover.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/dnsapi/dns_hover.sh b/dnsapi/dns_hover.sh index a3008782..d9322c9e 100644 --- a/dnsapi/dns_hover.sh +++ b/dnsapi/dns_hover.sh @@ -198,7 +198,6 @@ _HOVER_login() { } - #_acme-challenge.www.domain.com #returns # _sub_domain=_acme-challenge.www