latest-kernel 2.18 KB
Newer Older
Nico Schottelius's avatar
init  
Nico Schottelius committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
#!/bin/sh
#
# Nico Schottelius <nico@schottelius.(net|org)>
# Date: 21-Oct-2003
# Last Modified: 
# Versions:
#  1.6 2007-03-10
#     Only mail, if new kernel is newer.
#  1.5: 2006-03-20
#     Added URL to download kernel
#  1.4: 2006-02-03
#     Added Changelog

#set -x

MAILTO="kernel-announce@lists.schottelius.org"

USERFILE=$HOME/.latest-kernel

#VERSION=`curl ftp://ftp.kernel.org/pub/linux/kernel/v2.6/  | grep linux-2.6.0 | sort | tail -n 1 | awk ' { print $9 }' 2>/dev/null`
#VERSION=`curl ftp://ftp.kernel.org/pub/linux/kernel/v2.6/ | grep linux | awk '{ print $6 " " $7 " " $8 " " $9 }' | sort -M | tail -n 1`
#VERSION=`curl ftp://ftp.kernel.org/pub/linux/kernel/v2.6/ 2>/dev/null| awk '/linux/ { print $9 }' | sort | tail -n 1`
#VERSION=`curl ftp://ftp.kernel.org/pub/linux/kernel/v2.6/ 2>/dev/null| awk '/linux/ { print $9 }' | sort | tail -n 1 | sed 's/\.tar.*//'`
#VERSION=`curl ftp://ftp.kernel.org/pub/linux/kernel/v2.6/ 2>/dev/null| awk '/linux/ { print $9 }' | sed 's/\.tar.*//' | sort | tail -n 1`
#VERSION=$(curl -s http://ftp.kernel.org/pub/linux/kernel/v2.6/ 2>/dev/null | grep LATEST-IS | sed 's/.*LATEST-IS-//')

VERSION=$(curl -s http://ftp.kernel.org/pub/linux/kernel/v2.6/ | grep LATEST-IS- | sed 's/.*LATEST-IS-\(.*\)<\/a.*/\1/')
OLDVERSION=`cat $USERFILE 2>/dev/null`

if [ "$OLDVERSION" != "$VERSION" -a -n "$VERSION"  ]; then
   i=1
   newpart=$(echo $VERSION | cut -f${i} -d.)

   while [ "$newpart" ]; do
      oldpart=$(echo $OLDVERSION | cut -f${i} -d.)
      echo "${oldpart}::${newpart}"
      if [ "$oldpart" -gt "$newpart" ]; then
         echo "Abort: $VERSION is older then old $OLDVERSION"
         exit 1
      fi

      i=$(($i+1))
      newpart=$(echo $VERSION | cut -f${i} -d.)
   done

   CHANGELOG="http://www.kernel.org/pub/linux/kernel/v2.6/ChangeLog-${VERSION}"

   BASEURL="http://www.kernel.org/pub/linux/kernel/v2.6/linux-"
   EXTENSION=".tar.bz2"
   FULL_URL=${BASEURL}${VERSION}${EXTENSION}

   (
      echo "Download kernel at $FULL_URL"
      echo ""
      curl -s ${CHANGELOG}
   #) | mail -s "New Linux-Kernel: $VERSION" "$MAILTO"
   ) | mutt -s "New Linux-Kernel: $VERSION" "$MAILTO"

   echo "$VERSION" > "$USERFILE"
   echo "Neue Version ($VERSION) gesendet"
fi