fix(ingress.tjo.cloud/dyndns): jq and logging
Some checks failed
/ lint (push) Failing after 41s

This commit is contained in:
Tine 2025-01-06 19:11:10 +01:00
parent 37a2c76077
commit 14fbd80481
Signed by: mentos1386
SSH key fingerprint: SHA256:MNtTsLbihYaWF8j1fkOHfkKNlnN1JQfxEU/rBU8nCGw

View file

@ -178,9 +178,9 @@ while (true); do
done done
if [[ -z $ipv4 ]]; then if [[ -z $ipv4 ]]; then
log::warn "IPv4 address wasn't found." log::warn "type=A IPv4 address wasn't found."
else else
log::info "Found IPv4 address $ipv4" log::info "type=A ip=$ipv4 Found IPv4 address."
if healthcheck "$ipv4"; then if healthcheck "$ipv4"; then
configure::single "$domain_records" "$CLOUD_REGION" "$ipv4" "A" configure::single "$domain_records" "$CLOUD_REGION" "$ipv4" "A"
configure::many "$domain_records" "any" "$ipv4" "A" configure::many "$domain_records" "any" "$ipv4" "A"
@ -188,9 +188,9 @@ while (true); do
fi fi
if [[ -z $ipv6 ]]; then if [[ -z $ipv6 ]]; then
log::warn "IPv6 address wasn't found." log::warn "type=AAAA IPv6 address wasn't found."
else else
log::info "Found IPv6 address $ipv6" log::info "type=AAAA ip=$ipv6 Found IPv6 address"
if healthcheck "[$ipv6]"; then if healthcheck "[$ipv6]"; then
configure::single "$domain_records" "$CLOUD_REGION" "$ipv6" "AAAA" configure::single "$domain_records" "$CLOUD_REGION" "$ipv6" "AAAA"
configure::many "$domain_records" "any" "$ipv6" "AAAA" configure::many "$domain_records" "any" "$ipv6" "AAAA"
@ -198,28 +198,28 @@ while (true); do
fi fi
log::info "type=A Checking for stale records..." log::info "type=A Checking for stale records..."
for domain in $(echo "$domain_records" | jq -r ".data[] | select(.type == \"A\" and .name != \"$CLOUD_REGION\") | .name"); do echo "$domain_records" | jq -r ".data[] | select(.type == \"A\" and .name != \"$CLOUD_REGION\") | .name" | while read -r domain; do
log::info "type=A domain=$domain Checking..."
record_id=$(echo "$domain_records" | jq -r ".data[] | select(.name == \"$domain\") | .id") record_id=$(echo "$domain_records" | jq -r ".data[] | select(.name == \"$domain\") | .id")
record_ip=$(echo "$domain_records" | jq -r ".data[] | select(.name == \"$domain\") | .content") record_ip=$(echo "$domain_records" | jq -r ".data[] | select(.name == \"$domain\") | .content")
log::info "type=A domain=$domain ip=$record_ip Checking..."
if ! healthcheck "$record_ip"; then if ! healthcheck "$record_ip"; then
log::warn "type=A domain=$domain Unhealthy..." log::warn "type=A domain=$domain ip=$record_ip Unhealthy..."
dnsimple::record::delete "$record_id" dnsimple::record::delete "$record_id"
else else
log::info "type=A domain=$domain Healthy..." log::info "type=A domain=$domain ip=$record_ip Healthy..."
fi fi
done done
log::info "type=AAAA Checking for stale records..." log::info "type=AAAA Checking for stale records..."
for domain in $(echo "$domain_records" | jq -r ".data[] | select(.type == \"AAAA\" and .name != \"$CLOUD_REGION\") | .name"); do echo "$domain_records" | jq -r ".data[] | select(.type == \"AAAA\" and .name != \"$CLOUD_REGION\") | .name" | while read -r domain; do
log::info "type=AAAA domain=$domain Checking..."
record_id=$(echo "$domain_records" | jq -r ".data[] | select(.name == \"$domain\") | .id") record_id=$(echo "$domain_records" | jq -r ".data[] | select(.name == \"$domain\") | .id")
record_ip=$(echo "$domain_records" | jq -r ".data[] | select(.name == \"$domain\") | .content") record_ip=$(echo "$domain_records" | jq -r ".data[] | select(.name == \"$domain\") | .content")
if ! healthcheck "$record_ip"; then log::info "type=AAAA domain=$domain ip=$record_ip Checking..."
log::warn "type=AAAA domain=$domain Unhealthy." if ! healthcheck "[$record_ip]"; then
dnsimple::record::delete "[$record_id]" log::warn "type=AAAA domain=$domain ip=$record_ip Unhealthy."
dnsimple::record::delete "$record_id"
else else
log::info "type=AAAA domain=$domain Healthy." log::info "type=AAAA domain=$domain ip=$record_ip Healthy."
fi fi
done done