[Mageia-sysadm] [143] adding check_new-blog-post on champagne

root at mageia.org root at mageia.org
Fri Nov 5 15:16:41 CET 2010


Revision: 143
Author:   dams
Date:     2010-11-05 15:16:41 +0100 (Fri, 05 Nov 2010)
Log Message:
-----------
adding check_new-blog-post on champagne

Modified Paths:
--------------
    puppet/manifests/nodes.pp

Added Paths:
-----------
    puppet/modules/blog/
    puppet/modules/blog/manifests/
    puppet/modules/blog/manifests/init.pp
    puppet/modules/blog/templates/
    puppet/modules/blog/templates/check_new-blog-post.sh

Modified: puppet/manifests/nodes.pp
===================================================================
--- puppet/manifests/nodes.pp	2010-11-05 13:03:26 UTC (rev 142)
+++ puppet/manifests/nodes.pp	2010-11-05 14:16:41 UTC (rev 143)
@@ -125,6 +125,8 @@
 #
 	include default_mageia_server
     include apache::base
+    #include postfix
+    include blog
 }
 
 

Added: puppet/modules/blog/manifests/init.pp
===================================================================
--- puppet/modules/blog/manifests/init.pp	                        (rev 0)
+++ puppet/modules/blog/manifests/init.pp	2010-11-05 14:16:41 UTC (rev 143)
@@ -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"],
+    	}
+}

Added: puppet/modules/blog/templates/check_new-blog-post.sh
===================================================================
--- puppet/modules/blog/templates/check_new-blog-post.sh	                        (rev 0)
+++ puppet/modules/blog/templates/check_new-blog-post.sh	2010-11-05 14:16:41 UTC (rev 143)
@@ -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 at 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"


Property changes on: puppet/modules/blog/templates/check_new-blog-post.sh
___________________________________________________________________
Added: svn:executable
   + *
Added: svn:eol-style
   + native
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/mageia-sysadm/attachments/20101105/54824d95/attachment.html>


More information about the Mageia-sysadm mailing list