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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3048 - (show annotations) (download) (as text)
Tue Apr 16 13:56:45 2013 UTC (11 years ago) by boklm
File MIME type: application/x-sh
File size: 2243 byte(s)
blog: add variables to set blog emails
1 #!/bin/sh
2
3 # Initialization
4 PATH_TO_FILE=${PATH_TO_FILE:-/var/lib/blog}
5 /usr/bin/wget -qO $PATH_TO_FILE"/last_tmp" http://blog.mageia.org/en/?feed=rss2
6 if [ $? -ne 0 ]
7 then
8 exit 2
9 fi
10 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 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
15 # Check if 'last_entry' exists
16 if [ ! -f $PATH_TO_FILE"/last_entry" ]
17 then
18 /bin/mv -f $PATH_TO_FILE"/last_tmp" $PATH_TO_FILE"/last_entry"
19 exit 1
20 fi
21
22 # Add a date file for log
23 /bin/date +"%d:%m:%Y %H:%M" > $PATH_TO_FILE"/last_check"
24
25 # Check if a new blog post on EN needs to be translated on other blogs
26 tmp_new=$(cat $PATH_TO_FILE"/last_tmp" | sed -n '1p')
27 tmp_old=$(cat $PATH_TO_FILE"/last_entry" | sed -n '1p')
28 if [ "$tmp_old" = "$tmp_new" ]
29 then
30 # Nothing new
31 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 then
35 # Modification on lastest post
36 echo "YES - Modification" >> $PATH_TO_FILE"/last_check"
37 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 echo $DATE
39 else
40 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 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 echo $DATE
47 fi
48
49 # Clean tmp files and copy RSS_new to RSS_old
50 /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.30