From b2baa656b9f670516123e7575778c3bfbf2e45db Mon Sep 17 00:00:00 2001 From: Eric Renfro Date: Tue, 31 Oct 2023 14:32:14 -0400 Subject: [PATCH] Finally fixed bugs and shellcheck cleanup --- src/agents.d/update-dns-namecheap | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/agents.d/update-dns-namecheap b/src/agents.d/update-dns-namecheap index 1b545de..61c6ebf 100755 --- a/src/agents.d/update-dns-namecheap +++ b/src/agents.d/update-dns-namecheap @@ -44,9 +44,8 @@ _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)" - if [[ $? -eq 0 ]]; then - errors="$(grep -oPm1 "(?<=)[^<]+" <<< $result)" + if result=$(curl -qs "https://dynamicdns.park-your-domain.com/update?host=${dnsHostname}&domain=${dnsDomain}&password=${dnsToken}&ip=${dnsIP}" | grep ErrCount); then + errors=$(grep -oPm1 "(?<=)[^<]+" <<< "$result") if [[ "$errors" -eq 0 ]]; then echo "DNS record ${dnsHostname}.${dnsDomain} updated successfully." @@ -68,11 +67,11 @@ _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 $? + exit $? 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 $? + exit $? fi