From 1cec8ada0ce051e418c1cc9762e66f5bc365a680 Mon Sep 17 00:00:00 2001 From: bn8 Date: Tue, 11 May 2010 09:48:45 +0200 Subject: [PATCH] Import initial --- check_rc_upgrade.sh | 48 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100755 check_rc_upgrade.sh diff --git a/check_rc_upgrade.sh b/check_rc_upgrade.sh new file mode 100755 index 0000000..82ef7cc --- /dev/null +++ b/check_rc_upgrade.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +MAIL=root +TIME=7 +CACHE=/var/www/webmail/.cache_check_upgrade + +DEBUG=0 +[ "$1" == "-v" ] && DEBUG=1 + +current=`egrep "define.*RCMAIL_VERSION" /var/www/webmail/public_html/program/include/iniset.php|sed "s/define('.*', '\([^']*\)'.*$/\1/"` +[ $DEBUG -eq 1 ] && echo "Current : $current" + +newest=`wget -q http://www.roundcube.net/download -O - |grep Stable|sed 's/^.*Stable.*: \(.*\)<\/td>.*$/\1/'` +[ $DEBUG -eq 1 ] && echo "Newest : $newest" + + +if [ "$newest" != "$current" ] +then + tmp=`mktemp` + echo "New RoundCude release" > $tmp + echo "=====================" >> $tmp + echo "Current : $current" >> $tmp + echo "Newest : $newest" >> $tmp + + M=0 + if [ -f $CACHE ] + then + if [ "`diff $tmp $CACHE`" != "" -o `find $CACHE -mtime +$TIME | wc -l` -eq 1 ] + then + [ $DEBUG -eq 1 ] && echo "Cache trop vieux ou modif => On envoi" + M=1 + else + [ $DEBUG -eq 1 ] && echo "Pas de modif et cache trop recent : pas d'envoi" + fi + else + [ $DEBUG -eq 1 ] && echo "Pas encore de cache => On envoi" + M=1 + fi + if [ $M -eq 1 ] + then + cat $tmp > $CACHE + cat $tmp | mail -s "New RoundCude release : $newest" $MAIL + [ $DEBUG -eq 1 ] && echo "Mail envoyé" + fi + rm -f $tmp +else + [ $DEBUG -eq 1 ] && echo "Pas de changement de version" +fi