[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cobalt-users] script to check for updates at Cobalt



I guess everybody, like myself, want's to stay on top of available packages
from Cobalt. So I've written a script that checks the webpage and will mail
you when something has changed.
Cron it every day as root and you have one thing less to check everyday.
(do not forget to change the email address to something suitable)
--------------- cut here ------------------
#!/bin/sh

####################################
# File:   checkupdates
# Author: Reinoud van Leeuwen (reinoud.v@xxxxxxxxxxxxx)
# $Revision: 1.1 $
# Desc:   Check the patches download page to see if it has 
#         Changed, and mail sombody that new patches might
#         have appeared.
#
# $Log: checkupdates,v $
# Revision 1.1  2001/03/06 12:30:16  root
# Initial revision
#
####################################

# change email address to the address of the Cobalt administrator
#
export EMAIL=yourmail@xxxxxxxxxxxxxxx

# You will probably have to change nothing from here
#
export TESTDIR=~/checkupdates.dir
export TESTFILE=$TESTDIR/checkupdatepage.keep
export LOG=$TESTDIR/checkupdates.log
export URL=http://pkg.nl.cobalt.com/
export LYNX=/usr/bin/lynx

TMPFILE=`mktemp -q /tmp/$0.XXXXXX`
if [ $? -ne 0 ]; then
  echo "$0: Can't create temp file, exiting..."
  exit 1
fi

if [ ! -d $TESTDIR ]; then
    mkdir -p $TESTDIR
fi 

if [ ! -e $LOG ]
then  
  touch $LOG
fi

export TIME=`date`

$LYNX -dump $URL > $TMPFILE

if [ -e $TESTFILE ]
then
  diff $TMPFILE $TESTFILE > /dev/null
  if  [ $? -eq 1 ]
  then 
    # files different -> web page has changed!
    echo "check $URL (brought to you by $0 on `hostname`)" | \
       mail -s "new updates available? (Web page $URL has changed)" $EMAIL
    echo "$TIME  STATUS CHANGED! (mailed to $EMAIL)" >> $LOG
  else
    echo "$TIME  nothing changed" >> $LOG
  fi
fi
cp $TMPFILE $TESTFILE
rm $TMPFILE

----------- end of script -----------------------