#!/bin/sh # Bart Trojanowski (c) 2003 # bart@jukie.net # Use this script from cron, or run regularly, to get emails on new # kernel releases. # # Example crontab: # USER=bart # HOME=/home/bart # 1 * * * * $HOME/bin/finger-kernel-org # NOTE that ~/tmp must exist for this script to function DIR=${HOME}/tmp FILE=${DIR}/last-finger-kernel-org TMP=${FILE}.$$ DIFF=${FILE}.diff EMAIL=${FILE}.email # make sure that we have ${DIR} if ! [ -d ${DIR} ] ; then echo "create ${DIR} or configure the script" >&2 exit 1 fi # ${DIR} must be writable if ! [ -w ${DIR} ] ; then echo "make ${DIR} writable or configure the script" >&2 exit 1 fi # ${MAILTO} must be defined if [ -z "${MAILTO}" ] ; then # in that case ${USER} must be defined if [ -z "${USER}" ] ; then echo "either MAILTO or USER must be set in your environment" >&2 exit 1 fi MAILTO="${USER}" fi # nuke stale files rm -f ${FILE}.* # can we get a new list? if ! ( finger @www.kernel.org > ${TMP} ) ; then exit $? fi # are there any kernels, need at least 3 lines lines=$(wc -l < ${TMP}) if [ $lines -lt 2 ] ; then exit 1 fi # is this the first one? newvers="" if [ -f ${FILE} ] ; then # are there any diffs? if ( diff -u ${FILE} ${TMP} > ${DIFF} ) ; then exit 0 fi # compose email echo "" > $EMAIL echo "Changes" >> $EMAIL echo "" >> $EMAIL cat $DIFF >> $EMAIL newvers=$(grep "^+The latest" < $DIFF | cut -d : -f 2- | xargs echo) newvers="($newvers)" fi echo "" >> $EMAIL echo "Complete output of finger @www.kernel.org" >> $EMAIL echo "" >> $EMAIL cat $TMP >> $EMAIL mv -f $TMP $FILE mail -s "new kernel release $newvers" ${MAILTO} < $EMAIL