aboutsummaryrefslogtreecommitdiffstats
path: root/modules/blog
diff options
context:
space:
mode:
Diffstat (limited to 'modules/blog')
-rw-r--r--modules/blog/manifests/init.pp54
-rwxr-xr-xmodules/blog/templates/backup_blog-files.sh7
-rw-r--r--modules/blog/templates/blogs_vhosts.conf2
-rwxr-xr-xmodules/blog/templates/check_new-blog-post.sh43
4 files changed, 57 insertions, 49 deletions
diff --git a/modules/blog/manifests/init.pp b/modules/blog/manifests/init.pp
index 585b5c16..c89a8168 100644
--- a/modules/blog/manifests/init.pp
+++ b/modules/blog/manifests/init.pp
@@ -1,9 +1,11 @@
class blog {
class base {
- $blog_domain = "blog.$::domain"
- $blog_location = "/var/www/vhosts/$blog_domain"
- $blog_db_backupdir = "/var/lib/backups/blog_db"
- $blog_files_backupdir = "/var/lib/backups/blog_files"
+ $blog_domain = "blog.${::domain}"
+ $blog_location = "/var/www/vhosts/${blog_domain}"
+ $blog_db_backupdir = '/var/lib/backups/blog_db'
+ $blog_files_backupdir = '/var/lib/backups/blog_files'
+ $blog_newpost_email_to = "i18n-reports@ml.${::domain}"
+ $blog_newpost_email_from = "Mageia Blog bot <blog@${::domain}>"
user { 'blog':
groups => apache,
@@ -11,13 +13,21 @@ class blog {
home => '/var/lib/blog',
}
}
-
+
class files_bots inherits base {
- package { ['php-mysql',
+if versioncmp($::lsbdistrelease, '9') < 0 {
+ package { ['php-mysqlnd',
+ 'php-ldap',
+ 'unzip',
+ 'nail']: }
+} else {
+ package { ['php-mysqlnd',
'php-ldap',
- 'unzip']: }
+ 'unzip',
+ 's-nail']: }
+}
- mga-common::local_script { 'check_new-blog-post.sh':
+ mga_common::local_script { 'check_new-blog-post.sh':
content => template('blog/check_new-blog-post.sh'),
}
@@ -25,27 +35,27 @@ class blog {
user => 'blog',
minute => '*/15',
command => '/usr/local/bin/check_new-blog-post.sh',
- require => Local_script['check_new-blog-post.sh'],
+ require => Mga_common::Local_script['check_new-blog-post.sh'],
}
include apache::mod::php
- apache::vhost::base { "$blog_domain":
+ apache::vhost::base { "${blog_domain}":
location => $blog_location,
- content => template('blog/blogs_vhosts.conf'),
+ content => template('blog/blogs_vhosts.conf'),
}
- apache::vhost::base { "ssl_$blog_domain":
- use_ssl => true,
- vhost => $blog_domain,
+ apache::vhost::base { "ssl_${blog_domain}":
+ use_ssl => true,
+ vhost => $blog_domain,
location => $blog_location,
- content => template('blog/blogs_vhosts.conf'),
+ content => template('blog/blogs_vhosts.conf'),
}
file { $blog_location:
- ensure => directory,
- owner => apache,
- group => apache,
+ ensure => directory,
+ owner => apache,
+ group => apache,
}
}
@@ -54,7 +64,7 @@ class blog {
ensure => directory,
}
- mga-common::local_script { 'backup_blog-db.sh':
+ mga_common::local_script { 'backup_blog-db.sh':
content => template('blog/backup_blog-db.sh'),
}
@@ -63,7 +73,7 @@ class blog {
hour => '23',
minute => '42',
command => '/usr/local/bin/backup_blog-db.sh',
- require => Local_script['backup_blog-db.sh'],
+ require => Mga_common::Local_script['backup_blog-db.sh'],
}
}
@@ -72,7 +82,7 @@ class blog {
ensure => directory,
}
- mga-common::local_script { 'backup_blog-files.sh':
+ mga_common::local_script { 'backup_blog-files.sh':
content => template('blog/backup_blog-files.sh'),
}
@@ -81,7 +91,7 @@ class blog {
hour => '23',
minute => '42',
command => '/usr/local/bin/backup_blog-files.sh',
- require => Local_script['backup_blog-files.sh'],
+ require => Mga_common::Local_script['backup_blog-files.sh'],
}
}
}
diff --git a/modules/blog/templates/backup_blog-files.sh b/modules/blog/templates/backup_blog-files.sh
index 3d66caa0..e268ad2b 100755
--- a/modules/blog/templates/backup_blog-files.sh
+++ b/modules/blog/templates/backup_blog-files.sh
@@ -1,17 +1,18 @@
-#!/bin/sh
+#!/bin/bash
# Initialization
PATH_TO_FILE=${PATH_TO_FILE:-<%= blog_files_backupdir %>}
[ ! -f $PATH_TO_FILE/count ] && echo 0 > $PATH_TO_FILE/count
COUNT=$(cat "$PATH_TO_FILE/count")
# Backup each locale
-for locale in de el en es fr it nl pl pt ro ru tr uk
+for locale in de el en es fr it nl pl pt ro ru sv tr uk
do
if [ ! -d $PATH_TO_FILE/$locale ]
then
/bin/mkdir $PATH_TO_FILE/$locale
fi
- tar Jcf $PATH_TO_FILE/$locale/$locale-$COUNT.tar.xz <%= blog_location %>/$locale
+ # use relative paths to avoid "Removing leading `/' from member names'" warning
+ tar -C / -Jcf "$PATH_TO_FILE/$locale/$locale-$COUNT.tar.xz" "$(sed s,^/,, <<< "<%= blog_location %>/$locale")"
done
# Check count file to have a week of backup in the directory
if [ $COUNT -ne 6 ]
diff --git a/modules/blog/templates/blogs_vhosts.conf b/modules/blog/templates/blogs_vhosts.conf
index 48b6d9ad..ff3c792f 100644
--- a/modules/blog/templates/blogs_vhosts.conf
+++ b/modules/blog/templates/blogs_vhosts.conf
@@ -2,7 +2,7 @@
Order deny,allow
Allow from All
AllowOverride All
- Options FollowSymlinks
+ Options FollowSymlinks
Options +Indexes
</Directory>
# Add a permanent redirection for 'pt' as it was 'pt-br' before
diff --git a/modules/blog/templates/check_new-blog-post.sh b/modules/blog/templates/check_new-blog-post.sh
index da142fd0..f2089a52 100755
--- a/modules/blog/templates/check_new-blog-post.sh
+++ b/modules/blog/templates/check_new-blog-post.sh
@@ -2,14 +2,15 @@
# Initialization
PATH_TO_FILE=${PATH_TO_FILE:-/var/lib/blog}
-/usr/bin/wget -qO $PATH_TO_FILE"/last_tmp" http://blog.mageia.org/en/?feed=rss2
-if [ $? -ne 0 ]
+/usr/bin/wget -qO $PATH_TO_FILE"/last_tmp" https://blog.mageia.org/en/?feed=rss2
+if [ $? -ne 0 ]
then
- exit 2
+ exit 2
fi
last_title=$(grep "title" $PATH_TO_FILE"/last_tmp" | head -n 2 | sed '1d' | sed 's/<title>//' | sed 's/<\/title>//' | sed 's/^[ \t]*//')
last_pub=$(grep "pubDate" $PATH_TO_FILE"/last_tmp" | head -n 1 | sed 's/<pubDate>//' | sed 's/<\/pubDate>//' | sed 's/^[ \t]*//')
-echo -e "$last_title\n$last_pub" > $PATH_TO_FILE"/last_tmp"
+last_creator=$(grep "creator" $PATH_TO_FILE"/last_tmp" | head -n 1 | sed 's/<dc:creator>//' | sed 's/<\/dc:creator>//' | sed 's/^[ \t]*//')
+echo -e "$last_title\n$last_pub\n$last_creator" > $PATH_TO_FILE"/last_tmp"
# Check if 'last_entry' exists
if [ ! -f $PATH_TO_FILE"/last_entry" ]
@@ -22,32 +23,28 @@ fi
/bin/date +"%d:%m:%Y %H:%M" > $PATH_TO_FILE"/last_check"
# Check if a new blog post on EN needs to be translated on other blogs
-tmp_new=$(cat $PATH_TO_FILE"/last_tmp" | sed '1d')
-tmp_old=$(cat $PATH_TO_FILE"/last_entry" | sed '1d')
+tmp_new=$(cat $PATH_TO_FILE"/last_tmp" | sed -n '1p')
+tmp_old=$(cat $PATH_TO_FILE"/last_entry" | sed -n '1p')
if [ "$tmp_old" = "$tmp_new" ]
then
# Nothing new
- echo "NO" >> $PATH_TO_FILE"/last_check"
- else
- tmp_new=$(cat $PATH_TO_FILE"/last_tmp" | sed '2d')
- tmp_old=$(cat $PATH_TO_FILE"/last_entry" | sed '2d')
- if [ "$tmp_old" = "$tmp_new" ]
+ tmp_new=$(cat $PATH_TO_FILE"/last_tmp" | sed -n '2p')
+ tmp_old=$(cat $PATH_TO_FILE"/last_entry" | sed -n '2p')
+ if [ "$tmp_old" != "$tmp_new" ]
then
- # Modification on last post
- cat $PATH_TO_FILE"/last_check" > $PATH_TO_FILE"/last_need_translation"
- echo $tmp_new >> $PATH_TO_FILE"/last_need_translation"
+ # Modification on latest post
echo "YES - Modification" >> $PATH_TO_FILE"/last_check"
- echo -e "Info: the last blog post had been modified and need to be checked.\nTitle: \"$tmp_new\"\n-- \nMail sent by the script '$0' on `hostname`" | /bin/mail -s "Modification of the last entry on English Blog" mageia-blogteam@<%= domain %>
+ 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 latest entry on English Blog" <%= blog_newpost_email_to %>
echo $DATE
else
- # New post to translate
- cat $PATH_TO_FILE"/last_check" > $PATH_TO_FILE"/last_need_translation"
- echo $tmp_new >> $PATH_TO_FILE"/last_need_translation"
- echo "YES - New entry" >> $PATH_TO_FILE"/last_check"
- echo -e "Info: a new blog post is waiting for translation.\nTitle: \"$tmp_new\"\n-- \nMail sent by the script '$0' on `hostname`" | /bin/mail -s "New entry on English Blog" mageia-blogteam@<%= domain %>
- echo $DATE
- fi
- fi
+ echo "NO" >> $PATH_TO_FILE"/last_check"
+ fi
+ else
+ # New post to translate
+ echo "YES - New entry" >> $PATH_TO_FILE"/last_check"
+ 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 %>
+ echo $DATE
+fi
# Clean tmp files and copy RSS_new to RSS_old
/bin/mv -f $PATH_TO_FILE"/last_tmp" $PATH_TO_FILE"/last_entry"