diff options
author | Damien Lallement <dams@mageia.org> | 2013-03-06 19:59:50 +0000 |
---|---|---|
committer | Damien Lallement <dams@mageia.org> | 2013-03-06 19:59:50 +0000 |
commit | 8405fcfa64d83c393bf9bcbe28f59453ea4b1aba (patch) | |
tree | 061d2123033c509263afe4031f29a05fb2b7a003 /modules/blog | |
parent | 69211a86ac4611065b734d1f31fe4e9e8d6d2cac (diff) | |
download | puppet-8405fcfa64d83c393bf9bcbe28f59453ea4b1aba.tar puppet-8405fcfa64d83c393bf9bcbe28f59453ea4b1aba.tar.gz puppet-8405fcfa64d83c393bf9bcbe28f59453ea4b1aba.tar.bz2 puppet-8405fcfa64d83c393bf9bcbe28f59453ea4b1aba.tar.xz puppet-8405fcfa64d83c393bf9bcbe28f59453ea4b1aba.zip |
- Fix sending empty mail
- Fix 'from'/'reply-to'
- Update mail content
- Fix warning detection about new post or updated post
Diffstat (limited to 'modules/blog')
-rwxr-xr-x | modules/blog/templates/check_new-blog-post.sh | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/modules/blog/templates/check_new-blog-post.sh b/modules/blog/templates/check_new-blog-post.sh index da142fd0..3f9d9755 100755 --- a/modules/blog/templates/check_new-blog-post.sh +++ b/modules/blog/templates/check_new-blog-post.sh @@ -5,11 +5,12 @@ PATH_TO_FILE=${PATH_TO_FILE:-/var/lib/blog} /usr/bin/wget -qO $PATH_TO_FILE"/last_tmp" http://blog.mageia.org/en/?feed=rss2 if [ $? -ne 0 ] then - exit 2 + exit 2 fi 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" +last_creator=$(grep "creator" $PATH_TO_FILE"/last_tmp" | head -n 1 | sed 's/<dc:creator>//' | sed 's/<\/dc:creator>//' | sed 's/^[ \t]*//') +echo -e "$last_title\n$last_pub\n$last_creator" > $PATH_TO_FILE"/last_tmp" # Check if 'last_entry' exists if [ ! -f $PATH_TO_FILE"/last_entry" ] @@ -22,32 +23,28 @@ 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=$(cat $PATH_TO_FILE"/last_tmp" | sed '1d') -tmp_old=$(cat $PATH_TO_FILE"/last_entry" | sed '1d') +tmp_new=$(cat $PATH_TO_FILE"/last_tmp" | sed -n '1p') +tmp_old=$(cat $PATH_TO_FILE"/last_entry" | sed -n '1p') if [ "$tmp_old" = "$tmp_new" ] then # Nothing new - echo "NO" >> $PATH_TO_FILE"/last_check" - else - 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" ] + tmp_new=$(cat $PATH_TO_FILE"/last_tmp" | sed -n '2p') + tmp_old=$(cat $PATH_TO_FILE"/last_entry" | sed -n '2p') + 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" + # Modification on lastest post echo "YES - Modification" >> $PATH_TO_FILE"/last_check" - echo -e "Info: the last blog post had been modified and need to be checked.\nTitle: \"$tmp_new\"\n-- \nMail sent by the script '$0' on `hostname`" | /bin/mail -s "Modification of the last entry on English Blog" mageia-blogteam@<%= domain %> + echo -e "The latest blog post has been modified and needs to be checked!\n\nTitle:\t$last_title\nAuthor:\t$last_creator\n-- \nMail sent by the script '$0' on `hostname`" | /bin/mail -r "Mageia Blog bot <mageia-blogteam@<%= domain %>>" -s "Modification of the lastest entry on English Blog" mageia-blogteam@<%= domain %> 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.\nTitle: \"$tmp_new\"\n-- \nMail sent by the script '$0' on `hostname`" | /bin/mail -s "New entry on English Blog" mageia-blogteam@<%= domain %> - echo $DATE - fi - fi + echo "NO" >> $PATH_TO_FILE"/last_check" + fi + else + # New post to translate + echo "YES - New entry" >> $PATH_TO_FILE"/last_check" + echo -e "A new blog post is waiting for translation:\n\nTitle:\t$last_title\nAuthor:\t$last_creator\n-- \nMail sent by the script '$0' on `hostname`" | /bin/mail -r "Mageia Blog bot <mageia-blogteam@<%= domain %>>" -s "New entry on English Blog" mageia-blogteam@<%= domain %> + echo $DATE +fi # Clean tmp files and copy RSS_new to RSS_old /bin/mv -f $PATH_TO_FILE"/last_tmp" $PATH_TO_FILE"/last_entry" |