aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamien Lallement <dams@mageia.org>2011-01-19 01:30:40 +0000
committerDamien Lallement <dams@mageia.org>2011-01-19 01:30:40 +0000
commit5b4915fc66456fdea0daa138d2ca138cc1f5ea8b (patch)
tree565a8dde12e1a52a47716d26bc65a5ca2ff83e43
parentfb4ffa2874fd3215a76206d83d8a44b025ad6f20 (diff)
downloadpuppet-5b4915fc66456fdea0daa138d2ca138cc1f5ea8b.tar
puppet-5b4915fc66456fdea0daa138d2ca138cc1f5ea8b.tar.gz
puppet-5b4915fc66456fdea0daa138d2ca138cc1f5ea8b.tar.bz2
puppet-5b4915fc66456fdea0daa138d2ca138cc1f5ea8b.tar.xz
puppet-5b4915fc66456fdea0daa138d2ca138cc1f5ea8b.zip
now support 'new post' or 'modification of last post' to prevent bad notification mails
-rwxr-xr-xmodules/blog/templates/check_new-blog-post.sh46
1 files changed, 31 insertions, 15 deletions
diff --git a/modules/blog/templates/check_new-blog-post.sh b/modules/blog/templates/check_new-blog-post.sh
index 8efc94ab..695e7303 100755
--- a/modules/blog/templates/check_new-blog-post.sh
+++ b/modules/blog/templates/check_new-blog-post.sh
@@ -2,36 +2,52 @@
# 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
+/usr/bin/wget -qO $PATH_TO_FILE"/last_tmp" 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" ]
+last_title=$(grep "title" $PATH_TO_FILE"/last_tmp" | head -n 2 | sed '1d' | sed 's/<title>//' | sed 's/<\/title>//' | sed 's/^[ \t]*//')
+last_pub=$(grep "pubDate" $PATH_TO_FILE"/last_tmp" | head -n 1 | sed 's/<pubDate>//' | sed 's/<\/pubDate>//' | sed 's/^[ \t]*//')
+echo -e "$last_title\n$last_pub" > $PATH_TO_FILE"/last_tmp"
+
+# Check if 'last_entry' exists
+if [ ! -f $PATH_TO_FILE"/last_entry" ]
then
- /bin/mv -f $PATH_TO_FILE"/RSS_new" $PATH_TO_FILE"/RSS_old"
+ /bin/mv -f $PATH_TO_FILE"/last_tmp" $PATH_TO_FILE"/last_entry"
exit 1
fi
+# Add a date file for log
/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")
+tmp_new=$(cat $PATH_TO_FILE"/last_tmp" | sed '1d')
+tmp_old=$(cat $PATH_TO_FILE"/last_entry" | sed '1d')
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
+ tmp_new=$(cat $PATH_TO_FILE"/last_tmp" | sed '2d')
+ tmp_old=$(cat $PATH_TO_FILE"/last_entry" | sed '2d')
+ if [ "$tmp_old" = "$tmp_new" ]
+ then
+ # Modification on last post
+ cat $PATH_TO_FILE"/last_check" > $PATH_TO_FILE"/last_need_translation"
+ echo $tmp_new >> $PATH_TO_FILE"/last_need_translation"
+ echo "YES - Modification" >> $PATH_TO_FILE"/last_check"
+ echo -e "Info: the last blog post had been modified and need to be checked.\n\"$tmp_new\"" | /bin/mail -s "Modification of the last entry on English Blog" mageia-blogteam@mageia.org
+ echo $DATE
+ else
+ # New post to translate
+ cat $PATH_TO_FILE"/last_check" > $PATH_TO_FILE"/last_need_translation"
+ echo $tmp_new >> $PATH_TO_FILE"/last_need_translation"
+ echo "YES - New entry" >> $PATH_TO_FILE"/last_check"
+ echo -e "Info: a new blog post is waiting for translation.\n\"$tmp_new\"" | /bin/mail -s "New entry on English Blog" mageia-blogteam@mageia.org
+ echo $DATE
+ fi
+ fi
# Clean tmp files and copy RSS_new to RSS_old
-/bin/mv -f $PATH_TO_FILE"/RSS_new" $PATH_TO_FILE"/RSS_old"
+/bin/mv -f $PATH_TO_FILE"/last_tmp" $PATH_TO_FILE"/last_entry"