The PHP script is rather simple. If you look at it, it basically defines which database, db user, db password, db server, etc. and then it runs WordPress'
wp_upgrade()
function. That simple! Honestly, the hardest part (for me at least) was figuring which WordPress files I needed to include and what order they go in! (In the beginning, I traversed the order of my require
statements. Doh!)
\<\?php //this gets hosed by blogger so i'm trying to "escape" it
if ($argc != 2) {
print "Usage: php $argv[0] [wpdb]\n";
exit;
}
$db = $argv[1];
define( 'ABSPATH', dirname(__FILE__) . '/' );
define('WP_ADMIN', true);
define('DB_NAME', $db);
define('DB_USER', 'wpuser'); // Your MySQL username
define('DB_PASSWORD', 'wppass'); // ...and password
define('DB_HOST', 'mysql.server.com'); // 99% chance you won't need to change this value
require('wp-load.php');
require('wp-admin/includes/upgrade.php');
print "Upgrading " . DB_NAME . "...\n";
wp_upgrade();
print "\n\nUpgrade for " . DB_NAME . " complete!\n";
?>
Now as you can see, I set up my PHP script to handle the database name as an argument. So now, all I need to do is write a bash wrapper script! I haven't done it yet, but it'll basically be similar to this:
for db in `cat listofdbs.txt`; do php ajc-wpupgrade.php $db; done;
And Bob's your uncle!
No comments:
Post a Comment