Update dns_googledomains.sh

This commit is contained in:
Marcio Cruz 2023-03-08 17:29:10 -03:00
parent 64b6f3df7a
commit b30227d544

View File

@ -24,18 +24,18 @@ dns_googledomains_add() {
i=0 i=0
while [ $i -le "$(echo "$fulldomain" | grep -o '\.' | wc -l)" ]; do while [ $i -le "$(echo "$fulldomain" | grep -o '\.' | wc -l)" ]; do
# join the domain parts from the current index to the end # join the domain parts from the current index to the end
current_domain=$(echo "$fulldomain" | cut -d "." -f $((i+1))-) current_domain=$(echo "$fulldomain" | cut -d "." -f $((i + 1))-)
# make a curl request to the URL and break the loop if the HTTP response code is 200 # make a curl request to the URL and break the loop if the HTTP response code is 200
response="$(_get "$GOOGLEDOMAINS_API/$current_domain")" response="$(_get "$GOOGLEDOMAINS_API/$current_domain")"
if _contains "$response" "INVALID_ARGUMENT"; then if _contains "$response" "INVALID_ARGUMENT"; then
_info "Invalid domain: $current_domain" _info "Invalid domain: $current_domain"
else else
_info "Found valid domain: $current_domain" _info "Found valid domain: $current_domain"
break break
fi fi
i=$((i+1)) i=$((i + 1))
done done
export _H1="Content-Type: application/json" export _H1="Content-Type: application/json"
_post "{\"accessToken\":\"$GOOGLEDOMAINS_TOKEN\",\"keepExpiredRecords\":true,\"recordsToAdd\":[{\"digest\":\"$txtvalue\",\"fqdn\":\"$fulldomain\"}]}" "$GOOGLEDOMAINS_API/$current_domain:rotateChallenges" "" "" _post "{\"accessToken\":\"$GOOGLEDOMAINS_TOKEN\",\"keepExpiredRecords\":true,\"recordsToAdd\":[{\"digest\":\"$txtvalue\",\"fqdn\":\"$fulldomain\"}]}" "$GOOGLEDOMAINS_API/$current_domain:rotateChallenges" "" ""
@ -51,8 +51,8 @@ dns_googledomains_rm() {
i=0 i=0
while [ $i -le "$(echo "$fulldomain" | grep -o '\.' | wc -l)" ]; do while [ $i -le "$(echo "$fulldomain" | grep -o '\.' | wc -l)" ]; do
# join the domain parts from the current index to the end # join the domain parts from the current index to the end
current_domain=$(echo "$fulldomain" | cut -d "." -f $((i+1))-) current_domain=$(echo "$fulldomain" | cut -d "." -f $((i + 1))-)
# make a curl request to the URL and break the loop if the HTTP response code is 200 # make a curl request to the URL and break the loop if the HTTP response code is 200
response="$(_get "$GOOGLEDOMAINS_API/$current_domain")" response="$(_get "$GOOGLEDOMAINS_API/$current_domain")"
if _contains "$response" "INVALID_ARGUMENT"; then if _contains "$response" "INVALID_ARGUMENT"; then
@ -61,6 +61,6 @@ dns_googledomains_rm() {
echo "Found valid domain: $current_domain" echo "Found valid domain: $current_domain"
break break
fi fi
i=$((i+1)) i=$((i + 1))
done done
} }