-
Notifications
You must be signed in to change notification settings - Fork 5
/
check_links.sh
22 lines (22 loc) · 824 Bytes
/
check_links.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/bash
LINKS="$(grep -r 'http://\|https://' ./docs | grep -oP 'http.*' | sed 's| .*||;s|).*||;s|`.*||')"
mapfile -t LINKS <<< "$LINKS"
for link in "${LINKS[@]}"
do
if echo "$link" | grep -q "yourdomain\|geizhals.eu\|192.168.178.144\|internal.*address\|packages.cisofy.com\|duckdns.org\|https://jan.wildeboer.net/about/\|https://askubuntu.com/questions/39760/how-can-i-control-hdd-spin-down-time/39764#39764"; then
echo "Not testing $link"
continue
fi
if [ "$(curl -sLI "$link" -o /dev/null -w "%{http_code}\n")" != 200 ]; then
echo "Invalid is: $link"
INVALID_LINKS+="$link\n"
else
echo "Valid is: $link"
fi
done
if [ -n "$INVALID_LINKS" ]; then
echo '################################'
echo 'Invalid Links:'
echo -e "$INVALID_LINKS"
exit 1
fi