" |
+ sed -n 's/.*\(edit\.php?edit_domain_id=[0-9a-zA-Z]*\).*/\1/p' |
+ cut -d = -f 2)"
# The above beauty extracts domain ID from the html page...
# strip out all blank space and new lines. Then insert newlines
# before each table row
@@ -349,11 +349,11 @@ _freedns_data_id() {
return 1
fi
- data_id="$(echo "$htmlpage" | tr -d "[:space:]" | sed 's/
" |
+ grep "$search_domain" |
+ sed -n 's/.*\(edit\.php?data_id=[0-9a-zA-Z]*\).*/\1/p' |
+ cut -d = -f 2)"
# The above beauty extracts data ID from the html page...
# strip out all blank space and new lines. Then insert newlines
# before each table row
diff --git a/dnsapi/dns_gandi_livedns.sh b/dnsapi/dns_gandi_livedns.sh
index cdda4775..87119521 100644
--- a/dnsapi/dns_gandi_livedns.sh
+++ b/dnsapi/dns_gandi_livedns.sh
@@ -69,9 +69,9 @@ dns_gandi_livedns_rm() {
_gandi_livedns_rest PUT \
"domains/$_domain/records/$_sub_domain/TXT" \
- "{\"rrset_ttl\": 300, \"rrset_values\": $_new_rrset_values}" \
- && _contains "$response" '{"message": "DNS Record Created"}' \
- && _info "Removing record $(__green "success")"
+ "{\"rrset_ttl\": 300, \"rrset_values\": $_new_rrset_values}" &&
+ _contains "$response" '{"message": "DNS Record Created"}' &&
+ _info "Removing record $(__green "success")"
}
#################### Private functions below ##################################
@@ -125,9 +125,9 @@ _dns_gandi_append_record() {
fi
_debug new_rrset_values "$_rrset_values"
_gandi_livedns_rest PUT "domains/$_domain/records/$sub_domain/TXT" \
- "{\"rrset_ttl\": 300, \"rrset_values\": $_rrset_values}" \
- && _contains "$response" '{"message": "DNS Record Created"}' \
- && _info "Adding record $(__green "success")"
+ "{\"rrset_ttl\": 300, \"rrset_values\": $_rrset_values}" &&
+ _contains "$response" '{"message": "DNS Record Created"}' &&
+ _info "Adding record $(__green "success")"
}
_dns_gandi_existing_rrset_values() {
@@ -145,8 +145,8 @@ _dns_gandi_existing_rrset_values() {
return 1
fi
_debug "Already has TXT record."
- _rrset_values=$(echo "$response" | _egrep_o 'rrset_values.*\[.*\]' \
- | _egrep_o '\[".*\"]')
+ _rrset_values=$(echo "$response" | _egrep_o 'rrset_values.*\[.*\]' |
+ _egrep_o '\[".*\"]')
return 0
}
diff --git a/dnsapi/dns_gcloud.sh b/dnsapi/dns_gcloud.sh
index ebbeecf2..d560996c 100755
--- a/dnsapi/dns_gcloud.sh
+++ b/dnsapi/dns_gcloud.sh
@@ -78,8 +78,8 @@ _dns_gcloud_execute_tr() {
for i in $(seq 1 120); do
if gcloud dns record-sets changes list \
--zone="$managedZone" \
- --filter='status != done' \
- | grep -q '^.*'; then
+ --filter='status != done' |
+ grep -q '^.*'; then
_info "_dns_gcloud_execute_tr: waiting for transaction to be comitted ($i/120)..."
sleep 5
else
@@ -131,17 +131,17 @@ _dns_gcloud_find_zone() {
filter="$filter$part. "
part="$(echo "$part" | sed 's/[^.]*\.*//')"
done
- filter="$filter)"
+ filter="$filter) AND visibility=public"
_debug filter "$filter"
# List domains and find the zone with the deepest sub-domain (in case of some levels of delegation)
if ! match=$(gcloud dns managed-zones list \
--format="value(name, dnsName)" \
- --filter="$filter" \
- | while read -r dnsName name; do
+ --filter="$filter" |
+ while read -r dnsName name; do
printf "%s\t%s\t%s\n" "$(echo "$name" | awk -F"." '{print NF-1}')" "$dnsName" "$name"
- done \
- | sort -n -r | _head_n 1 | cut -f2,3 | grep '^.*'); then
+ done |
+ sort -n -r | _head_n 1 | cut -f2,3 | grep '^.*'); then
_err "_dns_gcloud_find_zone: Can't find a matching managed zone! Perhaps wrong project or gcloud credentials?"
return 1
fi
@@ -163,5 +163,8 @@ _dns_gcloud_get_rrdatas() {
return 1
fi
ttl=$(echo "$rrdatas" | cut -f1)
- rrdatas=$(echo "$rrdatas" | cut -f2 | sed 's/","/"\n"/g')
+ # starting with version 353.0.0 gcloud seems to
+ # separate records with a semicolon instead of commas
+ # see also https://cloud.google.com/sdk/docs/release-notes#35300_2021-08-17
+ rrdatas=$(echo "$rrdatas" | cut -f2 | sed 's/"[,;]"/"\n"/g')
}
diff --git a/dnsapi/dns_gd.sh b/dnsapi/dns_gd.sh
index 7cf47386..7f8efca9 100755
--- a/dnsapi/dns_gd.sh
+++ b/dnsapi/dns_gd.sh
@@ -91,7 +91,7 @@ dns_gd_rm() {
fi
if ! _contains "$response" "$txtvalue"; then
- _info "The record is not existing, skip"
+ _info "The record does not exist, skip"
return 0
fi
diff --git a/dnsapi/dns_gdnsdk.sh b/dnsapi/dns_gdnsdk.sh
deleted file mode 100755
index 8c4962c0..00000000
--- a/dnsapi/dns_gdnsdk.sh
+++ /dev/null
@@ -1,168 +0,0 @@
-#!/usr/bin/env sh
-#Author: Herman Sletteng
-#Report Bugs here: https://github.com/loial/acme.sh
-#
-#
-# Note, gratisdns requires a login first, so the script needs to handle
-# temporary cookies. Since acme.sh _get/_post currently don't directly support
-# cookies, I've defined wrapper functions _myget/_mypost to set the headers
-
-GDNSDK_API="https://admin.gratisdns.com"
-######## Public functions #####################
-#Usage: dns_gdnsdk_add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
-dns_gdnsdk_add() {
- fulldomain=$1
- txtvalue=$2
- _info "Using gratisdns.dk"
- _debug fulldomain "$fulldomain"
- _debug txtvalue "$txtvalue"
- if ! _gratisdns_login; then
- _err "Login failed!"
- return 1
- fi
- #finding domain zone
- if ! _get_domain; then
- _err "No matching root domain for $fulldomain found"
- return 1
- fi
- # adding entry
- _info "Adding the entry"
- _mypost "action=dns_primary_record_added_txt&user_domain=$_domain&name=$fulldomain&txtdata=$txtvalue&ttl=1"
- if _successful_update; then return 0; fi
- _err "Couldn't create entry!"
- return 1
-}
-
-#Usage: fulldomain txtvalue
-#Remove the txt record after validation.
-dns_gdnsdk_rm() {
- fulldomain=$1
- txtvalue=$2
- _info "Using gratisdns.dk"
- _debug fulldomain "$fulldomain"
- _debug txtvalue "$txtvalue"
- if ! _gratisdns_login; then
- _err "Login failed!"
- return 1
- fi
- if ! _get_domain; then
- _err "No matching root domain for $fulldomain found"
- return 1
- fi
- _findentry "$fulldomain" "$txtvalue"
- if [ -z "$_id" ]; then
- _info "Entry doesn't exist, nothing to delete"
- return 0
- fi
- _debug "Deleting record..."
- _mypost "action=dns_primary_delete_txt&user_domain=$_domain&id=$_id"
- # removing entry
-
- if _successful_update; then return 0; fi
- _err "Couldn't delete entry!"
- return 1
-}
-
-#################### Private functions below ##################################
-
-_checkcredentials() {
- GDNSDK_Username="${GDNSDK_Username:-$(_readaccountconf_mutable GDNSDK_Username)}"
- GDNSDK_Password="${GDNSDK_Password:-$(_readaccountconf_mutable GDNSDK_Password)}"
-
- if [ -z "$GDNSDK_Username" ] || [ -z "$GDNSDK_Password" ]; then
- GDNSDK_Username=""
- GDNSDK_Password=""
- _err "You haven't specified gratisdns.dk username and password yet."
- _err "Please add credentials and try again."
- return 1
- fi
- #save the credentials to the account conf file.
- _saveaccountconf_mutable GDNSDK_Username "$GDNSDK_Username"
- _saveaccountconf_mutable GDNSDK_Password "$GDNSDK_Password"
- return 0
-}
-
-_checkcookie() {
- GDNSDK_Cookie="${GDNSDK_Cookie:-$(_readaccountconf_mutable GDNSDK_Cookie)}"
- if [ -z "$GDNSDK_Cookie" ]; then
- _debug "No cached cookie found"
- return 1
- fi
- _myget "action="
- if (echo "$_result" | grep -q "logmeout"); then
- _debug "Cached cookie still valid"
- return 0
- fi
- _debug "Cached cookie no longer valid"
- GDNSDK_Cookie=""
- _saveaccountconf_mutable GDNSDK_Cookie "$GDNSDK_Cookie"
- return 1
-}
-
-_gratisdns_login() {
- if ! _checkcredentials; then return 1; fi
-
- if _checkcookie; then
- _debug "Already logged in"
- return 0
- fi
- _debug "Logging into GratisDNS with user $GDNSDK_Username"
-
- if ! _mypost "login=$GDNSDK_Username&password=$GDNSDK_Password&action=logmein"; then
- _err "GratisDNS login failed for user $GDNSDK_Username bad RC from _post"
- return 1
- fi
-
- GDNSDK_Cookie="$(grep -A 15 '302 Found' "$HTTP_HEADER" | _egrep_o 'Cookie: [^;]*' | _head_n 1 | cut -d ' ' -f2)"
-
- if [ -z "$GDNSDK_Cookie" ]; then
- _err "GratisDNS login failed for user $GDNSDK_Username. Check $HTTP_HEADER file"
- return 1
- fi
- export GDNSDK_Cookie
- _saveaccountconf_mutable GDNSDK_Cookie "$GDNSDK_Cookie"
- return 0
-}
-
-_myget() {
- #Adds cookie to request
- export _H1="Cookie: $GDNSDK_Cookie"
- _result=$(_get "$GDNSDK_API?$1")
-}
-_mypost() {
- #Adds cookie to request
- export _H1="Cookie: $GDNSDK_Cookie"
- _result=$(_post "$1" "$GDNSDK_API")
-}
-
-_get_domain() {
- _myget 'action=dns_primarydns'
- _domains=$(echo "$_result" | _egrep_o ' domain="[[:alnum:]._-]+' | sed 's/^.*"//')
- if [ -z "$_domains" ]; then
- _err "Primary domain list not found!"
- return 1
- fi
- for _domain in $_domains; do
- if (_endswith "$fulldomain" "$_domain"); then
- _debug "Root domain: $_domain"
- return 0
- fi
- done
- return 1
-}
-
-_successful_update() {
- if (echo "$_result" | grep -q 'table-success'); then return 0; fi
- return 1
-}
-
-_findentry() {
- #returns id of dns entry, if it exists
- _myget "action=dns_primary_changeDNSsetup&user_domain=$_domain"
- _id=$(echo "$_result" | _egrep_o "
$1
\s*
$2
[^?]*[^&]*&id=[^&]*" | sed 's/^.*=//')
- if [ -n "$_id" ]; then
- _debug "Entry found with _id=$_id"
- return 0
- fi
- return 1
-}
diff --git a/dnsapi/dns_geoscaling.sh b/dnsapi/dns_geoscaling.sh
new file mode 100755
index 00000000..6ccf4daf
--- /dev/null
+++ b/dnsapi/dns_geoscaling.sh
@@ -0,0 +1,232 @@
+#!/usr/bin/env sh
+
+########################################################################
+# Geoscaling hook script for acme.sh
+#
+# Environment variables:
+#
+# - $GEOSCALING_Username (your Geoscaling username - this is usually NOT an amail address)
+# - $GEOSCALING_Password (your Geoscaling password)
+
+#-- dns_geoscaling_add() - Add TXT record --------------------------------------
+# Usage: dns_geoscaling_add _acme-challenge.subdomain.domain.com "XyZ123..."
+
+dns_geoscaling_add() {
+ full_domain=$1
+ txt_value=$2
+ _info "Using DNS-01 Geoscaling DNS2 hook"
+
+ GEOSCALING_Username="${GEOSCALING_Username:-$(_readaccountconf_mutable GEOSCALING_Username)}"
+ GEOSCALING_Password="${GEOSCALING_Password:-$(_readaccountconf_mutable GEOSCALING_Password)}"
+ if [ -z "$GEOSCALING_Username" ] || [ -z "$GEOSCALING_Password" ]; then
+ GEOSCALING_Username=
+ GEOSCALING_Password=
+ _err "No auth details provided. Please set user credentials using the \$GEOSCALING_Username and \$GEOSCALING_Password environment variables."
+ return 1
+ fi
+ _saveaccountconf_mutable GEOSCALING_Username "${GEOSCALING_Username}"
+ _saveaccountconf_mutable GEOSCALING_Password "${GEOSCALING_Password}"
+
+ # Fills in the $zone_id and $zone_name
+ find_zone "${full_domain}" || return 1
+ _debug "Zone id '${zone_id}' will be used."
+
+ # We're logged in here
+
+ # we should add ${full_domain} minus the trailing ${zone_name}
+
+ prefix=$(echo "${full_domain}" | sed "s|\\.${zone_name}\$||")
+
+ body="id=${zone_id}&name=${prefix}&type=TXT&content=${txt_value}&ttl=300&prio=0"
+
+ do_post "$body" "https://www.geoscaling.com/dns2/ajax/add_record.php"
+ exit_code="$?"
+ if [ "${exit_code}" -eq 0 ]; then
+ _info "TXT record added successfully."
+ else
+ _err "Couldn't add the TXT record."
+ fi
+ do_logout
+ return "${exit_code}"
+}
+
+#-- dns_geoscaling_rm() - Remove TXT record ------------------------------------
+# Usage: dns_geoscaling_rm _acme-challenge.subdomain.domain.com "XyZ123..."
+
+dns_geoscaling_rm() {
+ full_domain=$1
+ txt_value=$2
+ _info "Cleaning up after DNS-01 Geoscaling DNS2 hook"
+
+ GEOSCALING_Username="${GEOSCALING_Username:-$(_readaccountconf_mutable GEOSCALING_Username)}"
+ GEOSCALING_Password="${GEOSCALING_Password:-$(_readaccountconf_mutable GEOSCALING_Password)}"
+ if [ -z "$GEOSCALING_Username" ] || [ -z "$GEOSCALING_Password" ]; then
+ GEOSCALING_Username=
+ GEOSCALING_Password=
+ _err "No auth details provided. Please set user credentials using the \$GEOSCALING_Username and \$GEOSCALING_Password environment variables."
+ return 1
+ fi
+ _saveaccountconf_mutable GEOSCALING_Username "${GEOSCALING_Username}"
+ _saveaccountconf_mutable GEOSCALING_Password "${GEOSCALING_Password}"
+
+ # fills in the $zone_id
+ find_zone "${full_domain}" || return 1
+ _debug "Zone id '${zone_id}' will be used."
+
+ # Here we're logged in
+ # Find the record id to clean
+
+ # get the domain
+ response=$(do_get "https://www.geoscaling.com/dns2/index.php?module=domain&id=${zone_id}")
+ _debug2 "response" "$response"
+
+ table="$(echo "${response}" | tr -d '\n' | sed 's|.*
Basic Records
.*|
|')"
+ _debug2 table "${table}"
+ names=$(echo "${table}" | _egrep_o 'id="[0-9]+\.name">[^<]*' | sed 's|||; s|.*>||')
+ ids=$(echo "${table}" | _egrep_o 'id="[0-9]+\.name">[^<]*' | sed 's|\.name">.*||; s|id="||')
+ types=$(echo "${table}" | _egrep_o 'id="[0-9]+\.type">[^<]*' | sed 's|||; s|.*>||')
+ values=$(echo "${table}" | _egrep_o 'id="[0-9]+\.content">[^<]*' | sed 's|||; s|.*>||')
+
+ _debug2 names "${names}"
+ _debug2 ids "${ids}"
+ _debug2 types "${types}"
+ _debug2 values "${values}"
+
+ # look for line whose name is ${full_domain}, whose type is TXT, and whose value is ${txt_value}
+ line_num="$(echo "${values}" | grep -F -n -- "${txt_value}" | _head_n 1 | cut -d ':' -f 1)"
+ _debug2 line_num "${line_num}"
+ found_id=
+ if [ -n "$line_num" ]; then
+ type=$(echo "${types}" | sed -n "${line_num}p")
+ name=$(echo "${names}" | sed -n "${line_num}p")
+ id=$(echo "${ids}" | sed -n "${line_num}p")
+
+ _debug2 type "$type"
+ _debug2 name "$name"
+ _debug2 id "$id"
+ _debug2 full_domain "$full_domain"
+
+ if [ "${type}" = "TXT" ] && [ "${name}" = "${full_domain}" ]; then
+ found_id=${id}
+ fi
+ fi
+
+ if [ "${found_id}" = "" ]; then
+ _err "Can not find record id."
+ return 0
+ fi
+
+ # Remove the record
+ body="id=${zone_id}&record_id=${found_id}"
+ response=$(do_post "$body" "https://www.geoscaling.com/dns2/ajax/delete_record.php")
+ exit_code="$?"
+ if [ "$exit_code" -eq 0 ]; then
+ _info "Record removed successfully."
+ else
+ _err "Could not clean (remove) up the record. Please go to Geoscaling administration interface and clean it by hand."
+ fi
+ do_logout
+ return "${exit_code}"
+}
+
+########################## PRIVATE FUNCTIONS ###########################
+
+do_get() {
+ _url=$1
+ export _H1="Cookie: $geoscaling_phpsessid_cookie"
+ _get "${_url}"
+}
+
+do_post() {
+ _body=$1
+ _url=$2
+ export _H1="Cookie: $geoscaling_phpsessid_cookie"
+ _post "${_body}" "${_url}"
+}
+
+do_login() {
+
+ _info "Logging in..."
+
+ username_encoded="$(printf "%s" "${GEOSCALING_Username}" | _url_encode)"
+ password_encoded="$(printf "%s" "${GEOSCALING_Password}" | _url_encode)"
+ body="username=${username_encoded}&password=${password_encoded}"
+
+ response=$(_post "$body" "https://www.geoscaling.com/dns2/index.php?module=auth")
+ _debug2 response "${response}"
+
+ #retcode=$(grep '^HTTP[^ ]*' "${HTTP_HEADER}" | _head_n 1 | _egrep_o '[0-9]+$')
+ retcode=$(grep '^HTTP[^ ]*' "${HTTP_HEADER}" | _head_n 1 | cut -d ' ' -f 2)
+
+ if [ "$retcode" != "302" ]; then
+ _err "Geoscaling login failed for user ${GEOSCALING_Username}. Check ${HTTP_HEADER} file"
+ return 1
+ fi
+
+ geoscaling_phpsessid_cookie="$(grep -i '^set-cookie:' "${HTTP_HEADER}" | _egrep_o 'PHPSESSID=[^;]*;' | tr -d ';')"
+ return 0
+
+}
+
+do_logout() {
+ _info "Logging out."
+ response="$(do_get "https://www.geoscaling.com/dns2/index.php?module=auth")"
+ _debug2 response "$response"
+ return 0
+}
+
+find_zone() {
+ domain="$1"
+
+ # do login
+ do_login || return 1
+
+ # get zones
+ response="$(do_get "https://www.geoscaling.com/dns2/index.php?module=domains")"
+
+ table="$(echo "${response}" | tr -d '\n' | sed 's|.*