mirror of
https://github.com/acmesh-official/acme.sh.git
synced 2025-05-05 15:12:53 +00:00
Update dns_googledomains.sh
This commit is contained in:
parent
b30227d544
commit
6e5374e8f9
@ -1,66 +1,66 @@
|
|||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
GOOGLEDOMAINS_API="https://acmedns.googleapis.com/v1/acmeChallengeSets"
|
GOOGLEDOMAINS_API="https://acmedns.googleapis.com/v1/acmeChallengeSets"
|
||||||
dns_googledomains_add() {
|
dns_googledomains_add() {
|
||||||
fulldomain=$1
|
fulldomain=$1
|
||||||
txtvalue=$2
|
txtvalue=$2
|
||||||
_info "Using Google Domains api"
|
_info "Using Google Domains api"
|
||||||
_debug fulldomain "$fulldomain"
|
_debug fulldomain "$fulldomain"
|
||||||
_debug txtvalue "$txtvalue"
|
_debug txtvalue "$txtvalue"
|
||||||
|
|
||||||
GOOGLEDOMAINS_TOKEN="${GOOGLEDOMAINS_TOKEN:-$(_readaccountconf_mutable GOOGLEDOMAINS_TOKEN)}"
|
GOOGLEDOMAINS_TOKEN="${GOOGLEDOMAINS_TOKEN:-$(_readaccountconf_mutable GOOGLEDOMAINS_TOKEN)}"
|
||||||
|
|
||||||
if [ -z "$GOOGLEDOMAINS_TOKEN" ]; then
|
if [ -z "$GOOGLEDOMAINS_TOKEN" ]; then
|
||||||
GOOGLEDOMAINS_TOKEN=""
|
GOOGLEDOMAINS_TOKEN=""
|
||||||
_err "You did not specify GOOGLEDOMAINS_TOKEN yet."
|
_err "You did not specify GOOGLEDOMAINS_TOKEN yet."
|
||||||
_err "Please create your key and try again."
|
_err "Please create your key and try again."
|
||||||
_err "e.g."
|
_err "e.g."
|
||||||
_err "export GOOGLEDOMAINS_TOKEN=d41d8cd98f00b204e9800998ecf8427e"
|
_err "export GOOGLEDOMAINS_TOKEN=d41d8cd98f00b204e9800998ecf8427e"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
#save the api token to the account conf file.
|
#save the api token to the account conf file.
|
||||||
_saveaccountconf_mutable GOOGLEDOMAINS_TOKEN "$GOOGLEDOMAINS_TOKEN"
|
_saveaccountconf_mutable GOOGLEDOMAINS_TOKEN "$GOOGLEDOMAINS_TOKEN"
|
||||||
|
|
||||||
_debug "First detect the root zone"
|
_debug "First detect the root zone"
|
||||||
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" "" ""
|
||||||
}
|
}
|
||||||
dns_googledomains_rm() {
|
dns_googledomains_rm() {
|
||||||
fulldomain=$1
|
fulldomain=$1
|
||||||
txtvalue=$2
|
txtvalue=$2
|
||||||
|
|
||||||
GOOGLEDOMAINS_TOKEN="${GOOGLEDOMAINS_TOKEN:-$(_readaccountconf_mutable GOOGLEDOMAINS_TOKEN)}"
|
GOOGLEDOMAINS_TOKEN="${GOOGLEDOMAINS_TOKEN:-$(_readaccountconf_mutable GOOGLEDOMAINS_TOKEN)}"
|
||||||
_info "Using Google Domains api"
|
_info "Using Google Domains api"
|
||||||
_debug fulldomain "$fulldomain"
|
_debug fulldomain "$fulldomain"
|
||||||
_debug txtvalue "$txtvalue"
|
_debug txtvalue "$txtvalue"
|
||||||
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
|
||||||
echo "Invalid domain: $current_domain"
|
echo "Invalid domain: $current_domain"
|
||||||
else
|
else
|
||||||
echo "Found valid domain: $current_domain"
|
echo "Found valid domain: $current_domain"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
i=$((i + 1))
|
i=$((i + 1))
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user