#!/bin/bash # ukgovweb-check: # check for changes to http://barcamp.org/BarcampUKGovweb09 # # Define & use some variables; this makes it # easier (to re-purpose, for example). # this URI, we get from the email, change 'ir' & 'ea' values. URI="http://barcamp.org/BarcampUKGovweb09" # files, well, change these if you want. And the paths, too, if you want. file1=~/tmp/ukgovweb09-status.new file2=~/tmp/ukgovweb09-status crondiff=~/tmp/ukgovweb09-crondiff # these are the bits used in emailing, so guess what... subj="UKGovCamp09 Wiki has changed" mailto="adam@amyl.org.uk gmail@amyl.org.uk" # that done, let's get cracking. set -e cd ~/tmp # we use lynx 'cos it's nice and simple lynx -dump -force_html -nolist "${URI}" | tail -n +5 > ${file1} # remove existing diff file, if needed. if [ -e ${crondiff} ] ; then rm -rf ${crondiff} fi # and the work's all in here.. if [ -e ${file2} ] ; then if ! diff ${file2} ${file1} > /dev/null ; then echo 'ukgovweb wiki update:' echo '' diff -u ${file2} ${file1} > ${crondiff} || echo "continue" >/dev/null mv ${file1} ${file2} mailx -s "${subj}" ${mailto} < ${crondiff} else rm ${file1} fi else mv ${file1} ${file2} mailx -s "${subj}" ${mailto} < ${file2} fi