summaryrefslogtreecommitdiffstats
path: root/zarb-ml/mageia-sysadm/2011-January/002243.html
blob: 07af4b699670f435e861f390e60776079d9c2187 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
 <HEAD>
   <TITLE> [Mageia-sysadm] [856] now support 'new post' or 'modification of last post' to prevent bad notification mails
   </TITLE>
   <LINK REL="Index" HREF="index.html" >
   <LINK REL="made" HREF="mailto:mageia-sysadm%40mageia.org?Subject=Re%3A%20%5BMageia-sysadm%5D%20%5B856%5D%20now%20support%20%27new%20post%27%20or%20%27modification%20of%0A%20last%20post%27%20to%20prevent%20bad%20notification%20mails&In-Reply-To=%3C20110119013040.B0CC742999%40valstar.mageia.org%3E">
   <META NAME="robots" CONTENT="index,nofollow">
   <META http-equiv="Content-Type" content="text/html; charset=us-ascii">
   <LINK REL="Previous"  HREF="002238.html">
   <LINK REL="Next"  HREF="002245.html">
 </HEAD>
 <BODY BGCOLOR="#ffffff">
   <H1>[Mageia-sysadm] [856] now support 'new post' or 'modification of last post' to prevent bad notification mails</H1>
    <B>root at mageia.org</B> 
    <A HREF="mailto:mageia-sysadm%40mageia.org?Subject=Re%3A%20%5BMageia-sysadm%5D%20%5B856%5D%20now%20support%20%27new%20post%27%20or%20%27modification%20of%0A%20last%20post%27%20to%20prevent%20bad%20notification%20mails&In-Reply-To=%3C20110119013040.B0CC742999%40valstar.mageia.org%3E"
       TITLE="[Mageia-sysadm] [856] now support 'new post' or 'modification of last post' to prevent bad notification mails">root at mageia.org
       </A><BR>
    <I>Wed Jan 19 02:30:40 CET 2011</I>
    <P><UL>
        <LI>Previous message: <A HREF="002238.html">[Mageia-sysadm] [855] fix group/user
</A></li>
        <LI>Next message: <A HREF="002245.html">[Mageia-sysadm] [857] use service name rather than hostname
</A></li>
         <LI> <B>Messages sorted by:</B> 
              <a href="date.html#2243">[ date ]</a>
              <a href="thread.html#2243">[ thread ]</a>
              <a href="subject.html#2243">[ subject ]</a>
              <a href="author.html#2243">[ author ]</a>
         </LI>
       </UL>
    <HR>  
<!--beginarticle-->
<PRE>Revision: 856
Author:   dams
Date:     2011-01-19 02:30:40 +0100 (Wed, 19 Jan 2011)
Log Message:
-----------
now support 'new post' or 'modification of last post' to prevent bad notification mails

Modified Paths:
--------------
    puppet/modules/blog/templates/check_new-blog-post.sh

Modified: puppet/modules/blog/templates/check_new-blog-post.sh
===================================================================
--- puppet/modules/blog/templates/check_new-blog-post.sh	2011-01-18 23:08:26 UTC (rev 855)
+++ puppet/modules/blog/templates/check_new-blog-post.sh	2011-01-19 01:30:40 UTC (rev 856)
@@ -2,36 +2,52 @@
 
 # Initialization
 PATH_TO_FILE=${PATH_TO_FILE:-/var/lib/blog}
-/usr/bin/wget -qO $PATH_TO_FILE&quot;/RSS_new&quot; <A HREF="http://blog.mageia.org/?feed=rss2">http://blog.mageia.org/?feed=rss2</A>
+/usr/bin/wget -qO $PATH_TO_FILE&quot;/last_tmp&quot; <A HREF="http://blog.mageia.org/?feed=rss2">http://blog.mageia.org/?feed=rss2</A>
 if [ $? -ne 0 ] 
 then
         exit 2
 fi
-# Check if RSS_old exists
-if [ ! -f $PATH_TO_FILE&quot;/RSS_old&quot; ]
+last_title=$(grep &quot;title&quot; $PATH_TO_FILE&quot;/last_tmp&quot; | head -n 2 | sed '1d' | sed 's/&lt;title&gt;//' | sed 's/&lt;\/title&gt;//' | sed 's/^[ \t]*//')
+last_pub=$(grep &quot;pubDate&quot; $PATH_TO_FILE&quot;/last_tmp&quot; | head -n 1 | sed 's/&lt;pubDate&gt;//' | sed 's/&lt;\/pubDate&gt;//' | sed 's/^[ \t]*//')
+echo -e &quot;$last_title\n$last_pub&quot; &gt; $PATH_TO_FILE&quot;/last_tmp&quot;
+
+# Check if 'last_entry' exists
+if [ ! -f $PATH_TO_FILE&quot;/last_entry&quot; ]
 	then
-		/bin/mv -f $PATH_TO_FILE&quot;/RSS_new&quot; $PATH_TO_FILE&quot;/RSS_old&quot;
+		/bin/mv -f $PATH_TO_FILE&quot;/last_tmp&quot; $PATH_TO_FILE&quot;/last_entry&quot;
 		exit 1
 fi
 
