#!/bin/bash # # Cronrss # Old style RSS feed # # http://freaknet.org/alpt/src/utils/cronrss # # It verifies if the web page pointed by a given URL has changed. # If it has, cronrss will send a notice email to you. # The URL list is kept in the ~/.cronrss/url text file (one URL per line). # # It is very useful to use URLs which point to rss feeds. # # *** Usage: # # 1) Put all the URLs you want to check in the ~/.cronrss/url text file (one # URL per line). # # 2) Run cronrss # # cronrss [-d [seconds]] # # If the `-d' option is specified, it will check periodically the URLs. # You can specify its frequency in seconds (default is 1800s = 30min) # # cronrss update # # Each time you modify the url_list, you have to run `cronrss update` # # *** Examples: # # echo http://www.hackaday.org >> ~/.cronrss/url # cronrss update # cronrss -d # # From this point on, whenever hackday.org changes you will get an email # # which shows you the text differences # # Since hackaday has a rss feed it is better to use this URL instead: # # http://www.hackaday.com/rss.xml # # *** Links: # # This webservice maybe useful: # http://page2rss.com/ # # PS: the idea of Cronrss was initially published on Idiki: # http://idiki.dyne.org/wiki/Cronrss # # # AlpT (@freaknet.org) # # # ## Configure here # dir=`echo ~/.cronrss` # cronrss stuff is saved in this directory dump="$dir/dump" # dumps of the web pages url_list="$dir/url" # url list file mail_to="`whoami`" # this is the email address where the notice is sent #mail_to="foo@bar.org`" mail_subject="Cronrss digest" # ## # # check_it() { local notice if [ "$1" == "no_notice" ] then notice=0 else notice=1 fi if [ ! -d $dump ] then mkdir -p $dump/ fi for i in `cat $url_list` do md5=`echo "$i" | md5sum | cut -d ' ' -f 1` rm -f $dump/old-$md5 &> /dev/null mv -f $dump/new-$md5 $dump/old-$md5 &> /dev/null links -dump "$i" > $dump/new-$md5 if [ "$?" != "0" ] || [ ! -f $dump/old-$md5 ] || [ ! -f $dump/new-$md5 ] then continue fi diff -q $dump/old-$md5 $dump/new-$md5 &> /dev/null if [ "$?" == 1 ] && [ "$notice" == "1" ] then local t t=`tempfile` echo "$i changed" > $t echo "" >> $t diff -u $dump/old-$md5 $dump/new-$md5 >> $t cat $t | mail -s "$mail_subject" $mail_to rm $t fi done } if test "$1" = "help" -o "$1" = "-h" -o "$1" = "--help" then echo "Usage:" echo " cronrss [-d [seconds]]" echo " cronrss update" echo "" echo " If the \"-d\" option is specified, it will check periodically the URLs." echo " You can specify its frequency in seconds (default is 1800s = 30min)" echo "" echo " Each time you modify the url_list, you have to run \"cronrss update\"" exit 1 fi if [ "$1" == "-d" ] then seconds=1800 if [ ! -z "$2" ] then seconds=$2 fi while true do check_it sleep $seconds done elif [ "$1" == "update" ] then check_it no_notice else check_it fi