Last active
August 7, 2023 20:24
-
-
Save felddy/8021c23a97a5c269e3b0f0a9b25b9cf6 to your computer and use it in GitHub Desktop.
Check FoundryVTT public DNS and create a markdown table of the results
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Initial list of domains | |
DOMAINS=("api.foundryvtt.com" | |
"foundryvtt.com" | |
"foundryvtt.s3.amazonaws.com" | |
"foundryvtt.s3.dualstack.us-west-2.amazonaws.com") | |
# Print the table header | |
echo "| Name | \`A\` | \`AAAA\` | Notes |" | |
echo "|------|:-:|:-----:|-------|" | |
# Set to keep track of checked domains | |
checked_domains=() | |
index=0 | |
while [ $index -lt ${#DOMAINS[@]} ]; do | |
domain=${DOMAINS[$index]} | |
# Skip if we've already checked this domain | |
if [[ " ${checked_domains[@]} " =~ " ${domain} " ]]; then | |
((index++)) | |
continue | |
fi | |
# Query A, AAAA, and CNAME records | |
a_record=$(dig +short $domain A) | |
aaaa_record=$(dig +short $domain AAAA) | |
cname_record=$(dig +short $domain CNAME) | |
# Check the records and set the appropriate symbols | |
a_status="❌" | |
aaaa_status="❌" | |
notes="" | |
if [[ ! -z $a_record ]]; then | |
a_status="✅" | |
fi | |
# Check if the AAAA record is actually an IPv6 address | |
if [[ $aaaa_record == *":"* ]]; then | |
aaaa_status="✅" | |
fi | |
if [[ ! -z $cname_record ]]; then | |
notes="\`CNAME\` to $cname_record" | |
# Insert CNAME into the list of domains to check right after the current domain | |
DOMAINS=("${DOMAINS[@]:0:$index+1}" "$cname_record" "${DOMAINS[@]:$index+1}") | |
fi | |
# Print the results in markdown table format | |
echo "| $domain | $a_status | $aaaa_status | $notes |" | |
# Mark the domain as checked | |
checked_domains+=("$domain") | |
((index++)) | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment