#!/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 # 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 "Starting check on $url" wget --spider \ --recursive \ --no-directories \ --no-verbose \ --span-hosts \ --level="$recurse_level" \ --wait="$wait_time" \ --reject-regex "$ignore_list" \ "$url" 2>&1 | tee --append "$logfile" done # Search the log for the phrase "broken link" as this is what wget will report if grep -iRl 'broken link!!' $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