summaryrefslogtreecommitdiff
path: root/buildbot/linkchecker.sh
blob: 1eaac2472183ce29627b40d62099d2f1a7e4cef9 (plain)
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
44
#!/bin/bash
#set -v
# Removed because wget errors with error 8 (Server issued an error response.)
#set -e

## This script will scan www.taler.net for broken links and e-mail a copy of the log if any are found.

logfile="$HOME/linkchecker.log"
wait_time="1"
recurse_level="1"
ignore_list="(.*)demo.taler.net(.*)\/orders\/(.*)" # appears to do *nothing*

# Remove old log

if [ -f "$logfile" ]
	then
		echo $logfile " exists.  Moving to" $logfile".old."
		mv $logfile $logfile.old
	else
		echo "Info: existing log file '$logfile' not found."
fi

podman build -t linkchecker:latest -f "$HOME/deployment/buildbot/linkchecker.Containerfile" "$HOME/deployment/buildbot"

# Use wget to scan hosts and save output
for url in "https://www.taler.net/" "https://docs.taler.net/" "https://taler-systems.net/" "https://demo.taler.net/" "https://bank.demo.taler.net/" "https://shop.demo.taler.net/" "https://donations.demo.taler.net/" "https://survey.demo.taler.net/" ; do
	echo -e "\n\n#############################\n## Starting check on ${url}\n#############################\n"
	podman run --rm localhost/linkchecker:latest \
		linkchecker \
		--no-robots \
		--check-extern \
		--recursion-level="$recurse_level" \
		"$url" | tee --append "$logfile"
done

# Search the log for the phrase "broken link" as this is what wget will report
if grep -iRl 'Error' $logfile
	then
		echo "Found broken links.  Build should fail (exit 1), triggering e-mail notification."
		exit 1
	else
		echo "No broken links found.  Nothing more to do."
		exit 0
fi