Uitbreiden link-checker
This commit is contained in:
parent
bbe63672b9
commit
905140979c
|
@ -4,16 +4,37 @@ set -eu
|
||||||
|
|
||||||
if [ -f ./check-all-links.tmp ]; then rm ./check-all-links.tmp; fi
|
if [ -f ./check-all-links.tmp ]; then rm ./check-all-links.tmp; fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if [ -d ./public ]; then
|
if [ -d ./public ]; then
|
||||||
grep -ri --only-matching --no-filename "https://[a-zA-Z0-9]*\.\([a-z0-9\.\_/~-]\)*" ./public | grep "^http" | sed 's/\\n.*//g' | sort --unique > check-all-links.tmp
|
|
||||||
|
# Recursief zoeken, case-insentive, alleen de woorden die matchen, bestandsnaam niet tonen
|
||||||
|
# Alleen de items tonen die starten met http
|
||||||
|
# Strip items die eindigen met een \ (o.a. uit feed.json)
|
||||||
|
# Strip items die eindigen met een \n en aanvullende tekst (b.v. in abstracts)
|
||||||
|
# Negeer items van GitHub/Schema.org
|
||||||
|
# Sorten en uniek maken van de lijst
|
||||||
|
grep -ri --only-matching --no-filename "https://[a-zA-Z0-9]*\.\([a-z0-9\.\_/~-]\)*" ./public \
|
||||||
|
| grep "^http" \
|
||||||
|
| sed 's/\\$//' \
|
||||||
|
| sed 's/\\n.*$//' \
|
||||||
|
| grep -v 'https://github.com/NLUUG/website' \
|
||||||
|
| grep -v 'https://schema.org' \
|
||||||
|
| sort --unique > check-all-links.tmp
|
||||||
|
|
||||||
|
# URL's testen
|
||||||
|
if [ -f ./check-all-links.tmp ]; then
|
||||||
for URL in $(cat ./check-all-links.tmp); do
|
for URL in $(cat ./check-all-links.tmp); do
|
||||||
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" "${URL}")
|
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" "${URL}")
|
||||||
if [ ! "${HTTP_CODE}" = "200" ]; then
|
if [ ! "${HTTP_CODE}" = "200" ]; then
|
||||||
echo "[WARNING] ${URL} (HTTP: ${HTTP_CODE})"
|
echo "[WARNING] ${URL} (HTTP: ${HTTP_CODE})"
|
||||||
fi
|
fi
|
||||||
sleep 5
|
sleep 2
|
||||||
done
|
done
|
||||||
|
else
|
||||||
|
echo "Kan bestand met links niet vinden."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "Dit script dient gedraaid te worden in de hoofddirectory van de website."
|
echo "Dit script dient gedraaid te worden in de hoofddirectory van de website."
|
||||||
exit 1
|
exit 1
|
||||||
|
|
Reference in a new issue