-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_domain.sh
More file actions
executable file
·44 lines (33 loc) · 901 Bytes
/
check_domain.sh
File metadata and controls
executable file
·44 lines (33 loc) · 901 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env bash
set -euo pipefail
FILE="${1:-domains.txt}"
if [[ ! -f "$FILE" ]]; then
echo "Domain list file not found: $FILE"
exit 1
fi
printf "%-35s %-12s %-10s %-10s\n" "DOMAIN" "DNS" "HTTP" "HTTPS"
printf "%-35s %-12s %-10s %-10s\n" "------" "---" "----" "-----"
while read -r domain; do
[[ -z "$domain" || "$domain" =~ ^# ]] && continue
# DNS check
dns=$(dig +short "$domain" A "$domain" CNAME | head -n1)
if [[ -z "$dns" ]]; then
dns_status="NO_DNS"
else
dns_status="OK"
fi
# HTTP check
if curl -sI --max-time 5 "http://$domain" >/dev/null; then
http_status="OK"
else
http_status="FAIL"
fi
# HTTPS check
if curl -sI --max-time 5 "https://$domain" >/dev/null; then
https_status="OK"
else
https_status="FAIL"
fi
printf "%-35s %-12s %-10s %-10s\n" \
"$domain" "$dns_status" "$http_status" "$https_status"
done < "$FILE"