From 233560167b32bc4fb18c5f31bb5f37779640257d Mon Sep 17 00:00:00 2001 From: Eric Renfro Date: Tue, 31 Oct 2023 14:24:22 -0400 Subject: [PATCH] Fixing bugs --- src/agents.d/update-dns-namecheap | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/agents.d/update-dns-namecheap b/src/agents.d/update-dns-namecheap index f63474e..2fddba0 100755 --- a/src/agents.d/update-dns-namecheap +++ b/src/agents.d/update-dns-namecheap @@ -44,9 +44,9 @@ _update_dns_namecheap() { local result local errors - result="$(curl -qs "https://dynamicdns.park-your-domain.com/update?host=${dnsHostname}&domain=${dnsDomain}&password=${dnsToken}&ip=${dnsIP}" | grep ErrCount)" + result="$(curl -qs \"https://dynamicdns.park-your-domain.com/update?host=${dnsHostname}&domain=${dnsDomain}&password=${dnsToken}&ip=${dnsIP}" | grep ErrCount)" if [[ $? -eq 0 ]]; then - errors="$(set -n -e 's/.*\(.*\)<\/ErrCount>.*/\1/p' <<< $result)" + errors="$(grep oPm1 "(?<=)[^<]+" <<< $result)" if [[ "$errors" -eq 0 ]]; then echo "DNS record ${dnsHostname}.${dnsDomain} updated successfully." @@ -63,14 +63,16 @@ _update_dns_namecheap() { # Main -_get_host_and_domain "$DIP_RECORD" || exit 99 +_get_host_and_domain "$DIP_RECORD" || return 99 if valid_ipv4 "$DIP_CUR_IP"; then log "Updating Namecheap DNS IPv4 Record for ${hostname}.${domain}" _update_dns_namecheap "$hostname" "$domain" "$token" "${DIP_CUR_IP}" + return $? fi if valid_ipv6 "$DIP_CUR_IP"; then log "Updating Namecheap DNS IPv6 Record for ${hostname}.${domain}" _update_dns_namecheap "$hostname" "$domain" "$token" "${DIP_CUR_IP}" + return $? fi