#!/bin/bash

# This skript checks if the Jargon File changed and dispatches an eMail
# License is GPL, in case anyone gives a damn for s.th. like that :)

# CONFIGURATION VARIABLES

# $USER - eMail Adress to send the notification to
USER=donkaspar@snooweatinganima.de

# $TMPFILE - temporary file
TMPFILE=/usr/local/tmp/tmp.jargon.index.html

# $MFILE - mirror index.html
MFILE=~/doms/snooweatinganima.de/subs/ressourcen/jargon/index.html
 
if (/bin/ping -c1 www.catb.org>/dev/null); then 
    echo "Host is up. Getting index.html..."
    wget --quiet  http://www.catb.org/~esr/jargon/index.html -O $TMPFILE
    echo "Comparing files..."
    if [ $TMPFILE -nt $MFILE ]; then
	echo "Difference noted, dispatching eMail"
	mail -s "Mirror Update necessary" $USER <<EOT
The Jargon File changed. Please update your mirror. The preferred way with wget:

wget -m http://catb.org/~esr/jargon/ -nH --cut-dirs=2 -np -L -P [your mirror location]
EOT
	echo "Removing Tempfile..."
	rm -f $TMPFILE
    else 
	echo "No difference. Aborting."
	echo "Deleting Tempfile..."
	rm -f $TMPFILE
    fi
else
    echo "Host seems down. Aborting."
fi