#!/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="linkchecker.log" # 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 wget --spider -r -nd -nv -H -l 1 -w 2 -o $logfile https://www.taler.net/ wget --spider -r -nd -nv -H -l 1 -w 2 -a $logfile https://docs.taler.net/ wget --spider -r -nd -nv -H -l 1 -w 2 -a $logfile https://taler-systems.net/ wget --spider -r -nd -nv -H -l 1 -w 2 -a $logfile https://demo.taler.net/ wget --spider -r -nd -nv -H -l 1 -w 2 -a $logfile https://bank.demo.taler.net/ wget --spider -r -nd -nv -H -l 1 -w 2 -a $logfile https://shop.demo.taler.net/ wget --spider -r -nd -nv -H -l 1 -w 2 -a $logfile https://donations.demo.taler.net/ wget --spider -r -nd -nv -H -l 1 -w 2 -a $logfile https://survey.demo.taler.net/ # display logfile echo echo "Displaying contents of logfile" cat $logfile # 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