diff options
author | Damien Lallement <dams@mageia.org> | 2010-11-05 14:16:41 +0000 |
---|---|---|
committer | Damien Lallement <dams@mageia.org> | 2010-11-05 14:16:41 +0000 |
commit | 2272cb3cff69b65a3874b6abb4cfacb49b85ba84 (patch) | |
tree | 54d74eae254158e655cf554cff282fe83474dfe9 /modules/blog | |
parent | bf529770246e474fb6a280ab61741d69651334b5 (diff) | |
download | puppet-2272cb3cff69b65a3874b6abb4cfacb49b85ba84.tar puppet-2272cb3cff69b65a3874b6abb4cfacb49b85ba84.tar.gz puppet-2272cb3cff69b65a3874b6abb4cfacb49b85ba84.tar.bz2 puppet-2272cb3cff69b65a3874b6abb4cfacb49b85ba84.tar.xz puppet-2272cb3cff69b65a3874b6abb4cfacb49b85ba84.zip |
adding check_new-blog-post on champagne
Diffstat (limited to 'modules/blog')
-rw-r--r-- | modules/blog/manifests/init.pp | 24 | ||||
-rwxr-xr-x | modules/blog/templates/check_new-blog-post.sh | 32 |
2 files changed, 56 insertions, 0 deletions
diff --git a/modules/blog/manifests/init.pp b/modules/blog/manifests/init.pp new file mode 100644 index 00000000..d48acd23 --- /dev/null +++ b/modules/blog/manifests/init.pp @@ -0,0 +1,24 @@ +#TODO: add the creation of the user 'blog' in puppet +class blog { + package { 'wget': + ensure => installed + } + package { 'postfix': + ensure => installed + } + file { "check_new-blog-post": + path => "/home/blog/check_new-blog-post.sh", + ensure => present, + owner => blog, + group => blog, + mode => 755, + content => template("blog/check_new-blog-post.sh") + } + cron { blog: + user => blog, + hour => 0, + minute => 15, + command => "/home/blog/check_new-blog-post.sh", + require => File["check_new-blog-post"], + } +} diff --git a/modules/blog/templates/check_new-blog-post.sh b/modules/blog/templates/check_new-blog-post.sh new file mode 100755 index 00000000..1d55b137 --- /dev/null +++ b/modules/blog/templates/check_new-blog-post.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +# Initialization +PATH_TO_FILE="/home/blog" +/usr/bin/wget -qO $PATH_TO_FILE"/RSS_new" http://blog.mageia.org/?feed=rss2 +/bin/date +"%d:%m:%Y %H:%M" > $PATH_TO_FILE"/last_check" + +# Check if RSS_old exists +if [ ! -f $PATH_TO_FILE"/RSS_old" ] + then + /bin/cp $PATH_TO_FILE"/RSS_new" $PATH_TO_FILE"/RSS_old" + /bin/rm -rf $PATH_TO_FILE"/RSS_new" $PATH_TO_FILE"/last_check" + exit 1 +fi + +# 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 + echo "YES" >> $PATH_TO_FILE"/last_check" + echo "blablabla" /bin/mail -s "New entry on English Blog to translate" damien@damsweb.net + echo $DATE +fi + +# Clean tmp files and copy RSS_new to RSS_old +/bin/cp $PATH_TO_FILE"/RSS_new" $PATH_TO_FILE"/RSS_old" +/bin/rm -rf $PATH_TO_FILE"/RSS_new" |