Import initial
bn8

bn8 commited on 2010-05-11 07:48:45
Showing 1 changed files, with 48 additions and 0 deletions.

... ...
@@ -0,0 +1,48 @@
1
+#!/bin/bash
2
+
3
+MAIL=root
4
+TIME=7
5
+CACHE=/var/www/webmail/.cache_check_upgrade
6
+
7
+DEBUG=0
8
+[ "$1" == "-v" ] && DEBUG=1
9
+
10
+current=`egrep "define.*RCMAIL_VERSION" /var/www/webmail/public_html/program/include/iniset.php|sed "s/define('.*', '\([^']*\)'.*$/\1/"`
11
+[ $DEBUG -eq 1 ] && echo "Current : $current"
12
+
13
+newest=`wget -q http://www.roundcube.net/download -O - |grep Stable|sed 's/^.*Stable.*: \(.*\)<\/td>.*$/\1/'`
14
+[ $DEBUG -eq 1 ] && echo "Newest : $newest"
15
+
16
+
17
+if [ "$newest" != "$current" ]
18
+then
19
+	tmp=`mktemp`
20
+	echo "New RoundCude release" > $tmp
21
+	echo "=====================" >> $tmp
22
+	echo "Current : $current" >> $tmp
23
+	echo "Newest : $newest" >> $tmp
24
+	
25
+	M=0
26
+	if [ -f $CACHE ]
27
+	then
28
+		if [ "`diff $tmp $CACHE`" != "" -o `find $CACHE -mtime +$TIME | wc -l` -eq 1 ]
29
+		then
30
+			[ $DEBUG -eq 1 ] && echo "Cache trop vieux ou modif => On envoi"
31
+			M=1
32
+		else
33
+			[ $DEBUG -eq 1 ] && echo "Pas de modif et cache trop recent : pas d'envoi"
34
+		fi
35
+	else
36
+		[ $DEBUG -eq 1 ] && echo "Pas encore de cache => On envoi"
37
+		M=1
38
+	fi
39
+	if [ $M -eq 1 ]
40
+	then
41
+		cat $tmp > $CACHE
42
+		cat $tmp | mail -s "New RoundCude release : $newest" $MAIL
43
+		[ $DEBUG -eq 1 ] && echo "Mail envoyé"
44
+	fi
45
+	rm -f $tmp
46
+else
47
+	[ $DEBUG -eq 1 ] && echo "Pas de changement de version"
48
+fi
0 49