/g' | tr '@' '\n' | grep edit.php | grep "$fulldomain")"
- _debug2 subdomain_csv "$subdomain_csv"
+ _debug3 "subdomain_csv: $subdomain_csv"
# The above beauty ends with striping out rows that do not have an
# href to edit.php and do not have the domain name we are looking for.
@@ -216,35 +164,51 @@ dns_freedns_rm() {
lines="$(echo "$subdomain_csv" | wc -l)"
i=0
found=0
+ DNSdataid=""
while [ "$i" -lt "$lines" ]; do
i="$(_math "$i" + 1)"
line="$(echo "$subdomain_csv" | sed -n "${i}p")"
- _debug2 line "$line"
+ _debug3 "line: $line"
DNSname="$(echo "$line" | _egrep_o 'edit.php.*' | cut -d '>' -f 2 | cut -d '<' -f 1)"
- _debug2 DNSname "$DNSname"
- DNStype="$(echo "$line" | sed 's/' -f 2 | cut -d '<' -f 1)"
- _debug2 DNStype "$DNStype"
- if [ "$DNSname" = "$fulldomain" ] && [ "$DNStype" = "TXT" ]; then
- DNSdataid="$(echo "$line" | _egrep_o 'data_id=.*' | cut -d = -f 2 | cut -d '>' -f 1)"
- _debug2 DNSdataid "$DNSdataid"
- DNSvalue="$(echo "$line" | sed 's/ | ' -f 2 | cut -d '<' -f 1)"
- _debug2 DNSvalue "$DNSvalue"
- # if [ "$DNSvalue" = "$txtvalue" ]; then
- # Testing value match fails. Website is truncating the value
- # field. So for now we will assume that there is only one TXT
- # field for the sub domain and just delete it. Currently this
- # is a safe assumption.
- _freedns_delete_txt_record "$FREEDNS_COOKIE" "$DNSdataid"
- return $?
- # fi
+ _debug2 "DNSname: $DNSname"
+ if [ "$DNSname" = "$fulldomain" ]; then
+ DNStype="$(echo "$line" | sed 's/ | ' -f 2 | cut -d '<' -f 1)"
+ _debug2 "DNStype: $DNStype"
+ if [ "$DNStype" = "TXT" ]; then
+ DNSdataid="$(echo "$line" | _egrep_o 'data_id=.*' | cut -d = -f 2 | cut -d '>' -f 1)"
+ _debug2 "DNSdataid: $DNSdataid"
+ DNSvalue="$(echo "$line" | sed 's/ | ' -f 2 | cut -d '<' -f 1)"
+ if _startswith "$DNSvalue" """; then
+ # remove the quotation from the start
+ DNSvalue="$(echo "$DNSvalue" | cut -c 7-)"
+ fi
+ if _endswith "$DNSvalue" "..."; then
+ # value was truncated, remove the dot dot dot from the end
+ DNSvalue="$(echo "$DNSvalue" | sed 's/...$//')"
+ elif _endswith "$DNSvalue" """; then
+ # else remove the closing quotation from the end
+ DNSvalue="$(echo "$DNSvalue" | sed 's/......$//')"
+ fi
+ _debug2 "DNSvalue: $DNSvalue"
+
+ if [ -n "$DNSdataid" ] && _startswith "$txtvalue" "$DNSvalue"; then
+ # Found a match. But note... Website is truncating the
+ # value field so we are only testing that part that is not
+ # truncated. This should be accurate enough.
+ _debug "Deleting TXT record for $fulldomain, $txtvalue"
+ _freedns_delete_txt_record "$FREEDNS_COOKIE" "$DNSdataid"
+ return $?
+ fi
+
+ fi
fi
done
done
# If we get this far we did not find a match (after two attempts)
# Not necessarily an error, but log anyway.
- _debug2 "$subdomain_csv"
- _info "Cannot delete TXT record for $fulldomain/$txtvalue. Does not exist at FreeDNS"
+ _debug3 "$subdomain_csv"
+ _info "Cannot delete TXT record for $fulldomain, $txtvalue. Does not exist at FreeDNS"
return 0
}
@@ -272,7 +236,7 @@ _freedns_login() {
# if cookies is not empty then logon successful
if [ -z "$cookies" ]; then
- _debug "$htmlpage"
+ _debug3 "htmlpage: $htmlpage"
_err "FreeDNS login failed for user $username. Check $HTTP_HEADER file"
return 1
fi
@@ -301,7 +265,7 @@ _freedns_retrieve_subdomain_page() {
return 1
fi
- _debug2 "$htmlpage"
+ _debug3 "htmlpage: $htmlpage"
printf "%s" "$htmlpage"
return 0
@@ -323,17 +287,17 @@ _freedns_add_txt_record() {
_err "FreeDNS failed to add TXT record for $subdomain bad RC from _post"
return 1
elif ! grep "200 OK" "$HTTP_HEADER" >/dev/null; then
- _debug "$htmlpage"
+ _debug3 "htmlpage: $htmlpage"
_err "FreeDNS failed to add TXT record for $subdomain. Check $HTTP_HEADER file"
return 1
elif _contains "$htmlpage" "security code was incorrect"; then
- _debug "$htmlpage"
+ _debug3 "htmlpage: $htmlpage"
_err "FreeDNS failed to add TXT record for $subdomain as FreeDNS requested security code"
_err "Note that you cannot use automatic DNS validation for FreeDNS public domains"
return 1
fi
- _debug2 "$htmlpage"
+ _debug3 "htmlpage: $htmlpage"
_info "Added acme challenge TXT record for $fulldomain at FreeDNS"
return 0
}
@@ -352,7 +316,7 @@ _freedns_delete_txt_record() {
_err "FreeDNS failed to delete TXT record for $data_id bad RC from _get"
return 1
elif ! _contains "$htmlheader" "200 OK"; then
- _debug "$htmlheader"
+ _debug2 "htmlheader: $htmlheader"
_err "FreeDNS failed to delete TXT record $data_id"
return 1
fi
|