← back to Coming Soon Template
dns_watcher.sh
51 lines
#!/usr/bin/env bash
# Watches all 21 abrams/butler domains for a nameserver flip to Cloudflare.
# Polls every 60s, logs to /tmp/dns_watch.log, and writes a one-line
# state file at /tmp/dns_watch.state. Stop with: kill $(cat /tmp/dns_watch.pid)
set -u
cd "$(dirname "$0")"
DOMAINS=(
abramsindex.com abramsos.com abramsintel.com abramsspace.com abramsterminal.com
abramsvc.com abramsindustries.com abramsprotection.com abramscivic.com abramslive.com
abramsatlas.com abramsdirectory.com abramsguide.com abramslocal.com abramsmaps.com
abramsmarkets.com abramsintelligence.com
818butler.com beverlyhillsbutler.com bhbutler.com boulevardbutler.com
)
LOG=/tmp/dns_watch.log
STATE=/tmp/dns_watch.state
echo $$ > /tmp/dns_watch.pid
: > "$STATE"
printf "[%s] dns_watcher started for %d domains\n" "$(date '+%H:%M:%S')" "${#DOMAINS[@]}" >> "$LOG"
declare -A last_status
for d in "${DOMAINS[@]}"; do last_status[$d]="godaddy"; done
while true; do
cf_count=0
state_lines=""
for d in "${DOMAINS[@]}"; do
ns=$(dig +short +time=3 +tries=1 NS "$d" 2>/dev/null | head -1)
if echo "$ns" | grep -q "cloudflare"; then
status="cloudflare"
cf_count=$((cf_count+1))
elif echo "$ns" | grep -q "domaincontrol"; then
status="godaddy"
elif [ -z "$ns" ]; then
status="no-ns"
else
status="other"
fi
if [ "${last_status[$d]}" != "$status" ]; then
printf "[%s] %-30s %s -> %s\n" "$(date '+%H:%M:%S')" "$d" "${last_status[$d]}" "$status" >> "$LOG"
last_status[$d]=$status
fi
state_lines+="$d:$status\n"
done
printf "[%s] %d/21 domains on cloudflare\n" "$(date '+%H:%M:%S')" "$cf_count" > "$STATE"
printf "%b" "$state_lines" >> "$STATE"
sleep 60
done