Wordpress ha resultado siendo un verdadero dolor de cabeza en las últimas semanas. He tenido que limpiar algunos sitios de clientes que han sido hackeados. No actualizar a tiempo un sitio wordpress es una invitación para que inserten links de viagra o malware en el contenido del sitio. Estoy tratando de crear unos cron jobs que revisen si hay sitios desactualizados en mi servidor y si es posible que se actualizen automaticamente. No es tan sencillo porque a veces instalan plugins y pueden dejar de funcionar. Mi idea es usar svn para descargar la ultima version estable de wordpress desde el repositorio. y luego actualizar el sitio descargando las nuevas revisiones. Hice un pequeño script en python que chequea la ultima version de Wordpress en wordpress.org y la descarga a la carpeta desde la que se invoca el script. Aca les comparto el código del script.
#!/usr/bin/python
#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program. If not, see .
import commands
import sys
import os
import os.path
import inspect
from pyquery import PyQuery as pq
import string
#check the current folder and ask the user if wants to download wordpress there
site_dir = commands.getoutput("pwd")
print "site root folder is: " + site_dir + ".? [y/n]"
sys.stdout.flush()
val = raw_input()
if val == "y":
# check wordpress.org frontpage and extract the latest version number from download button
d = pq(url='http://wordpress.org/')
wp_version_button = d("a.download-button").text();
wp_version = "";
for letter in wp_version_button:
if letter.isdigit() or letter == ".":
wp_version += letter;
print "current Wordpress version: " + wp_version;
#check if wordpress is already installed
if os.path.isdir(site_dir + "/wp-content"):
print "Wordpress is already installed";
else:
# download latest wordpress version
os.system('svn co http://core.svn.wordpress.org/tags/' + wp_version + ' "' + site_dir + '/wordpress_svn"');
os.system('mv ' + site_dir + '/wordpress_svn/* ' + site_dir + '/');
os.system('mv ' + site_dir + '/wordpress_svn/.svn ' + site_dir + '/');
os.system('rmdir "' + site_dir + '/wordpress_svn"');
Espero hacerle unas mejoras despues para que actualize automaticamente wordpress cuando salga una nueva versión.