/[adm]/puppet/modules/blog/templates/check_new-blog-post.sh
ViewVC logotype

Annotation of /puppet/modules/blog/templates/check_new-blog-post.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3048 - (hide annotations) (download) (as text)
Tue Apr 16 13:56:45 2013 UTC (10 years, 7 months ago) by boklm
File MIME type: application/x-sh
File size: 2243 byte(s)
blog: add variables to set blog emails
1 dams 143 #!/bin/sh
2    
3     # Initialization
4 misc 338 PATH_TO_FILE=${PATH_TO_FILE:-/var/lib/blog}
5 dams 1274 /usr/bin/wget -qO $PATH_TO_FILE"/last_tmp" http://blog.mageia.org/en/?feed=rss2
6 dams 481 if [ $? -ne 0 ]
7 misc 338 then
8 dams 3019 exit 2
9 misc 338 fi
10 dams 856 last_title=$(grep "title" $PATH_TO_FILE"/last_tmp" | head -n 2 | sed '1d' | sed 's/<title>//' | sed 's/<\/title>//' | sed 's/^[ \t]*//')
11     last_pub=$(grep "pubDate" $PATH_TO_FILE"/last_tmp" | head -n 1 | sed 's/<pubDate>//' | sed 's/<\/pubDate>//' | sed 's/^[ \t]*//')
12 dams 3019 last_creator=$(grep "creator" $PATH_TO_FILE"/last_tmp" | head -n 1 | sed 's/<dc:creator>//' | sed 's/<\/dc:creator>//' | sed 's/^[ \t]*//')
13     echo -e "$last_title\n$last_pub\n$last_creator" > $PATH_TO_FILE"/last_tmp"
14 dams 856
15     # Check if 'last_entry' exists
16     if [ ! -f $PATH_TO_FILE"/last_entry" ]
17 dams 143 then
18 dams 856 /bin/mv -f $PATH_TO_FILE"/last_tmp" $PATH_TO_FILE"/last_entry"
19 dams 143 exit 1
20     fi
21    
22 dams 856 # Add a date file for log
23 misc 165 /bin/date +"%d:%m:%Y %H:%M" > $PATH_TO_FILE"/last_check"
24    
25 dams 143 # Check if a new blog post on EN needs to be translated on other blogs
26 dams 3019 tmp_new=$(cat $PATH_TO_FILE"/last_tmp" | sed -n '1p')
27     tmp_old=$(cat $PATH_TO_FILE"/last_entry" | sed -n '1p')
28 dams 143 if [ "$tmp_old" = "$tmp_new" ]
29     then
30     # Nothing new
31 dams 3019 tmp_new=$(cat $PATH_TO_FILE"/last_tmp" | sed -n '2p')
32     tmp_old=$(cat $PATH_TO_FILE"/last_entry" | sed -n '2p')
33     if [ "$tmp_old" != "$tmp_new" ]
34 dams 856 then
35 dams 3019 # Modification on lastest post
36 dams 856 echo "YES - Modification" >> $PATH_TO_FILE"/last_check"
37 boklm 3048 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 '<%= blog_newpost_email_from %>' -s "Modification of the lastest entry on English Blog" <%= blog_newpost_email_to %>
38 dams 856 echo $DATE
39     else
40 dams 3019 echo "NO" >> $PATH_TO_FILE"/last_check"
41     fi
42     else
43     # New post to translate
44     echo "YES - New entry" >> $PATH_TO_FILE"/last_check"
45 boklm 3048 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 '<%= blog_newpost_email_from %>' -s "New entry on English Blog" <%= blog_newpost_email_to %>
46 dams 3019 echo $DATE
47     fi
48 dams 143
49     # Clean tmp files and copy RSS_new to RSS_old
50 dams 856 /bin/mv -f $PATH_TO_FILE"/last_tmp" $PATH_TO_FILE"/last_entry"

Properties

Name Value
svn:eol-style native
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.28