Created
October 16, 2012 13:05
-
-
Save simme/3899147 to your computer and use it in GitHub Desktop.
Aegir: Switch Site Domains
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// put in $aegirhome/.drush/siteswitch/ | |
// run with: drush @hostmaster siteswitch "regexp" "replacepattern" | |
// example: drush @hostmaster siteswitch "(.*)\.yourdomain\.com" "\$1.yournewdomain.com" | |
function siteswitch_drush_command() { | |
$commands = array(); | |
$commands['siteswitch'] = array( | |
'description' => dt('Run siteswitch'), | |
'arguments' => array('search' => 'Pattern to search for', 'replace' => 'Pattern to replace'), | |
); | |
return $commands; | |
$nodes = db_query('SELECT nid, title FROM {node} WHERE type="site"'); | |
while ($site = db_fetch_array($nodes)) { | |
if (preg_match('/' . $search . '/', $site['title'])) { | |
$args = array( | |
'new_uri' => preg_replace('/' . $search . '/', $replace, $site['title']), | |
'new_db_server' => 2, | |
'target_platform' => 79, | |
); | |
hosting_add_task($site['nid'], 'migrate', $args); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Target platform and db server is hardcoded, make sure you change that to suite your needs.