blob: 8efc94ab785a129352082e5a640784e8579d7517 (
plain)
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
|
#!/bin/sh
# Initialization
PATH_TO_FILE=${PATH_TO_FILE:-/var/lib/blog}
/usr/bin/wget -qO $PATH_TO_FILE"/RSS_new" http://blog.mageia.org/?feed=rss2
if [ $? -ne 0 ]
then
exit 2
fi
# Check if RSS_old exists
if [ ! -f $PATH_TO_FILE"/RSS_old" ]
then
/bin/mv -f $PATH_TO_FILE"/RSS_new" $PATH_TO_FILE"/RSS_old"
exit 1
fi
/bin/date +"%d:%m:%Y %H:%M" > $PATH_TO_FILE"/last_check"
# Check if a new blog post on EN needs to be translated on other blogs
tmp_new=$(/bin/grep 'lastBuildDate' $PATH_TO_FILE"/RSS_new")
tmp_old=$(/bin/grep 'lastBuildDate' $PATH_TO_FILE"/RSS_old")
if [ "$tmp_old" = "$tmp_new" ]
then
# Nothing new
echo "NO" >> $PATH_TO_FILE"/last_check"
else
# New post to translate
cat $PATH_TO_FILE"/last_check" > $PATH_TO_FILE"/last_need_translation"
new_post=$(grep "title" $PATH_TO_FILE"/RSS_new" | head -n 2 | sed '1d' | sed 's/<title>//' | sed 's/<\/title>//' | sed 's/^[ \t]*//')
echo $new_post >> $PATH_TO_FILE"/last_need_translation"
echo "YES" >> $PATH_TO_FILE"/last_check"
echo -e "A new blog post is waiting for translation\n\"$new_post\"" | /bin/mail -s "New entry on English Blog" mageia-blogteam@mageia.org
echo $DATE
fi
# Clean tmp files and copy RSS_new to RSS_old
/bin/mv -f $PATH_TO_FILE"/RSS_new" $PATH_TO_FILE"/RSS_old"
|