Browse Source

Fix shellcheck and shfmt issues

- Add double quotes around variables to prevent globbing
- Fix parameter expansion quoting in ${domain%.${_zone}}
- Remove trailing whitespace for shfmt compliance
pull/6760/head
Kilian Ries 1 week ago
parent
commit
01c93b9bbd
  1. 10
      dnsapi/dns_opusdns.sh

10
dnsapi/dns_opusdns.sh

@ -212,7 +212,7 @@ $page_zones"
zone_with_dot="${zone}." zone_with_dot="${zone}."
if _endswith "$domain." "$zone_with_dot"; then if _endswith "$domain." "$zone_with_dot"; then
zone_length=${#zone} zone_length=${#zone}
if [ $zone_length -gt $_zone_length ]; then
if [ "$zone_length" -gt "$_zone_length" ]; then
_zone="$zone" _zone="$zone"
_zone_length=$zone_length _zone_length=$zone_length
fi fi
@ -227,10 +227,10 @@ $page_zones"
# Calculate record name (subdomain part) # Calculate record name (subdomain part)
# Use parameter expansion instead of sed to avoid regex metacharacter issues # Use parameter expansion instead of sed to avoid regex metacharacter issues
_record_name="${domain%.${_zone}}"
_record_name="${domain%."${_zone}"}"
# Handle case where domain equals zone (remove trailing dot if present) # Handle case where domain equals zone (remove trailing dot if present)
if [ "$_record_name" = "$domain" ]; then if [ "$_record_name" = "$domain" ]; then
_record_name="${domain%${_zone}}"
_record_name="${domain%"${_zone}"}"
_record_name="${_record_name%.}" _record_name="${_record_name%.}"
fi fi
@ -343,9 +343,9 @@ _opusdns_wait_for_propagation() {
# Check all OpusDNS authoritative nameservers # Check all OpusDNS authoritative nameservers
for ns in $nameservers; do for ns in $nameservers; do
if _exists dig; then if _exists dig; then
result=$(dig @$ns +short "$fulldomain" TXT 2>/dev/null | tr -d '"')
result=$(dig @"$ns" +short "$fulldomain" TXT 2>/dev/null | tr -d '"')
elif _exists nslookup; then elif _exists nslookup; then
result=$(nslookup -type=TXT "$fulldomain" $ns 2>/dev/null | grep -A1 "text =" | tail -n1 | tr -d '"' | sed 's/^[[:space:]]*//')
result=$(nslookup -type=TXT "$fulldomain" "$ns" 2>/dev/null | grep -A1 "text =" | tail -n1 | tr -d '"' | sed 's/^[[:space:]]*//')
else else
_err "Neither dig nor nslookup found. Cannot verify DNS propagation." _err "Neither dig nor nslookup found. Cannot verify DNS propagation."
return 1 return 1

Loading…
Cancel
Save