-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcheck_mirrors_headers_at_url
More file actions
executable file
·31 lines (25 loc) · 1.08 KB
/
check_mirrors_headers_at_url
File metadata and controls
executable file
·31 lines (25 loc) · 1.08 KB
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
#!/bin/bash
# For the given URL, gather some response headers from a HEAD request against each mirror server
# Example use case: Determine when each mirrors' copy of a file at the given URL was last modified
URL=$1
if [ "x$URL" = "x" ];
then
echo "Usage: $(basename $0) <URL>"
echo ''
echo 'URL should point to a file download.'
echo ''
echo 'Example:'
echo " $(basename $0) http://ftp.us.debian.org/debian/dists/Debian11.3/main/binary-all/Packages.xz"
exit 1
fi
FQDN=$(echo "$URL" | sed -E 's;^https?://([^/:]*)[:/].*;\1;i')
# Get list of IP addresses (omitting CNAMEs) and add square brackets around IPV6 IP addresses
IPS=($(dig -t A $FQDN +short | grep -Ev '^[a-zA-Z]'; dig -t AAAA $FQDN +short | grep -Ev '^[a-zA-Z]' | xargs -I '{}' echo '[{}]'))
echo "Testing ${#IPS[@]} mirrors for URL: $URL"
echo
for IP in ${IPS[@]}
do
echo " IP: $IP"
curl -sI --resolve $FQDN:80:$IP --resolve $FQDN:443:$IP $URL | grep -Ei --color=NEVER '^(HTTP|(Server|Last-Modified|Content-Type|Content-Length|Cache-Control|Expires|Etag|X-Cache-Status):)' | xargs -I '{}' echo ' {}'
echo
done