+# Add a date file for log
 /bin/date +&quot;%d:%m:%Y %H:%M&quot; &gt; $PATH_TO_FILE&quot;/last_check&quot;
 
 # Check if a new blog post on EN needs to be translated on other blogs
-tmp_new=$(/bin/grep 'lastBuildDate' $PATH_TO_FILE&quot;/RSS_new&quot;)
-tmp_old=$(/bin/grep 'lastBuildDate' $PATH_TO_FILE&quot;/RSS_old&quot;)
+tmp_new=$(cat $PATH_TO_FILE&quot;/last_tmp&quot; | sed '1d')
+tmp_old=$(cat $PATH_TO_FILE&quot;/last_entry&quot; | sed '1d')
 if [ &quot;$tmp_old&quot; = &quot;$tmp_new&quot; ]
 	then
 		# Nothing new
 		echo &quot;NO&quot; &gt;&gt; $PATH_TO_FILE&quot;/last_check&quot;
 	else
-		# New post to translate
-		cat $PATH_TO_FILE&quot;/last_check&quot; &gt; $PATH_TO_FILE&quot;/last_need_translation&quot;
-		new_post=$(grep &quot;title&quot; $PATH_TO_FILE&quot;/RSS_new&quot; | head -n 2 | sed '1d' | sed 's/&lt;title&gt;//' | sed 's/&lt;\/title&gt;//' | sed 's/^[ \t]*//')
-		echo $new_post &gt;&gt; $PATH_TO_FILE&quot;/last_need_translation&quot;
-		echo &quot;YES&quot; &gt;&gt; $PATH_TO_FILE&quot;/last_check&quot;
-		echo -e &quot;A new blog post is waiting for translation\n\&quot;$new_post\&quot;&quot; | /bin/mail -s &quot;New entry on English Blog&quot; <A HREF="https://www.mageia.org/mailman/listinfo/mageia-sysadm">mageia-blogteam at mageia.org</A>
-		echo $DATE
-fi
+		tmp_new=$(cat $PATH_TO_FILE&quot;/last_tmp&quot; | sed '2d')
+		tmp_old=$(cat $PATH_TO_FILE&quot;/last_entry&quot; | sed '2d')
+		if [ &quot;$tmp_old&quot; = &quot;$tmp_new&quot; ]
+			then 
+				# Modification on last post
+				cat $PATH_TO_FILE&quot;/last_check&quot; &gt; $PATH_TO_FILE&quot;/last_need_translation&quot;
+				echo $tmp_new &gt;&gt; $PATH_TO_FILE&quot;/last_need_translation&quot;
+				echo &quot;YES - Modification&quot; &gt;&gt; $PATH_TO_FILE&quot;/last_check&quot;
+				echo -e &quot;Info: the last blog post had been modified and need to be checked.\n\&quot;$tmp_new\&quot;&quot; | /bin/mail -s &quot;Modification of the last entry on English Blog&quot; <A HREF="https://www.mageia.org/mailman/listinfo/mageia-sysadm">mageia-blogteam at mageia.org</A>
+				echo $DATE
+			else
+				# New post to translate
+				cat $PATH_TO_FILE&quot;/last_check&quot; &gt; $PATH_TO_FILE&quot;/last_need_translation&quot;
+				echo $tmp_new &gt;&gt; $PATH_TO_FILE&quot;/last_need_translation&quot;
+				echo &quot;YES - New entry&quot; &gt;&gt; $PATH_TO_FILE&quot;/last_check&quot;
+				echo -e &quot;Info: a new blog post is waiting for translation.\n\&quot;$tmp_new\&quot;&quot; | /bin/mail -s &quot;New entry on English Blog&quot; <A HREF="https://www.mageia.org/mailman/listinfo/mageia-sysadm">mageia-blogteam at mageia.org</A>
+				echo $DATE
+			fi
+	fi
 
 # Clean tmp files and copy RSS_new to RSS_old
-/bin/mv -f $PATH_TO_FILE&quot;/RSS_new&quot; $PATH_TO_FILE&quot;/RSS_old&quot;
+/bin/mv -f $PATH_TO_FILE&quot;/last_tmp&quot; $PATH_TO_FILE&quot;/last_entry&quot;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: &lt;/pipermail/mageia-sysadm/attachments/20110119/32a9dd13/attachment.html&gt;
</PRE>










<!--endarticle-->
    <HR>
    <P><UL>
        <!--threads-->
	<LI>Previous message: <A HREF="002238.html">[Mageia-sysadm] [855] fix group/user
</A></li>
	<LI>Next message: <A HREF="002245.html">[Mageia-sysadm] [857] use service name rather than hostname
</A></li>
         <LI> <B>Messages sorted by:</B> 
              <a href="date.html#2243">[ date ]</a>
              <a href="thread.html#2243">[ thread ]</a>
              <a href="subject.html#2243">[ subject ]</a>
              <a href="author.html#2243">[ author ]</a>
         </LI>
       </UL>

<hr>
<a href="https://www.mageia.org/mailman/listinfo/mageia-sysadm">More information about the Mageia-sysadm
mailing list</a><br>
</body></html>