semi-offtopic - new kernel script watcher:

Jared Mauch (jared@puck.nether.net)
Thu, 29 May 1997 05:11:09 -0400 (EDT)


Please let me know if you have any questions about this..
basically it's a *TRULY* ugly hack that watches for a new
kernel to appear and will send you e-mail if it notices a new version.

THis is totally unsupported and should really be written in C to
be done "properly". Please heed my note about not running this
more than once every 10 minutes as a minimum, you can cause ftp servers
to do bad things if they get too many connections at once, and think
they're being syn flooded by lots of folks.. I'd recommend croning
it at some random time interval once an hour such as:

27 * * * * /yourhome/yourname/kernel.watcher

So that not everyone in the world crons their kernel watcher
for exactly the 0th minute of every hour.

I'll support this for about a week or two, then it's up to
you.. I'll probally get motivated enough to write this in C by then.

- Jared

#!/bin/sh
MAILADDR=jared@puck.nether.net
FTPSERVER=ftp.kernel.org
DIRECTORY=/pub/linux/kernel
TMPDIR=/tmp
LASTVER=/home/jared/.kern.ver
NCFTP=/usr/local/bin/ncftp
VERTOWATCH=v2.1
GREP=/usr/bin/grep
## find the latest kernel and send mail to $MAILADDR when it comes
## out on $FTPSERVER in the remote $DIRECTORY and the LATEST* file is
## updated

## **********************************************************************
## ** DO NOT EVER THINK OF CALLING THIS SCRIPT MORE THAN ONCE EVERY 10 **
## ** MINUTES OUT OF CRON! IT WILL DO BAD THINGS TO THE REMOTE SERVER **
## **********************************************************************

cd $TMPDIR

$NCFTP ftp://$FTPSERVER/$DIRECTORY/$VERTOWATCH/LATEST\* || exit 0

## check for the existance of $LASTVER
if [ -x $LASTVER ]
then
echo Creating file $LASTVER
echo "$VERTOWATCH:$VERTOWATCH.0" > $LASTVER
fi

CURVER=`grep ^$VERTOWATCH $LASTVER | cut -d: -f2`

GOTVER=`echo LATEST* | cut -d- -f3`

if [ $CURVER = $GOTVER ]
then
rm -f LATEST*
else
sed "s/$CURVER/$GOTVER/g" < $LASTVER > /tmp/lk.watch.$$
cp /tmp/lk.watch.$$ $LASTVER
rm -f /tmp/lk.watch.$$
echo "New kernel version $GOTVER is out" | mail -s"New Kernel $GOTVER" $MAILADDR
rm -f LATEST*
fi