Идеята е, че трябва да се обновят 10 блога на WordPress и то бързичко с идеята при следващ ъпдейт да става лесно.
Понеже системата е писана на php реших и скриптчет ода бъде на php . Ето го и него:
<?php
#############################################
$wordpress_root_dirs=array(
"/var/www/sait1.com/",
"/var/www/sait2.com/",
"/var/www/sait3.com/",
"/var/www/sait4.com/",
"/var/www/sait5.com/",
"/var/www/sait6.com/",
"/var/www/sait7.com/",
"/var/www/sait8.com/",
"/var/www/sait9.com/",
"/var/www/sait10.com/"
);
$BDIR="/tmp/backup_upgraded_wordpress";
$NDIR="$BDIR/latest_wordpress_files";
#############################################
function dhs_lr_str($a,$b,$c){$a=explode("$a",$c);$b=explode("$b",$a[1]);return addslashes(trim($b[0]));};
$count_wp_blogs=count($wordpress_root_dirs)-1;
@system("mkdir -p $NDIR");
chdir("$NDIR");
echo "
###########################################################################
######## Mass Wordpress Updater ver. 0.1 by amri -- www.mpetrov.net ########
###########################################################################
\n";
echo "Downloading Latest WordPress … \n";
system("wget -q http://wordpress.org/latest.zip -O $NDIR/latest.zip");
system("unzip -o -q $NDIR/latest.zip");
$count_upd_wp=0;
foreach ($wordpress_root_dirs as $RDIR)
{
$count_upd_wp++;
echo "Update Wordpress blogs $count_upd_wp/$count_wp_blogs\n";
$buf=file_get_contents("$RDIR/wp-config.php");
$DB_NAME=trim(dhs_lr_str("define('DB_NAME', '","'",$buf));
$DB_USER=trim(dhs_lr_str("define('DB_USER', '","'",$buf));
$DB_PASSWORD=trim(dhs_lr_str("define('DB_PASSWORD', '","'",$buf));
$DB_HOST=trim(dhs_lr_str("define('DB_HOST', '","'",$buf));
$DB_TABLE=trim(dhs_lr_str('$table_prefix = \","'",$buf));
$WDIR="$BDIR/$DB_NAME";
@system("mkdir -p $WDIR");
chdir("$WDIR");
echo "Backup Old WordPress ($RDIR) DB: $DB_NAME\n";
system("mysqldump -u$DB_USER -p$DB_PASSWORD $DB_NAME > $WDIR/$DB_NAME.sql");
echo "Backup Old WordPress ($RDIR) Files\n";
system("cp -Rp $RDIR/ $WDIR/wordress_files/");
echo "Replace Old WordPress($RDIR) Files\n";
system("cp -ar $NDIR/wordpress/* $RDIR/");
mysql_connect($DB_HOST,$DB_USER,$DB_PASSWORD);mysql_select_db($DB_NAME);
$result = mysql_query("select option_value from ".$DB_TABLE."options where option_name='siteurl'");
$row = mysql_fetch_array($result);
$siteurl=stripslashes($row['option_value']);
$ch1=curl_init();
curl_setopt($ch1,CURLOPT_URL,"$siteurl/wp-admin/upgrade.php?step=1&backto=");
curl_setopt($ch1,CURLOPT_RETURNTRANSFER,1);
$buf=curl_exec($ch1);
curl_close($ch1);
};
?>